Friday, 4 March 2016

Better Sim design in Opensim - some tips and tricks

Opensim has some particular quirks that sometimes make it hard to build responsive environments. More controlled environments such as games or pre-designed experiences have ways of mitigating these issues that are not available to us. That said, there are ways of building and ways of thinking about sim design that will help you deliver a more responsive experience.

This is aimed at people who want their regions to be visited and care about the user experience. This is for people who want a world they can confidently use VR goggles and not throw up. They are good tips for anyone to follow but if your a hobbyist/casual users its probably of less interest.

1. Build small
I know in Opensim its really really tempting to go for the biggest amount of land you can get, then proceed to cram it with as much stuff as you can find. if this is your private space and you have a great computer and/or you dont care about framerates and load times then fine. But if you are expecting visitors, this is a BAD move.

The larger the space you have, the more sparse it needs to be. This is because issues like LOD, LOS and Overdraw (which you will read more about below) conspire against you in larger environments. In a game situation for example, objects that are on your screen are pre-loaded and rendered and anything not on your screen (Line Of Sight/Field Of View) is "culled" essentially meaning it does not exist and will not place burden on your CPU. Not so in Opensim.

You can easily test this in any moderately full sim with Firestorms Phototools. Bring up the FPS monitor and cam to the corner of the sim. You will notice your frame rate jump and your camera and avatar movements will become more responsive.

Now, slowly cam or turn from the outer corner into the center of the sim. See the drop in the numbers? If you do this in a 1x1 sim, the effect is barely noticeable, but try it in a dense 2x2 or 3x3 and I am SURE you will see what I am talking about. Its common to loose 25+% of your FPS when staring inland as opposed to looking out to sea. Even system terrain with no objects rezzed will effect this.

I want to stress that this is normal behavior. Something is not "wrong". Its just something to consider. Every object that you rez has a rendering cost. Rez a lot of objects and your CPU struggles. Designers (like myself) can only help customers so far by designing low poly and trying to make effective LOD models (but this can be a crapshoot as LOD models can be very context specific, more below). The rest is down to the sim designer and how they choose to use objects within the chosen space.

Therefore if you want to build a "dense" environment such as a city or large, thick forest I strongly recommend using nothing bigger than 2x2 (4 Regions). If your going for high detail/density, its much better to build a series of smaller worlds rather than try to cram it all into one big worldspace.


2. Dense on the outside, sparse on the inside
If you MUST build in a larger area than 2x2, consider building the densest parts of the build on the outer sims and trying to leave the center relatively sparse. This way, when users are looking towards the center of the world, the CPU will not suddenly get hit by looking at 3-4 regions of dense geometry all at once. if you want two densely built up areas, separate them by as much distance as possible and make the other areas/sims less dense.


3. Think LOD, think LOS
LOS - Line Of Sight (also called FOV or Field of View). Related to point two. Say you are building a roleplay sim and somewhere you want a large settlement. its more beneficial to build this settlement to the corner or side of the sim rather than the center.

As I mentioned before, in games anything not in your direct FOV/LOS is culled and effectively ceases to exist. In Opensim if you are in a house with your draw distance at full and there is a huge forest behind you outside, that forest is still there, being calculated and sucking up your computational power even though you cant actually see it.

Say you have a 3x3 region and build in the center sim. Now, no matter which direction the user looks there is an extra sim full of geometry to render in every direction on top of whatever is actually in the sim your standing in. Those sims are not very far away, and so probably 90% of objects will be at the Med/Low LOD stages (depending on scale as mentioned above). Also conversely, if your user is in ANY other sim, they have to render the entire settlement too!

Build in the corner then you have empty ocean to one side, 3 sims at Med/Low LOD on the other side and the rest of the sims so far away most objects should be culled completely or at the lowest LOD stage. This will result in improved framerates both inside and outside your "built up" area.
LOD - Level Of Detail. If you are a designer and in control of this aspect, you can greatly reduce the burden on users computers by designing effective LOD. The problem with LOD as I eluded to above is that it is often very context specific. Items need a different LOD if they will be placed inside or outside for example. If placed outside the object will need multiple, fairly accurate models, as they will possibly be viewed from far away. An object inside probably only needs 1 LOD stage and can then be culled completely after that, as they will never be seen by anyone not directly in the house/castle/whatever. But that depends how big the building is, of course.

LOD is also effected by scale. So somewhere between distance and scale is the "sweet spot". Getting it right is a matter of practice, observation and adjustment. It can be like pulling teeth at times. Not exactly my favorite part of the process, in case you cant tell.



4. Be aware of Overdraw
Overdraw is a thing which happens when too many alpha textures are present on screen and your computer cant decide which is the correct order to display them. So it displays all of them at once. You may have looked at a tree or plant and noticed a strange effect where you can see the leaves both in front and behind at the same time and the object seems in a weird semi-solid semi-transparent state. Happens with grass most commonly. That is overdraw. It hurts your brain to look at it and it hurts your computers brain too! If you build big areas full of plants, I can almost promise you this is why you are experiencing lag.

Alpha textures are most often found on plants and trees. Most plants and trees use "alpha blending" which causes overdraw. But we now have the option of changing that. Select the face of the plant in the build menu, go to the textures tab and select "Alpha Masking". Then type a number between 10 and 100 into the box below.

Alpha Blending allows pixels to have both transparency and colour. Alpha masking does not allow this. Pixes must be transparent OR coloured. The number you just entered above is the threshold ratio. The higher the number, the more pixels are moved from "colour" over to "transparent". This saves your computer from having to calculate this aspect and eliminates overdraw. Leading to significant performance benefits for most users. The downside is it makes lighting look harsher and as Opensim has pretty crappy shaders it can make some things look ugly. If only we had shadow maps.

More on overdraw here: SL forums: Grass Lag


5. Stay away from sculpties
I know, I know. I sell mesh so I would say that right? But its pretty hard to defend sculpties these days. You can nearly always do it better with mesh both in terms of beauty and efficiency. Consider that EVERY sculpty has 1024 Tris no matter what it is, large or small. Most sculpted items can be made with significantly less than this. Rez 10 sculpties and thats 10,000+ tris! You can build a small mansion with that.

If your still working with sculptie tools do yourself and your users a favor and stop it right now and learn Blender. It isnt that hard, if you can "get" sculpties, you can "get" mesh. and there are plenty of resources for education out there these days.

Start with:
*Camera control and interface
*Mesh editing and manipulation
*UV mapping

Then spice it up with rigging and baking once you get the hang of those 3 key areas.

Sculpties are fine for hobbyists but if your making a world designed to be visited then leave the sculpties at home!


6. Recyle
ALWAYS reuse objects and textures wherever you can. The Kitely Evergreen Island is a good example of this. Break that whole island down and I would guestimate (I didnt keep  exact count) no more than a few dozen meshes and textures were used to create it. Whatever the number it is LOW. Thats why it loads fast and responds well.


7. Tiny Textures
Just as the best meshes use the fewest number of polygons possible, the best builds and objects also use the smallest texture size to get the job done. Its easy when designing to "not see the forest for the trees" and make every texture surface super crisp and high definition. When your working on a single object its easy to get lost in the detail. But texture size has a bigger effect on load times and lag than mesh complexity.

It is also a bad trend set in Second Life (both users and designers are equally to blame here). People should understand that higher texture quality comes at a significant cost. People have developed bad habits of expecting textures to be super crisp at every zoom level. Which is ridiculous.

If you spend all day with your cam zoomed into tiny details and grumbling that the textures dont stay sharp, sorry to tell you but you should probably get outside more. Just dont put your face too close to anything or you might get cranky at the poor resolution of RL ;).

Ideally, only textures that cover large areas (such as terrain or main areas of brick/and stonework on buildings) should have 1024x1024 textures. Everything smaller can usually be done with 512x512 or smaller. In the process of designing anything, you should always ask yourself if the textures could be smaller.

Another great thread from the SL Forum archives on this issue right here. Note in particular the very useful chart on page 1, second post.

8. Know your Viewer
While all of the above is well and good, it can all get thrown out of the window when it comes to viewers. Settings in your users viewers such as LOD Level, Draw Distance and Shadows/Materials can have a drastic impact on how your users see your worlds and the performance they experience.

The only way to ensure your users see your world as intended is to recommend the viewer settings you used while building. Try not to stray too far from the default settings of whichever viewer you use to make life easier for your end users.

Many users do not realize how much control they can have via the viewers settings and it is best to recommend what you feel is essential via your website, world page and/or in-world.


I hope that was a helpful rant and I have given you some ideas for better world building!

7 comments:

  1. Thanks for the explanation of Alpha Blending. Never knew that one. There is one thing I can think that could be added - Textures need to be just as small as possible. The problems you mention about large sims are always due not to too much geometry, but to to overrunning the texture memory and thus being forced to redraw the textures by the host CPU every frame. FPS then drops severely.

    ReplyDelete
    Replies
    1. Glad it was an interesting read :)

      Your quite right about textures of course. I will add a section on that ASAP. Thanks for the feedback!

      Delete
    2. I should add as well, if you want to experience this firsthand, drop into my Kitely showroom. Walk across the bridge and there are two oak trees in front of you. One with masking, one with blending.

      Cam up into the leaves of both and you will feel the difference in responsiveness.

      Delete
    3. This comment has been removed by the author.

      Delete
  2. thank you! I think i have done some of this, creating spots of interest, different themes, reusing trees but rotating and tilting them.. much more to think about!

    ReplyDelete
    Replies
    1. Your very welcome :) yes there is so much to think about it can make your head spin sometimes. But just keeping these things in mind will help you get better results.

      Delete
  3. I am curious about a couple of things. I understand what you're saying, but doesn't draw distance and object occlusion have significant effect on viewer behavior. You stated if you're inside a house with a forest behind you, you still access the forest. However, if your draw distance is 32 and you have Object Occlusion turned on... you won't see anything beyond the walls.

    An example is Replicant City in ElvenSong on OSgrid. The "Hall of Funny" consists of more than 1,500 signs, each sign consisting of a different 512x512 texture. If one put all of those signs inside one huge room the texture access would likely bring your avatar to a standstill. However the Hall was built in short, twisting corridors so that only 50 or so textures show at any given time. As a result there is no perceivable lag while touring the exhibit.

    The same holds true for a densely packed city. Anything on the other side of the building you're facing shouldn't impact your viewer. Experienced shoppers know when you enter a store, use your Quick Settings to drop your Draw Distance to 64, and when you exit push it back up to 128 or 256 so you can see the area around you and figure out where to go next.

    Beyond that, your suggestions to repeat textures, meshes, and avoid sculpties are very good suggestions. (Sculpties: interesting idea, done very badly.)

    You offer a lot of good building points and thank you for that. A number of these things are valuable tips for beginning builders.

    ReplyDelete