Jump to content

How to create a shade?


Ark Vuckovic
 Share

You are about to reply to a thread that has been inactive for 3624 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Hello everyone,

Here is my scenario. I use Blender 2.65. I made a pergola. Applied the AO to it.  Everything looks good, but now I am trying to cast a shade on the ground. Without a proper shade this thing looks silly:). Do I need to create a separate plane for the shade? How do I bake this texture?

I created a plane on the base of the pergola and rendered it. Here is my result.

pergola shade.png

Still my question is, how to separte the shade from the pergola?

Link to comment
Share on other sites

The trouble is that some people will have lighting and shadows enabled in their viewer, and the viewer shadows will conflict with whatever you provide (except at one time of day, perhaps). Others users will not, and would benefit from your shadow. For the ground shadow, you could provide a separate plane and the user could choose whether to use it. For shadows on the mesh, you are stuck. I guess you could provide two (or more for different conditions) textures, with and without the shadows*. If you are doing that, you could include the ground shadow plane in the mesh. You can bake any lighting you like to set up in Blender, but I don't know if you can bake to an image with an alpha channel for the transparent ground shadow. If not, I suppose you would have to edit it in photoshop/gimp after baking it with solid colour.

What we need is a texture toggle that sets the transparency depending on the viewer setting for lighting and shadows! Anyone like to do the feature request? Can that setting be detected in a scipt, which could change the texture accordingly? (I hope not - that would be more lag!)

*or you could use a whole-mesh shadow overlay mesh of the sort that has been discussed in recent threads here.

  • Like 1
Link to comment
Share on other sites

Hello, don't give up so easily =)

Its always nice to have an object with several options. Especially since it might be re-used in different places. (apart from users not having shadows enabled also some Sims have objects in the sky or a whole megaprim covering the sky area preventing shadows from being casted. In such cases a version with artificial shadow would be nice to have)

in general I'd suggest just making one more single Polygon on the object ( a quad in this case with 4 vertices) size it as big as the shadow would need to be and move it to the ground position.

Edit: Good input from Drongle  - separate objects might be better in this case this way you can keep the shadow plane non-physical.

Make sure the Normal of that polygon is facing the right way (upwards in your case) since SL has no double sided rendering and the backside of each normal stays invisible / unrendered.

Now select this face and assign a new material to it. (you can have up to 8 faces / materials per one object/mesh) you just have to ensure that all LODs will have the exact same amount.

UV unwrap that one polygon and distribute it over the full size of a newly created image (make its background white and the resolution max. 512x512 that should be way enough for a simple shadow) in blender which you will assign to this new material and its UV area. (that one polygon)

Now in blender you can bake the shadow path onto your texture.  (go on the material tab and make sure its 'receiving shadows' set the shadow type in the Lamp object to raytrace and the amount of samples to around 5. In the world-tab set the Gather for the shadows also to raytrace and to an amount of around 15 samples. (this will help smoothing the shadow). 

With that one polygon still selected and its UV and Texture open in the imageview:
switch to the render tab and under 'bake' you choose shadow. Set your 'output' to RGBA to ensure Alphatranparency and the format to PNG. Now bake and save your image.

This will bake you the shadow onto your image. Which you can either use directly when the alphachannel was assigned correctly. Or just quick edit in Photoshop/Gimp to get it to be transparent in the needed spots.

Since you assigned a second material to your object you can now after exporting the model and editing it in SL select this one polygon just as a single face on a cube and assign your shadow texture to it. In  order to have a choice between the two versions (with/without shadow) just make a second version where you simply pull a fully transparent texture on this one face.

PS: i would recommend instead of putting way too many vertices into your model and have a second model surrounding it completly do a shadowbake for your building itself too. and overlay it with a slight Multiply value onto your Objects texture. So that the beams etc also have shadows from the roof of it with the same light angle. And assign this texture to your building for the artificial shadow version next to the shadow texture on the ground polygon)

(repeat: don't forget to add this additional polygon in all of your LODs and to assign the shadow material to it)

Have fun creating, cheers! Code

 

 

  • Like 2
Link to comment
Share on other sites

"...keep it in the same mesh / object. (you need to understand that independent objects have more weight / landimpact as when being in one object."

In this case, I think the weight consideration leads to the opposite conclusion. Including the larger plane in the same mesh increases the bounding box "radius". The download weight part of the land impact (likely to be the deretrmining weight for this item) depends on the square of that radius. So it will increase substantially even though only two triangles are added. On the other hand, the download weights of separate meshes are added together before rounding to calculate the weight for a linkset. The plane will have the minimum download weight and will therefore add little to the weight of the linkset.

To confirm this, I made a simple pergola like Ark's, with a shadow plane about twice the x and y dimensions of the pergola (that is a lot less than the Ark shows). Uploaded as a linkset of two separate objects/meshes, the LI was 4 (download weight 3.9). Uploaded with the plane combined into the same mesh, the LI was 8 (download weight 7.5). So combining the plane doubled the LI compared with linking it.

The unlinked meshes (plane and pergola) had LIs of 1 (download weight 0.1) and 4 (download weight 3.9).

With the linked prims, the physics type of the shadow plane can be set to "none", which is what you want for the shadow. With the plane in the mesh, you have to use special methods to make the physics of the plane disappear. So I think in this case, all these factors work in favour of using a separate object for the shadow plane.

Here it is in Blender. The cube is 1m cubed. As you can see, the plane is too small for more slanted shadows.

apergola.png

 Edited - typos.

  • Like 1
Link to comment
Share on other sites

@ Drongle - true I should have removed the word 'landimpact' from that sentence.

thanks for checking and testing it out that precisely!

The whole LI calculation system of SL is still, to a certain extend, odd.

Given the fact its counting towards their own system and server performance might be understandable that it is not always conform with the values we are used to from other 3D environments / CPU / GPU impacts. And may be one of the reason why I try not to think too much in terms of LI when it comes to the subject of an 'optimized model'.

(and let's not get started about the subject on the difference in LI when it comes to 'sculpty versus mesh'. I can understand LL here but it just shows that it can't really be used blindly when thinking of draw calls and optimization)
And also we might need to remember that they have  joggled the costings of mesh and the calculated landimpact around quite a few times. 

Generally the impact and draw calls of separate objects would  weigh much more due to them having more single used verts plus its 2 objects which need to be calculated stored and updated  (i.e.. If you have a thousand triangles, it will be much, much cheaper if they are all in one mesh, instead of having a thousand individual meshes one triangle each. GPU costs will here be kind of similar but the CPU work will increase quite significant in such a scenario).  

Unless the independent parts inside this combined mesh are very far apart -  in such cases lots engines would 'render' invisible triangles between them and also physics would be more expensive due to the larger all over shape bounding box and other factors.

I am still often really tempted to ignore LI completely and go with the regular knowledge about graphics. And I am most likely not the only one. It sure is a 'measure-point' when considering what you will have to pay for the upload and how much it would take up in space in terms of a region or landimpact. But aside from this lots of it doesn't really apply to regular terms of making an optimized model.

A valid point thou: I didn't think about it when when contemplating to separate or include the shadow in one object -  was that you can and should actually leave the shadow plane with no physics - which you can't while its in the same model. So this is absolute correct from your side.

So of course edited advice for the OP: keep it separated.




Link to comment
Share on other sites

Aside from all the technical stuff which I think has been covered, I wanted to chime in here.

 

I run with shadows all the time and genearlly hate the objects that come with shadows attached. It is easy enough to place them into the floor (thankfully). If, down the line you decide to make shadow maps I would really, really, really (yes three of those) advise you to find a way to make the SOFT looking ones.

I never make cast shadows on my mesh but I know designer who have very nice cast shadows (soft and subtle) and others that do not (pretty much like the ones shown in the examples). So, for any designer that SELLS things --- LOL, please take the quality of your shadows into consideration. A bad shadow is certainly worse than no shadow.

At the same time, telling folks to "turn on their shadows" isn't really a good plan. Plenty of people in SL cannot use shadows (I was one of them for a long time until I bought a very expensive machine a couple of years ago), so they are penalized. Ambient shadows can be seen by lots more folks (maybe everyone - I haven't actually checked), so I would concentrait on making great ambient maps which will add lots of "form" to your builds.


This is a note (just my opinion of course) for othe folks as well as you. I see a LOT of mesh in my blogger role. Some is fantastic, some not so much. Aim for the former *wink*.

Link to comment
Share on other sites

*nods, nods, and nods* (yes also 3 times!)  ; )

It's like the advise i gave someone else yesterday about lighting for the scene to bake textures: find a good middle value. something that works in both cases (shadows or not) - he doesn't need to add something that 'is already there'.

Those objects with either intense blocky black shadows with prolly raycasts and gathers of 1 or so lol are just a pain in the eye. Or the ones who have been baked with too much lights in the scene and each of them being set to cast shadows when u have an object that has the wildest shadows from all directions: also not a good looking result.

And speaking of AO i wish people would be a bit more sottle with their AO overlays or bakes, especially when parts move a tiny bit apart and you start seeing that big black spot isn't really pleasing on the eye. 

I mean in some cases it might be a desired outcome in a matter of certain styles but in general try to be sottle and neutral as much as possible and make something that would work in both scenarios without being understated or overdrawn.

Link to comment
Share on other sites

"..try to be subtle and neutral as much as possible and make something that would work in both scenarios.."

I just want to add even more agreement to that. My shadow above was for illustration. I would never actually use anything like that. Ugh! 

There's a problem with the viewer ambient occlusion on smooth surfaces though - just make a 10x10x10 half pathcut 95% hollow plain white sphere and look inside it while toggling ambient occlusion in preferences! The effects are much worse on various large mesh cylinders. The ao doesn't respect smooth shading.

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 3624 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...