controlling automatically generated texture coordinates

ghettotek
Unregistered
 
Post: #1
im using automatic texture coordinate generation to achieve the look of reflections on a polygon via:

[sourcecode]
-(void)initGL
{
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
}

-(void)drawPolygon
{
glEnable(GL_TEXTURE_GEN_T);
glEnable(GL_TEXTURE_GEN_S);
glCallList(polygons);
glDisable(GL_TEXTURE_GEN_T);
glDisable(GL_TEXTURE_GEN_S);
}
[/sourcecode]

im using a texture that contains the general look of the environment the polygons are in. everything looks fine, the reflection almost looks real if i make the object spin, or if i make the camera rotate around the object; however, if i make the camera follow the object, and make the object move around the environment, the reflection looks phony because it doesn't look as if the reflection on the polygons moves in relation to the environment. it looks as if the object were just sitting still; that is, if there wasnt anything else around the object. i was wondering if there was a way to somehow pass an offset to opengl and the automatic texture generation to reposition the texture or something. thanks.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #2
If you want to do more realistic reflections than you can do with a sphere map, you might like to look into doing a dynamic cube-map.

Basically, you render a low-res version of your scene (from the appropriate viewpoints) into each of the six faces of a cube map each frame, then use the cube map (with the appropriate texture coordinate generation) for the reflection.

I don't think you'll be able to do what you want with sphere-mapping.
Quote this message in a reply
ghettotek
Unregistered
 
Post: #3
i figured it out. all i had to do was translate the texture matrix based on the objects position. it looks perfect now.
Quote this message in a reply
Member
Posts: 164
Joined: 2002.04
Post: #4
OSC if you're rendering to texture each frame it might be faster and easier to use sphere maps instead of cube maps though. Maybe not. I wish OS 9 supported cube maps.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #5
You need a nonlinear projection to render to a sphere map, so I didn't think it was possible... I'd be delighted to be wrong, though Smile

As for OS 9 -- just forget about it. It's dead (and pretty much useless) as far as OpenGL is concerned. There's a reason so many new games don't run on 9.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  openal coordinates vs. opengl coordinates gerald 1 5,888 Feb 3, 2011 10:04 PM
Last Post: OneSadCookie
  Pre-generated cube map Fenris 2 3,460 Apr 5, 2007 07:01 PM
Last Post: nich
  Integer texture coordinates. Skorche 5 3,772 Apr 28, 2005 10:49 AM
Last Post: Puzzler183
  vertex/texture coordinates screwy reubert 1 2,549 Aug 10, 2004 08:29 AM
Last Post: phydeaux
  Controlling 3D Spaceship Phate 4 3,190 Jan 21, 2004 01:01 AM
Last Post: NCarter