Terrain Super Shader
by Matt Vitelli · in Torque Game Engine Advanced · 05/11/2007 (9:47 am) · 32 replies
After a few late nights of programming I came up with this terrain shader. It does accurate water rendering using Jacob Dankovchik's code. It also renders a parallax mapped shoreline which unfortunately sticks out because of no blending. Detail textures also change based on elevation. This is a work in progress, but I think it's coming along nicely.




Once again, this is a work in progress. As soon as I sort out some issues I'm having with blending and fading detail textures, I may post the code.
Any feedback is greatly appreciated!
-Matt Vitelli




Once again, this is a work in progress. As soon as I sort out some issues I'm having with blending and fading detail textures, I may post the code.
Any feedback is greatly appreciated!
-Matt Vitelli
#2
/me keeps fingers crossed for progress on this!
Thanks...
05/11/2007 (10:11 am)
Looking awesome Matt! When you feel it is ready, please *please* post some code! I'm looking for detail on the side of my mountains (on very steep sides) and because my L3DT texture map is essentially pushed from the top down I'm getting very stretched low-res textures on steep terrain. You've got much more detail there!/me keeps fingers crossed for progress on this!
Thanks...
#3
05/11/2007 (10:25 am)
By the way, this is using Legacy Terrain. It probably wouldn't be very hard to set up in Atlas, I just have very limited knowledge of how Atlas's clipmaps work.
#4
05/11/2007 (10:46 am)
Looks great for a WIP :)
#5
05/11/2007 (3:16 pm)
I would be very interested in getting this working for Atlas.
#6
05/12/2007 (1:14 am)
Let me know if you need any help, Ive got some spare time if you need any nice height maps...well anything really that i can contribute just ask:) this is something we all could use i bet.
#7
05/12/2007 (4:38 am)
You got email, Matt.
#8
As I say, if you need any artwork, just let me know.
06/02/2007 (3:19 am)
If you need any artwork help for this too Matt, just let me know. I'm not a coder but would be very interested in seeing if this would help out our blending around shorelines in our game. It already looks like you could get some stunning effects with this code. It looks great!As I say, if you need any artwork, just let me know.
#9
06/02/2007 (7:57 am)
Yeah me too this looks promising. If there is anything you need textures, maps, you name it's yours.
#10
06/02/2007 (8:38 am)
Matt, I have to second the kudos everyone has given here. This looks really nice, and it's impressive that you've done it legacy terrain - it just proves what's always said about the engine; dig in and amazing things can be done.
#11
I would think that the ultimate solution would be an atlas2 blended where you only really needed your attribute masks that would control what area is shader 1 what what area is rendered with shader 2 and so on I think it is possible to at least 4 but I think I have read that it is possible to do more with modification. I think L3DT supports up to 16 via 4 bitmaps with 4 channels each.. I think that something like this is what the new engines have like crytek 2.
Ideally have parameters for what shaders 1-4 point to "as in a .hlsl file" in the editor. as well as the tileing rates
this would be awesome and be soo much better than fighting with detail textures in atlas2
Just my 2 cents but I think persuing it on legacy first may be more of an up hill battle than starting with the most logical choice and getting it working there at least first..
Great work so far though.
06/02/2007 (9:50 am)
Forgive me as I'm very un educated in this area. "artist not programmer" but would not atlas 2 Blended terrain be the best target for this resource?I would think that the ultimate solution would be an atlas2 blended where you only really needed your attribute masks that would control what area is shader 1 what what area is rendered with shader 2 and so on I think it is possible to at least 4 but I think I have read that it is possible to do more with modification. I think L3DT supports up to 16 via 4 bitmaps with 4 channels each.. I think that something like this is what the new engines have like crytek 2.
Ideally have parameters for what shaders 1-4 point to "as in a .hlsl file" in the editor. as well as the tileing rates
this would be awesome and be soo much better than fighting with detail textures in atlas2
Just my 2 cents but I think persuing it on legacy first may be more of an up hill battle than starting with the most logical choice and getting it working there at least first..
Great work so far though.
#12
James, this is actually much easier than modifying Atlas2. All of this work is being done through 1 shader and requires almost no source code modifications. The main reason I'm working with Legacy is that it's ingame editable. Don't get me wrong, Atlas2 has many rewarding features such as blended terrains and being multithreaded and paged. However, at this time it's much easier for me to do this through one shader than a series of shaders.
06/02/2007 (10:20 am)
Thank you all for your kudos. James, this is actually much easier than modifying Atlas2. All of this work is being done through 1 shader and requires almost no source code modifications. The main reason I'm working with Legacy is that it's ingame editable. Don't get me wrong, Atlas2 has many rewarding features such as blended terrains and being multithreaded and paged. However, at this time it's much easier for me to do this through one shader than a series of shaders.
#14
07/18/2007 (3:06 pm)
Yes Matt Please???:)
#16
I would really like to have more then one detail map on the legacy terrain.
Having them assigned by height would definitely be better then just the one.
07/18/2007 (3:36 pm)
Im really curious about the detail map part you talk about.I would really like to have more then one detail map on the legacy terrain.
Having them assigned by height would definitely be better then just the one.
#17
07/18/2007 (3:37 pm)
.....
#18
Where hpos2 is a 4-vector texture coordinate equal to the position in the vertex shader.
Pixel Shader Pseudo-Code:
Vertex Shader Pseudo-Code:
07/18/2007 (4:08 pm)
I've been working on lighting and shading algorithms lately. Looking back this shader is extremely messy. I could offer some pseudo-code if anyone is really interested.if(IN.hpos2.z > pos.z + 100 && IN.hpos2.z < pos.z + 300) //if the vertex position is greater than 100, apply //the texture. If it's less than 300, don't apply it.
{
float4 detailMap = tex2D(detailMap, IN.detCoord);
dirtCol = detailMap;
}Where hpos2 is a 4-vector texture coordinate equal to the position in the vertex shader.
Pixel Shader Pseudo-Code:
struct ConnectData
{
float2 texCoord : TEXCOORD0;
float2 fogCoord : TEXCOORD1;
float2 lightMapCoord : TEXCOORD2;
float2 detCoord : TEXCOORD3;
float4 hpos2 : TEXCOORD4; //A four-dimensional vector for the vertex's position.
};Vertex Shader Pseudo-Code:
OUT.hpos2 = IN.position; //Assign the vertex position to a texture coordinate.
#19
07/19/2007 (11:50 am)
Once I can figure out how this works I'm going to try to make it only produce the other detail texture only when another certain texture is their, i was hoping if done right it will make them blend like the Tex it attached to. Any ideas....just when i think Ive got this my terrain is a grey(better than black):)
#20
07/19/2007 (12:45 pm)
Well, basically pos is just a reference point. I used Jacob Dankovckik's underwater shading parameter "pos" as a "sea level" reference point, but in theory pos could just be 0,0,0.
Torque 3D Owner Steven Chiu