Guest shane.ploenges Posted March 7, 2011 Posted March 7, 2011 Hi everybody. Currently I'm trying to implement a prototype of sun & moon in the skies. Since we have the sun with all the scattering for free (thanks to Unigine), I need to add the Moon only. Now, I have the direction vector which indicates where the Moon should be in the sky and I need to show the Moon there. The Moon has to have the following properties: 1. A billboard - always facing the camera. 2. Glowing. 3. Should be always behind all the geometry (mountains buildings, trees) no matter how far they are. I have create a billboard and a material for it with the texture and added 'ambient emission' as the glow thing (are there any other ways to make it emissive)? Now I have a little idea how to draw it where I want. At the moment I just place it 1000 units along the vector, but this is not a solution. I probably need to do it from the current camera and also what if there are mountains at 2000 distance? The moon then would be just in front of them which is wrong. So the questions are: 1. How do I get the current camera (player position?) we are rendering from in the script? 2. How do I designate that the Moon is rendered last or among the last? I tried to change Common->Options->Order, but nothing changes - the moon is still rendered in front of the trees. I also tried turning off depth buffer in the material settings - does not help. Btw it has Alpha Test on - it is needed. Here is the shot: Thanks for any help in advance!
Guest shane.ploenges Posted March 8, 2011 Posted March 8, 2011 Ok, figured out how to get the current camera: Player player = engine.game.getPlayer(); Now I'm trying to make the moon to be rendered AFTER anything (including clouds)... Any ideas? I will also need to render some stars during the night - I guess they will follow Moon's steps. Just figured out that clouds (layers, I don't use the volumetric ones) stay white despite of the sun light source emitting no light (black). Is there any way to make clouds darker 'during the night'? Like, for instance, applying ambient light (which I reduce) or something? Thanks!
Guest shane.ploenges Posted March 9, 2011 Posted March 9, 2011 Another observation: Moon is now rendered correctly with the following settings (it is billboard): 1. Alpha Test On (for the texture is using alpha) 2. Post Scattering On (not sure what it does in this case though) 3. Depth Mask Off 4. Order +8. So far the questions: 1. Is the tooltip on the 'order' control is wrong saying that surfaces with lowest order (-8) will be rendered first? Because if I use -8, then the moon overrides the scenery and +8 the moon is behind the scenery. So with +8 it looks like the moon is rendered first. 2. How can I make clouds 'night-compatible'? They are totally white when it is dark in the world... Looks weird. Now I'm looking into the materials, but can't see any means yet. 3. I can make moon billboard 'Screen Aligned' so it does not get deformed when not in the center of the view frustum. Very neat feature, btw. But the sun does get deformed - any way to fix it? Thanks in advance for answering these questions.
pluton Posted March 10, 2011 Posted March 10, 2011 I think that it's better to place the Moon billboard somewhere behind the scene, at a far distance. Then you should set the following parameters of the material: depth mask - off, deferred pass - skip, all light passes - skip, ambient emission - on. The Post Scattering and Order parameters only work for transparent objects. If scattering attenuates the moon, try adjusting scattering parameters and the moon materials emission scale.
Guest shane.ploenges Posted March 11, 2011 Posted March 11, 2011 Thanks for the reply, pluton. My moon has pretty much the same setting. I change the order to +8 because this way I don't care how far it is placed - more over I can control its scale simply by placing it further or closer. I can use your advice as well and always place it at the edge of the view frustum, so it is never drawn in front of anything, but there could be artifacts when you move your camera. Having order changed solves this problem. Hmm, if I skip deferred path then glow does not work. :mellow: Yes, the moon gets attenuated, but that's fine - it looks quite real. Thanks for the help again! Do you happen to know what to do with the sun being deformed when it is not in the middle of the screen? It does not look like a circle due to the projection. :(
pluton Posted March 11, 2011 Posted March 11, 2011 Hmm, if I skip deferred path then glow does not work. :) Ok, if you want to use the glow, you may render it during the deferred pass (is done by default). But using HDR effects gives better results without using a standard glow effect. Do you happen to know what to do with the sun being deformed when it is not in the middle of the screen? It does not look like a circle due to the projection. :) It may occur when you are viewing the sun disk at a large angle (i.e. it is distorted because of the big field of view). Decrease the size of the sun disk or decrease the field of view to reduce influence of perspective distortion if it's critical.
Recommended Posts