Game Development Community

Painting details and/or full detail terrain

by Bobby Leighton · in Torque Game Engine Advanced · 08/22/2007 (8:40 am) · 7 replies

Ok, I have come to the 1st step into what I am going to call a solution to the way the terrain is out of the box. Right now it is just legacy that this is working on, but I will make one for a Shader for Atlas, that's easy compared to what I'm about to ask all of you out their to help me with. If you guys can help then I will gladly give you guys the shaders and the source code changes to the engine.
The way it is now I can have up to 4 detail textures on one single terrain, but I have texture slots for up to seven textures, and you can leave out the diffuse color of the original topographical textures used by the blender and if you are happy with 5 FULL High Quality Un-stretched Textures, then I've got that nailed down too!
Now on to what I need help with.....Now that I've got the shaders adjusted and taking command from me, and now that I've got a reasonable handle on HLSL, I have been going through all the terrain and blender code looking for how the blender gathers the textures it uses so the Terrain Painter can grab the textures. Looking at that code, I notice that it uses RGBA channels created through code to paint an opacity map to file, and then using that data to decide where what textures gets placed where, fortunately this is exactly the way I do my Shader. So why can't we use all this information to add in the ability to paint the details where we want them. I know little about C++ in particular, but have a good handle on C#, which I notice a lot of similarities, and HLSL, some similar code there too. I guess I can live with my Shader the way it is and paint RGBA maps to place textures, but I would rather be able to paint the details in and use all available textures slots from the shaders. Any help or information would be much appreciated on this. Oh and here's a couple of screen shots! :)
i129.photobucket.com/albums/p220/lmaceleighton/Terrain_blend2.jpgThis one got full color grass blended unstretched there are other textures but I dont have room on my online album to show them all
i129.photobucket.com/albums/p220/lmaceleighton/Terrain_blend.jpg

#1
08/22/2007 (8:53 am)
What are you exactly trying to achive?

Your description is a little bit of chaotic.
First you mix terms and in this case badly.
There is only 1 detail texture (data/terrains/detail/detail1.*), which is applied in terrainV / terrainP

Those you refer to as detail textures are actually the 4 tiling textures you can paint onto the terrain.
Those painting results in the RGBA map you already found.

If you wanted to have more than 4 tiling textures, you would need more than 1 mixing map, unless you want a texture to span across the whole terrain (which I definitely would not want due to the texel size resulting from that)

Different detail texture for each base texture thought should be easier to add
#2
08/22/2007 (10:25 am)
Very nice, Bobby. So these changes are both C++ and to the terrain blender shaders? I got something similar to this working the other day by changing the blender shaders.
#3
08/22/2007 (12:55 pm)
@Marc- Sorry Matt knew, and Is used to my mess of writing, but This is not a question, I have already achieved the effect I want through the shader, I just want to gain control of it with the terrain painter, to actually paint the detains in the world editor instead of having to do it channel by channel in photo-shop. I though maybe that where some else might be able to help. make better sense?

@No real changes to the C++ yet, I'm just kinda farting around with that, as there is a lot of code to look over, and trying to ascertain what variable does what, and what classes do what, and...on and on and on. I really just made a bunch more texture slots in the terrainV. and terrainP. shader and set control with an RGB map.....I need help making them paint with the tools in world editor, think you can help.
#4
08/22/2007 (5:06 pm)
Perhaps I can offer some help and suggestions. I'm very interested to see your changes to terrainP and terrainV. It really looks great right now. You can really see how well the detail textures blend together.
#5
08/22/2007 (5:12 pm)
Send me an email Matt and I write up an email, maybe we can come up with something everyone can use:)
as well as anyone else that think they can be of use, i will post finished code, with a tutorial on how to use it when we are done;)
#6
08/25/2007 (3:24 pm)
I would suggest that when you handle the setting of detail textures that you combine them into the channels of an image (since they're grayscale you could use R,G,B, and A to each hold a different texture.

You'd have to decide whether you'd want to force the artist to build the composite textures himself or if you'll do it in code and output it to a file or just rebuild it at runtime and store it in memory.

---------------------------------------

A resource such as this (in total, the painting ability of detail textures, accuracte base texture display [instead of up-scaled]) would be most useful.

Taking a look at what'd be involved right now.
#7
08/28/2007 (10:24 am)
Already did that, and can tell everyone how, but my computer had a faulty power supply, and by the time I figured it out it wasn't something else, it fried my mother board, and god knows what else.Im just hoping it didn't cook my video card, that was more expensive then the motherboard and CPU together. So ill be a week or two getting back up and running. But YES, I combined all of the RBGA maps into on image, and control the blending using it, for 3 detail textures. What needs to be done because I'm am still new to programming and only have been applying what Ive learned in C# to the HLSL, is we need to figure our what vurtual size our terrain is so that when you set the tiling factor to cover the terrain ONCE ONLY and is oeriented properly. Also I need to figure out how to add in the Alpha channel, right now im adding the RBG like this:


OUT.col = detailColor1 * blendTex.r + detailColor2 * blenTex.g + detailColor3 * blendTex.b + diffuseColor;

I still need to add the fog back in I took out for testing, all you do is add in texture handle for each texture you want to use just like the detail texture is in terrainV, and terrainP.hlsl. Call one a blendTex, and the others names like the detail texture is, or something else shorter so you don't want to have code lines a mile long. If I can get shaders in REF mode running on this laptop then I will try to post something more detailed but, without all the stuff on my hard drives' on the toasted computer, I am going from memory that is a bit fuzzy at the moment. But I will resource this as soon as I fix what I outlined above:)