Jump to content
  • Advertisement
Sign in to follow this  
stringa

Texture Coordinates

This topic is 3721 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
//  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
//  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);

  SetupWaterTextureMatrix( 1 );

  DrawTexturedFloorQuad2();




All Helper Functions below
void SetupWaterTextureMatrix( unsigned active_texture )
{

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

  glLoadIdentity();

  glTranslatef (0.5, 0.5, 0.5);
  glScalef (0.5, 0.5, 0.5);
  glMultMatrixf(current_camera->GetProjection());
  glMultMatrixf(current_camera->GetCameraMatrix());

}



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

  glMatrixMode( GL_MODELVIEW );
  glLoadIdentity();
  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 );

  glEnd();
}



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
Advertisement
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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!