Multiple Textures and Colours

Started by
4 comments, last by FoxHunter2 16 years, 1 month ago
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]
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)
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?
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
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 :)
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.

This topic is closed to new replies.

Advertisement