Jump to content
  • Advertisement
Sign in to follow this  
LordFallout

Multiple Textures and Colours

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

Hello everyone im working on a terrain editor at the moment, and i've stumbled accross a problem, which has a simple solution, all thought i think there could be a better way Basically, i want the user to be able to 'pick' vertices for selection, when there picked i want them to change colour, this is easy to do, just add the colour variable to your definitions and alter acordingly. This works in practise, however i want the user to be able to texture each chunk with up too 4 textures so my data structure so far consists of XYZ, Normals, and 4 sets of Texture Co-ords (i would just use one but for the editor itself i want the user to be able to change the scale on each texture individually). I could just add the colour component but my structure is getting quite large, is there a more elegant way to do this? [Edited by - LordFallout on March 16, 2008 12:00:46 PM]

Share this post


Link to post
Share on other sites
Advertisement
You can use a technique called "Texture Splatting".

Take a look at following links:
http://forums.xna.com/thread/48128.aspx (Doing it in the shader)
http://www.gamedev.net/reference/articles/article2238.asp (Using the FFP)

Share this post


Link to post
Share on other sites
Yeah, i all ready texture splat the four textures, the only problem is that if i want to edit the colour of a specific vertices, to indicate which one had been selected i would need the structures too hold a colour value, or is there another way to do this?

Share this post


Link to post
Share on other sites
If you want to colorize your vertices in a terrain editor, then I don't think there's a away around some sort of color definition in the vertex declaration.
Maybe you could store the selected vertices in a different VB.
Something like:

VB1: terrain chunk, no color information
VB2: only selected vertices, with either a color element in the declaration or directly rendered by the shader

But then you have some overdraw if the number of selected vertices almost equals the number of total vertices on your terrain. On the other hand the shader for the vertices in VB2 wouldn't do very much, so modern GPUs could handle it quite easily

Share this post


Link to post
Share on other sites
Yeah, i thought this would be the only alternative, i was thinking about highlighting only one vertices, the main vert that was clicked, this would mean i only had to store minimal data. I guess i'll go this route :)

Share this post


Link to post
Share on other sites
Another idea I got was to just create a second index buffer with the indices to the vertices that are selected. You could then draw the vertices with this index buffer and a shader that colors them red.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!