Jump to content
  • Advertisement
Sign in to follow this  
ShmeeBegek

Using the contents of a texture as the texture coordinates for another

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

I am trying to adapt my renderer, which was concieved with fragment shaders, to work on cards with only vertex shader support (ex. GeForce4 MX 440). I have figured out everything except one last matter, a technique for shading lighting that the artist on the team who came up with it calls "palette rotation". Essentially the lights are a separate pass from everything else adding the amount of light on each pixel to a single color channel, which is then used as an index into the Y axis of a 2D palette texture (with the X axis index being the color of whatever was on that pixel). I am somewhat stumped as to how to implement this without fragment shaders because I can see no way to use the contents of one texture as the texture coordinates for another (with ARB_multitexture). Any ideas on this? (EXT_paletted_texture doesn't seem to do it either) Thanks, ~SPH

Share this post


Link to post
Share on other sites
Advertisement
You can use glGetTexImage() to get the texture data, and use whatever you need from that (RGBA values perhaps) to get the texture coordinates you need (for example: glMultiTexCoord2fARB(GL_TEXTURE0_ARB,iData[x] / 255.0f,iData[y] / 255.0f)).

Share this post


Link to post
Share on other sites

It is of course possible to send the data back across the bus and turn it into geometry and explicitly generate the texture coordinates, but that's painfully slow at best. In a fragment shader one can use just about any value (including the results of a texture access) as a texture coordinate, and I'm looking for some way to actually tell the hardware to do that (if it exists).

Thanks, ~SPH

Share this post


Link to post
Share on other sites
You may be able to use the GL_ARB_pixel_buffer_object extension to "render to a vertex array." You would really be rendering the texture data into a VBO and using it as texture coordinate data, but "Render to Vertex Array" is the common term for it. There's an example of using such rendered data as vertex data in the spec; texture coordinate data should be very similar.

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!