This script is inspired by the Nvidia nature demo ( http://developer.nvidia.com/object/nature_scene.html ). It’s not a 1:1 copy, but very similar. All media have been taken from the original Nvidia demo. The main features are:
dynamic sky with tinting
static terrain with texture blending depending on terrain elevation
water reflection via planar mirror and projective texturing
water distortions
moving grass
fog on terrain and grass shaders
Performance is poor, but you can speed up by reducing GRASS_DISTANCE near the top of the script. Also try reducing fog density for brighter colors: “fog = Vec4( 0.16, 0.32, 0.36, 0.0001 ) # r, g, b, density” in line 118.
Just a simple question : why do you use 800x600 buffer size for water reflection ? It breaks the reflection on my junkware here. So I use power of 2 size and everything is perfect.
You use antialias for the grass, you must mean to use transparency AA, right ? You’ve done that using alpha mode (setting “True” == 1 == TransparencyAttrib.MAlpha). So,
doesn’t help at all, because it only fixes aliasing on points, lines, and polygons, not transparency AFAIK. Moreover, to use framebuffer AA, you have to enable it first (the default is disabled, try to print the config vars, and look for “framebuffer-multisample”).
(2) You are right, setting AntialiasAttrib.MMultisample on grassNP doesn’t help at all. I don’t see a difference on my PC if setting it to MAuto or even MPolygon. I had
framebuffer-multisample 1
in my config file, but moving it into the python code is probably better:
from pandac.PandaModules import loadPrcFileData
loadPrcFileData( '', 'framebuffer-multisample 1' )
Thanks for your help here, it helped me getting a better understanding of AA, but I am still far from having a firm grip on either transparency or AA.
(1) At first I wanted best quality, and since my card supports non-power-two textures I selected the same size for the framebuffer that the window has, to avoid ‘pixel’ effects. This is nonsense of course. The water gets distorted, and choosing a much smaller size gives no loss in quality.
One problem though. If I choose a different ratio than the window has (e.g. 256x256) then I get a strange effect. If I look to the right and left from the start position, and watch the reflections of the hills, then these reflections seem to ‘lean’ to the right and left. Do you have this effect too is you choose power 2 sizes?
i dont see any sqeezed hills… but i can sometimes see the the terrain in the water reflection when looking at … dunno maybe 50degree angle onto the water. in this case the terrain in the reflection seems to be rendered in a side-perspective.
If you’d like to see an example of transparency AA, goto http://www.humus.ca, jump to 3d section page 2 (if it’s not moved around), look for “alpha to coverage” example. It’s awesome, even when the camera-poly angle is very shallow.
Runs on my system, but I think the shaders aren’t working, because everything is a completely different colour from your screenshot and the water reflection looks wrong:
Try not to use arb profile on each shader, remove :
//Cg profile arbvp1 arbfp1
I bet it will work !
@Thomas : what you saw is the front face of the pond base, which is exposed to water cam at some points of view. Try to show the buffer and you’ll see it clearly.
Not sure it can be fixed if the terrain is just 1 piece.
…it sucks. I assume it failed silently, since you didn’t mention any error.
What is your graphics card ? Is it mobile card ? Perhaps the shaders are too heavy for yours.
@ynjh_jo
Thank you again for your help. Setting the camera FOV works like a charm.
@chombee
I get the same effect if I remove all ‘setShader’ lines from the demo. Can it be your card doesn’t support shaders? Or at least Panda3D can’t use shaders on your PC?
@ThomasEgi
I get some artifacts too if I look with flat angles over the water. I think they come from the underwater hills. I added to following lines to the demo (first two lines go into init, the rest somewhere else.
Pressing F4 now moves the camera to the position where it should be when rendering the reflection. It seems the clip plane that should cut of everything below the water surface doesn’t work. So it is a bug in my code, and so far I don’t know a way to fix it.