Tesselated Terrain - Version 1.6 [with download]

This is really amazing but I have the following result when launching the script.

ATI readon HD 4650

It seems the terrain only works on NVIDIA cards … on ATI cards something prevents it from running …

Are you using Cg or GLSL? I will be including a fix for advanced Cg shaders on non-NVIDIA cards with 1.8.2.

Code using Cg. And if you can fix it. It will be the most wonder of next version.

I ported Cg shaders to GLSL to run it on the non NVIDIA cards.

terrain glsl shaders

To use you should put *.glsl files into the shader directory and rewrite shaders entries from Cg to GLSL in the main.py:

        #self._terrainElem.setShader(loader.loadShader("shader/terrain_engine.cg"))
        gl_shader = Shader.load(Shader.SLGLSL, 'shader/te_vert.glsl', 'shader/te_frag.glsl')
        self._terrainElem.setShader(gl_shader)
        #postProcessingShader = loader.loadShader("shader/post_processing.cg")
        #preBlurShader = loader.loadShader("shader/post_processing_blur.cg")
        postProcessingShader = Shader.load(Shader.SLGLSL, 'shader/pp_vert.glsl', 'shader/pp_frag.glsl')
        preBlurShader = Shader.load(Shader.SLGLSL, 'shader/pp_vert.glsl', 'shader/pp_blur_frag.glsl')

Thanks ninth, I did not test the shaders yet, but its cool you had the time to port it to glsl!

For the record, Cg shaders should run fine on non-NVIDIA cards, especially with the bugs fixed in the latest devel version of Panda. If they don’t, please reopen the corresponding bug report.

Just downloaded Panda3D-2013.08.13-85.exe and got empty black window with the any of my Cg examples.
No any errors, except

But this message appear even with GLSL which works well.
Not sure that it the same bug, but possible related

Win 7 x86, Intel onboard video

I’ll can test it on ATI a little later

Which sample shows that error?

First time I tryed sample from this topic, and then I tryed some of my own Cg samples and get the same result.

I’ve experimented a bit and found out that error messages cause by using postprocessing filters, but black window stayed on even if I remove all filters. Also I tryed to use minimal example from the Manual and seems that it works more or less correctly. I’ll continue experiments and try to figure out what exactly causes this effect.

It’s an error in the FBO code. I recently made changes to the FBO code, so I’ll look into it and see what I broke - I’ve got an Intel HD 4000 card so I should be able to test that.

Hmm, actually, you’re right - it does appear that Cg is broken on my Intel card. The FBOs weren’t the problem. (There was a different problem with buffers on Intel that I’ve now checked in a workaround for, though.)
Unfortunately, I won’t have time to look into the issue any time soon. Presumably, the issue has already been around for a while in CVS - or is this the first time you’re encountering it? Is there an existing bug report, and if not, could you file one?

Just checked - this error message appears on 1.8.1, but on 1.8.1 Cg works more or less, except issue with profile.

Also I tested last dev build on ATI and get the same result as Intel

And I think that I know why I get black screen - seems that some attributes (color, texture) not passed to the shader and all of my scene became solid black. But one strange thing - I apply shader to the single model, but seems that it affect to the whole scene.
For the test I used this simple shader, applied on the ‘smiley’ model:

//Cg 
void vshader(float4 vtx_position : POSITION,
             float4 vtx_color: COLOR,
             float2 vtx_texcoord0 : TEXCOORD0,
             out float2 l_texcoord0 : TEXCOORD0,
             out float4 l_position : POSITION,
             out float4 l_color0 : COLOR0,
             uniform float4x4 mat_modelproj)
{
  l_position=mul(mat_modelproj, vtx_position);
  l_color0=vtx_color;
  l_texcoord0 = vtx_texcoord0;
}
 
void fshader(float4 l_color0 : COLOR0,
             in uniform sampler2D tex_0 : TEXUNIT0,
             in float2 l_texcoord0 : TEXCOORD0,
             out float4 o_color : COLOR)
{
  //o_color=float4(l_color0[1], l_color0[0], l_color0[2], l_color0[3]);
  //o_color=float4(1,0,0,1);
  o_color = tex2D(tex_0, l_texcoord0);
}

Result of the tests: (1.8.1 / dev)
o_color=float4(l_color0[1], l_color0[0], l_color0[2], l_color0[3]); -> White sphere / Black sphere and black square instead of FPS counter
o_color = tex2D(tex_0, l_texcoord0); -> Textured sphere / White sphere and black square instead of FPS counter
o_color=float4(1,0,0,1); -> Red sphere / Red sphere and red square instead of FPS counter