Friday, June 26, 2015

RLV 2.9.12

Hi there !

I have become a mesh body user not long ago, and like every mesh body user, I quickly found out that having dynamic shadows activated while wearing a complex mesh body (Maitreya which is my choice, but also Eve, Belleza, Slink, Abar, TMP...) totally kills the FPS (Frames Per Second, the measure of rendering speed). Like, it divides them by half. It was so bad that I had to turn the shadows off, and I'm sure I'm not the only one.

I knew it was due to the avatar shadows, simply by looking at the Fast Timers in-world (press Ctrl-Shift-9 to show them). A little digging in it and you see "Avatar Shadows" in plain letters as the FPS hog. In fact, this was due specifically to complex rigged mesh rendering, the FPS slowdown wasn't due to unrigged attachments or anything like that. And since mesh bodies are among the most complex rigged mesh around, they kind of made that issue more obvious. And over time, more and more people switch to mesh bodies, so something had to be done.

Recently Chalice Yao implemented an optimized version of the avatar shadow rendering for her own viewer (NaCl). It does not lower the FPS for a single avatar much (since it has to render nearly all the passes the original algorithm does), but the optimization seems to work well for a crowd. After a short conversation with her, I had another idea and wanted to simplify the shadow of every single avatar in sight, by not rendering rigged mesh attachments at all, and rendering the avatar shape instead. I think Chalice will use that as an option in her viewer too since I integrated hers (thank you for that by the way, Chalice).

So I have added a new debug setting to the RLV called "RestrainedLoveAvatarShadows". You can access it by going to the "Advanced" menu, selecting "Show debug settings" and typing "RestrainedLoveAvatarShadows" in the edit box on the small window that shows. If you don't see an "Advanced" menu, press Ctrl-Alt-Shift-D to make it show.

This debug setting can take 4 values :

0 : No avatar shadow at all. Well, except unrigged attachments, which will still show. I don't know how to selectively hide the shadow of an object when it is attached, compared to an object that is not an attachment, since we are not in the right context for that when it comes to rendering shadows (we're dealing with surfaces and spatial partitions at that time of the process).

 
Level 0, 83 FPS. As you can see, my unrigged attachments (hair, necklace and a few other things) look like they are floating in the air).

1 : Simplified shadows (my method). By using this method, none of your rigged attachments will have a shadow. More over, none of your alpha layers will mask your body in its shadow either, so the result is that you will see your system shape instead of your mesh body shape. The downside to this is that your mesh hair won't show either, neither will your mesh clothes. This method is good for those who use a human mesh body, but is inadequate for non-human avatars such as animals, robots etc, since the underlying avatar shape is usually very thin and deformed and serves only as a skeleton.

Level 1, 83 FPS. Notice the avatar shape rendered on the white screen, and the lack of anything rigged (in particular my boots, which are replaced with the shape of the shoe base). Notice there is no difference in speed with Level 0, even at such high FPS counts.

2 : Chalice's optimized algorithm. You won't see a difference between that rendering and the legacy one, and the FPS gain will be minimal if there are only a few avatars around, but apparently this is good for crowds.

Level 2, 47 FPS. Notice that the shadow is visually exact, all my rigged attachments are rendered. But it has a cost in rendering speed.

3 : The legacy SL rendering. Exact, but slow.

Level 3, 45 FPS. Here too the shadow is exact.


In this example, from 45 FPS to 83 FPS, that's a 180% boost. This is what I generally observe (even in areas with a lot to render, while these pictures have been taken in a skybox to really emphasize the difference in speed), a speed boost between 150% and 180% when setting RestrainedLoveAvatarShadows to 1.

You may say "ok level 1 is cool but the shadow looks like crap" and you'd be right. However, you seldom look at your shadow. Your shadow is there to make the scene more realistic, but it isn't really the center of the attention. More over, very often you can see your system shoe base rendered at the same time as your rigged feet and shoes anyway.

Why ? Because short of a mesh body, you have to use an alpha layer that has an actual texture attached to it in order to hide your feet, and the renderer does not like that at all. If one texture in an alpha layer is not totally transparent, then it will have a full shadow. I believe this is done this way for optimization purposes. Mesh bodies, on the other hand, hide the whole body except the head, so it uses fully transparent textures, and that hides the shadows of the system hands and feet.

Lastly, you often have "Ambient Occlusion" selected in the graphics preferences, which not only adds ambient occlusion to the rendering (i.e. a darkening the corners, making the scene look more realistic too), but also blurs all the shadows (don't ask me why). In the end, with Ambient Occlusion on, your shadow looks good enough even at level 1. And if you really want to take good pictures including your shadow, you don't need the FPS boost so you can switch to level 2 or 3.


Ok, that was a long explanation, sorry about that ! You can grab the RLV for Windows here :

www.erestraints.com/realrestraint

Direct download :
www.erestraints.com/realrestraint/RestrainedLoveSetup.exe

And the MD5 hash for the executable is :
a8a225d6a105f25a1686e688d17605b9


Have fun !
Marine