Jump to content
  • Advertisement
Sign in to follow this  

Texture Coordinates

This topic is 3802 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

Well, I'm trying to create water. I want to simulate a wave by moving the texture coordinates of a quad by some amount. Thus the lookup to the noise texture will be displace for which I will use that displacement in my projected texture lookup. I have everything working except the noise texture lookup. The Main Function

  // ....
  // Reflection stuff above

  SHADERS.SetCurrentShader( GRAPHICS::GLSLShaderManager::ST_WATER );
  SHADERS.SetUniformSampler( GRAPHICS::GLSLShaderManager::ST_WATER, "noise", 1);
  SHADERS.SetUniformSampler( GRAPHICS::GLSLShaderManager::ST_WATER, "reflection", 0);

  Enable2DTexture( 1, GetTexture("noise.bmp") );
  Enable2DTexture( 0, BlankTexID );

// Using these 2 calls below slow the framerate down to 1 Frame / 5 secs

  SetupWaterTextureMatrix( 1 );


All Helper Functions below
void SetupWaterTextureMatrix( unsigned active_texture )

  glMatrixMode( GL_TEXTURE );
  glActiveTexture(GL_TEXTURE0 + active_texture );


  glTranslatef (0.5, 0.5, 0.5);
  glScalef (0.5, 0.5, 0.5);


I think the problem may have to either do with the Texture Coordinates, but I am not sure
void DrawTexturedFloorQuad2(void)

  glMatrixMode( GL_MODELVIEW );
  glLoadMatrixf( current_camera->GetCameraMatrix() );

  static float time = 0.0f;
  time += 0.001f;

  glBegin( GL_QUADS );

  glTexCoord2f(0.0f + time, 0.0f); 
  glVertex3f( -100.0f,0.0f, 100.0f );
  glTexCoord2f(0.0f+ time, 1.0f); 
  glVertex3f( -100.0f, 0.0f, -100.0f );
  glTexCoord2f(1.0f+ time, 1.0f); 
  glVertex3f(  100.0f, 0.0f, -100.0f );
  glTexCoord2f(1.0f+ time, 0.0f); 
  glVertex3f(  100.0f, 0.0f, 100.0f );


void Enable2DTexture( unsigned active_texture, unsigned oGL_id)
  glActiveTexture( GL_TEXTURE0 + active_texture );

  glEnable( GL_TEXTURE_2D );
  glBindTexture( GL_TEXTURE_2D, oGL_id );

  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); // far from camera
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); // close to camera

Share this post

Link to post
Share on other sites
I am not using VTF at all due to the fact that my ATI card doesn't support it. All i am doing is rendering the scene upside down and clipping everything above the water plane. Then I use glCopyTexSubImage2D to take a snapshot of the buffer.

All this works.

Then I have the code that you see above. I just projected that copied reflection to a quad that I call water.

I was trying to displace my noise lookup by using glTexCoord2f(0.0f + time, 0.0f); For some reason I'm not getting the result's i was expecting. I'm wondering if i possible missed some texture parameters.

I'm thinking about taking a different approach and sending uniforms to the shader for noise texture displacement.

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!