Sign in to follow this  
Isolier

Projective Texture For Water

Recommended Posts

Hello, I have read many resources on projective texturing, but apparently I am not really getting it... This is what I have so far:
		gl.glViewport(0,0,512,512);
		gl.glScalef(1.0f, -1.0f, 1.0f);
		gl.glCallList(terrain);
		gl.glBindTexture(GL.GL_TEXTURE_2D, textureObjects[REFLECT_TEXTURE_ID]);
		gl.glCopyTexImage2D(GL.GL_TEXTURE_2D, 0, GL.GL_RGBA, 0, 0, 512, 512, 0);
		gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
		gl.glViewport(0 , 0,1024 ,768);
		gl.glScalef(1.0f, -1.0f, 1.0f);
		
		gl.glClientActiveTexture(GL.GL_TEXTURE3);
		gl.glActiveTexture(GL.GL_TEXTURE3);
		gl.glEnable(GL.GL_TEXTURE_2D);
		gl.glBindTexture(GL.GL_TEXTURE_2D, textureObjects[REFLECT_TEXTURE_ID]);

                gl.glBegin(GL.GL_QUADS);
        	gl.glNormal3f(0.0f, 1.0f, 0.0f);
        	gl.glMultiTexCoord2f(GL.GL_TEXTURE3, 1.0f, 0.0f); 
        	gl.glVertex3f(512.0f, SEA_LEVEL*MAX_HEIGHT, -512.0f);
        	
        	gl.glMultiTexCoord2f(GL.GL_TEXTURE3, 0.0f, 0.0f);
        	gl.glVertex3f(-512.0f, SEA_LEVEL*MAX_HEIGHT, -512.0f);
        	
        	gl.glMultiTexCoord2f(GL.GL_TEXTURE3, 0.0f, 1.0f);
        	gl.glVertex3f(-512.0f, SEA_LEVEL*MAX_HEIGHT, 512.0f);
        	
        	gl.glMultiTexCoord2f(GL.GL_TEXTURE3, 1.0f, 1.0f);
        	gl.glVertex3f(512.0f,  SEA_LEVEL*MAX_HEIGHT, 512.0f);
                gl.glEnd();
                gl.glDisable(GL.GL_TEXTURE_2D);
		
		gl.glCallList(terrain);
However, what I am getting is a texture that spins with the view of the camera, not to mentiont the "reflection" isn't exactly corrent to begin with... What am I missing? Thank you in advance. [Edited by - Isolier on October 7, 2005 2:55:47 PM]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this