Jump to content
  • Advertisement
Sign in to follow this  

Texture coordinate generation

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

Hi, I think that I have some troubles understanding the texture coordinate generation feature of the fixed pipeline. My understanding of "generation" means that I have no texture coordinates and I "generate" some, using some kind of information such as the current vertex position. But if I understand the "generation" used in DirectX, it seems to be more some kind of texture transformation but generation, because it seems that you already have to have the texture coordinates. Am I wrong? What I want to achieve is: I have a terrain (underwater) on which I want to project the caustic texture from above. How can I achieve this without adding additional texture coordinates to the terrain mesh? Is it possible to achieve the same effect to any mesh (projecting the texture from above)? Best regards, Metron

Share this post

Link to post
Share on other sites
Yeah. You can create texture co-ordinates in D3D quite easily. Never actually done (dynamic) projected textures, but I THINK this is how you'd go about it...

You need to set the texture co-ord index to one of the creation types, which are:


So for your case you'd use the position (as your projected texture co-ordinates will be position based) by setting the following state before rendering:


This will then assign texture co-ordinated bases on your camera position, but you don't want this (as you're unlikely to have your camera where you're projecting from), so you'll need to project the co-ordinates to your texture emitter using:

d3dDevice->SetTransform(D3DTS_TEXTURE0, &cameraToTexEmitterTrans );

The second line basically throws away the z-component of the co-ordinate as you don't need this after the projection.

Not a clue if that'll actually work, as I've never done it, and I'm sure there's probably an easier way to do it somehow, but I hope it'll provide a good starting point. I'd be interested to know the solution when you find it :)

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!