Jump to content
  • Advertisement
Sign in to follow this  
mlt

Bug in Nature Scene by nvidia?

This topic is 3663 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am trying to understand the implementation of the Nature Scene by a nvidia programmer: http://developer.nvidia.com/object/nature_scene.html Here is some of the sky shader:
      void main(void)
      {
        
        vec2 newUV  = vec2((gl_Vertex.x - offset.x)/params.x,
                           (gl_Vertex.z - offset.z)/params.z);
      
        gl_TexCoord[0].x  = newUV.x + params.w*0.66;
        gl_TexCoord[0].y  = newUV.y + params.w*0.33;
        gl_TexCoord[0].xy *= 2.0;

        gl_TexCoord[0].z = newUV.x + params.w*1.33;
        gl_TexCoord[0].w = newUV.y + params.w*1.66;
        gl_TexCoord[0].zw *= 3.0;
 
        //Get the vertex height and scale it to 0 - 1 range
        intensity        = gl_Vertex.y/params.y;
        intensity        = exp(clamp(intensity, 0.0, 1.0))/2.8;
        intensitySqrd    = intensity*intensity;
   
        gl_Position      = ftransform();
      }


but what happens with the newUV.y coordinate? It is never calculated: vec2 newUV = vec2((gl_Vertex.x - offset.x)/params.x, (gl_Vertex.z - offset.z)/params.z); But it is used later in: gl_TexCoord[0].y = newUV.y + params.w*0.33; and: gl_TexCoord[0].w = newUV.y + params.w*1.66; is this a bug, don't see how it can work?

Share this post


Link to post
Share on other sites
Advertisement
I'm not familiar with GLSL, but that looks fine to me. NewUV is assigned this:


vec2((gl_Vertex.x - offset.x)/params.x, (gl_Vertex.z - offset.z)/params.z);


It looks like x AND y is set to me.

Share this post


Link to post
Share on other sites
Yes of course my bad, this thing that confuses me is the reason why the 'z' component is used and not the 'y' component? Don't think that makes any sense.

Share this post


Link to post
Share on other sites
Mapping two cloud-textures to a skydome thats inside an AABB. params.xyz contains the height, width and depth of the AABB, and offset contains the lower corner of the AABB. Params.w is the time.

When determining the newUV only the depth and the width are used not the height.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!