Skip to main content
gamedev.net
🔒 Locked

Using Framebuffer objects?

Started by mlt 1 reply 500+ views
Original Post
mlt
mlt
I am currently using Framebuffer Objects (FBO) to render a mirrored scene to a texture. I then map this texture to a surface to create reflection. EDIT: I am using Cg vertex and fragment programs to do the shading. 1) Scene above surface http://img75.imageshack.us/img75/6606/reflect1aj8.jpg 2) Mirror of scene http://img220.imageshack.us/img220/5436/reflect2iw0.jpg 3) Scene above surface and its reflection in the surface http://img75.imageshack.us/img75/8626/reflect3tn2.jpg Step 1) and 2) seems to go ok, but when I map the texture to the surface something goes wrong. I currently just use the texture coordinates from the vertex program which must be wrong. Where can I find some info on how I should compute the texture coordinates for the texture lookup in the fragment program?
idinev
idinev
I think this will help:
varying vec2 uv;void main(){	vec4 pos = ftransform();	uv = (pos.xy/pos.w) * 0.5 + 0.5; 	gl_Position=pos;}


It's a special case of projected textures. You should be ignoring the tex-coords received from the VBO/VtxArray.
mlt
mlt
What does

ftransform

do? I have read that its an GLSL function but cannot find any info in the Red bible about that function.

And why:

(pos.xy/pos.w) * 0.5 + 0.5;

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.