Tuesday, June 10, 2014

Upcoming RLV 2.9


This is just a heads-up, I am currently working on a few new commands for the RLV (I know, it's been a while, right ?), specifically aimed at handling the camera and the view range. It doesn't sound very glamour said like this, but here is what these commands can do :

- You can restrict the camera within a sphere around the head of the avatar, and if you restrict the distance to zero, it forces the view to Mouselook, without any way to get out of it until the restriction is lifted.

- You can also prevent the camera from going under a certain distance of the avatar's head. It prevents from going into Mouselook as well.

- You can specify a view range... that alone deserves some explanation. It has nothing to do with the draw range of the viewer, which lets you decide how far the objects rez. Here, it "simply" draws a hollow sphere around your avatar's head, at a specified radius, with a specified color and more importantly, a specified alpha. The camera is automatically restricted within that sphere so that your avatar looks normal to you, but the rest of the world may look darkened (or completely hidden). Even better, it can draw a gradient of spheres going from the specified alpha at a specified range, up to 1 at another specified (higher) range. The effect is good enough to simulate gradual darkness or fog. It does not look as good as Windlight fog, of course, but at least that simulated fog is centered on the avatar, not on the camera (but nothing keeps you from using fog on top of it, of course).

These features are great for blindfolds, with or without a gradient of darkness, because you can't see anything around you but you have heightened senses about your own body. I never really liked to obstruct the HUD with a prim to simulate blindness, since SL is mostly a visual world, take out the visuals and it becomes a lot less interesting. So now you will be able to make blindfolds that obstruct the world but not your avatar and not the immediate vicinity (for example the chair you are sitting on, or the bed you are laying on, or the wall you are trying to follow). Couple that with a clever use of RenderResolutionDivisor and/or Windlight parameters, and you can make some nice effects.

The camera and view restrictions are also great for mazes, or overall keeping the avatar from camming around. I know it is already possible through a script, but at the expense of a fast timer, hence a lot of lag for a single feature. Plus, a script would never be able to catch up quickly enough when you go outside the allowed range, so you can see things you are not supposed to see for a short moment. With the RLV handling that internally, the camera simply cannot move further than the limit.

I said earlier that it had nothing to do with the draw distance that decided whether a prim is rezzed or not. This because artificially forcing the draw distance to a low value does not look good, and removes some interesting prims such as lights, walls casting shadows, and the like. It would look, well, broken.

Here is a couple pictures to illustrate what I have been talking about :

With just a semi-transparent bubble around the avatar, set to alpha 0.5. No max draw specified means we can see through. The camera cannot go outside this bubble, by the way.

With both a min and a max draw specified, you can see (barely) a gradient. Beyond the max draw limit, everything is black. Once again, the camera cannot go beyond the min draw limit (where the world starts getting blackened a little).

Of course, those spheres are visible to the user only, not to other people. It is a local thing, as it should be. It would have been possible to simulate all that with attachments, but then everyone would have seen those black spheres, right ?

On a side note, all the limits (camera and view alike) are set to be the most restrictive among those specified. Suppose you have several attachments imposing different view limits, the minimum range will be taken into account, so no way to cheat there. Same for the alpha, the highest alpha is retained. As for the color, it is a mix of all the specified colors (default is black).

There are some other things I'd like to work on if I find out how to do them. For example, I'd really like to be able to restrict the camera to points in space that are directly in the line of sight of the avatar's head. But that requires some heavy computation that cannot take place in a frame update. I'd also like to let the user choose how many steps in the gradient of alpha to render, because the more layers of alpha to stack onto each other, the slower the rendering. Lastly, for now the spheres that are supposed to obstruct the view, do not appear on snapshots. I'm currently working on a way to make them show (the snapshots I took here are not taken with the SL snapshot feature, but with a classic screen capture).

There is no ETA for the release, but it is nearly satisfying as it is, so it should come out soon. I'm also trying to keep the code clear in my repository so that it will be easy to port, for example to RLVa.

Have fun !