1 registered members (AndrewAMD),
636
guests, and 4
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Terrainmaking
#98016
11/08/06 22:22
11/08/06 22:22
|
Joined: Mar 2005
Posts: 969 ch
Loopix
OP
User
|
OP
User
Joined: Mar 2005
Posts: 969
ch
|
Hello Nagashi pointed to a nice little terrain tool in the "Tools" forum called Earthsculptor. This tool creates highmaps, shadowmaps and rgb-blendmaps. It's quite easy to port the terrains to 3dgs and get them working with a multi-texture-terain shader. I 've tweaked one of my old and wanted to share it in Earthsculptor in 3dgs the shader: Code:
///////////////////////////////////////////////////////////////////////////////////////////////////////////// //This is a multitexture-terrainshader that makes it easy to implement terrains made //with "EarthSculptor, http://www.earthsculptor.com/" into 3dgs. It's able to blend 4 textures and //on top of that a shadowmap. // //When painting with textures in "earthscuptor" the rgb-blendmap is created as follows: //(from left to right) texture in slot1 creates red in the rgb-blendmap, slot2 = green, slot3 = blue, slot4 = black. //After you saved your terrain, you will find the highmap, the blendmap and the shadowmap in the "Maps" folder in the directory where "earthsculptor" is installed. // //After converting all needed maps and texture files into a MED compatible format (bmp,pcx,tga), import the highmap into MED //(File/Import/Import Terrain from Pic)and create a highmap with size according to your needs (I usualy make it around 100x100 vertices), //then you will have to rescale the terrain in height to fit it as close as possible to the original in "earthsculptor". //Then assign the rgb-blendmap as first and the shadowmap as second skin to your terrain (Edit/Manage Skins). // //Add the terrain to your level (Objec/Add Terrain) //Include the shader.wdl into your main wdl script and assign the action "multi_rgb" to your terrain. You //might want to adjust the tiling size of the textures by changing the values in the shader...see: //"Out.Tex3 = inTexCoord0.xy*30; // tiling texture red...". // // //This terrainshader is a reworked version of Thorsten Kunze 's terrainshader. //2006 By www.loopix-project.com /////////////////////////////////////////////////////////////////////////////////////////////////////////////
// entSkin1 rgb-blendmap // entSkin2 shadowmap
bmap tex3 = <rocks.bmp>; // Texture Layer Red bmap tex4 = <grass.bmp>; // Texture Layer Green bmap tex5 = <bark.bmp>; // Texture Layer Blue bmap tex6 = <cliff.bmp>; // Texture Layer Black
function multirgb_roughness() { bmap_to_mipmap(mtl.Skin1); bmap_to_mipmap(mtl.Skin2); bmap_to_mipmap(mtl.Skin3); bmap_to_mipmap(mtl.Skin4); }
material multirgb { flags = tangent; skin1 = tex3; skin2 = tex4; skin3 = tex5; skin4 = tex6; event=multirgb_roughness; effect " ////////////////////////////////////////////////////////////////////////////////////////////////////// // Define your needed values float4x4 matWorldViewProj; float4x4 matWorld; float4x4 matWorldInv; float4x4 matWorldView; float4 vecFog; // Define your textures texture mtlSkin1; texture mtlSkin2; texture mtlSkin3; texture mtlSkin4; texture entSkin1; texture entSkin2; ////////////////////////////////////////////////////////////////////////////////////////////////////// // Texture settings sampler sTex1 = sampler_state { Texture = <entSkin1>; // rgb-blendmap MipFilter = Linear; MinFilter = Linear; MagFilter = Linear; AddressU = Wrap; AddressV = Wrap; }; sampler sTex2 = sampler_state { Texture = <entSkin2>; // shadowmap MipFilter = Linear; MinFilter = Linear; MagFilter = Linear; AddressU = Wrap; AddressV = Wrap; }; sampler sTex3 = sampler_state { Texture = <mtlSkin1>; // red MipFilter = Linear; MinFilter = Linear; MagFilter = Linear; AddressU = Wrap; AddressV = Wrap; }; sampler sTex4 = sampler_state { Texture = <mtlSkin2>; // green MipFilter = Linear; MinFilter = Linear; MagFilter = Linear; AddressU = Wrap; AddressV = Wrap; }; sampler sTex5 = sampler_state { Texture = <mtlSkin3>; // blue MipFilter = Linear; MinFilter = Linear; MagFilter = Linear; AddressU = Wrap; AddressV = Wrap; }; sampler sTex6 = sampler_state { Texture = <mtlSkin4>; // black MipFilter = Linear; MinFilter = Linear; MagFilter = Linear; AddressU = Wrap; AddressV = Wrap; }; struct TMULTI_VS_OUT // Output to the pixelshader fragment { float4 Pos : POSITION; float Fog : FOG; float2 Tex1 : TEXCOORD0; float2 Tex2 : TEXCOORD1; float2 Tex3 : TEXCOORD2; float2 Tex4 : TEXCOORD3; float2 Tex5 : TEXCOORD4; float2 Tex6 : TEXCOORD5; }; float DoFog(float4 Pos) { float3 P = mul(Pos,matWorldView);// apply the linear fog formula return saturate((vecFog.y-P.z) * vecFog.z); } TMULTI_VS_OUT TMulti_VS( float4 inPos : POSITION, float3 inNormal : NORMAL, float2 inTexCoord0 : TEXCOORD0) { TMULTI_VS_OUT Out; // transform the vector position to screen coordinates Out.Pos = mul(inPos,matWorldViewProj); // rotate and normalize the normal float3 N = normalize(mul(inNormal,matWorldInv)); Out.Fog = DoFog(inPos); // scale the texture coordinates for the masked textures Out.Tex1 = inTexCoord0.xy; // rgb-blendmap (not tiled) Out.Tex2 = inTexCoord0.xy; // shadowmap (not tiled) Out.Tex3 = inTexCoord0.xy*30; // tiling texture red Out.Tex4 = inTexCoord0.xy*10; // tiling texture green Out.Tex5 = inTexCoord0.xy*10; // tiling texture blue Out.Tex6 = inTexCoord0.xy*30; // tiling texture black return Out; } ////////////////////////////////////////////////////////////////////////////////////////////////////// // pixelshader float4 ps( TMULTI_VS_OUT In ) : COLOR { float4 BlendColor = tex2D(sTex1,In.Tex1); float4 ShadowMap = tex2D(sTex2,In.Tex2); float4 RedColor = tex2D(sTex3,In.Tex3); float4 GreenColor = tex2D(sTex4,In.Tex4); float4 BlueColor = tex2D(sTex5,In.Tex5); float4 BlackColor = tex2D(sTex6,In.Tex6); float4 BaseRed = lerp(BlackColor,RedColor,BlendColor.r); float4 BaseGreen = lerp(BaseRed,GreenColor,BlendColor.g); float4 FinalColor = lerp(BaseGreen,BlueColor,BlendColor.b); FinalColor = FinalColor*ShadowMap; // maybe you will want to have it brighter ...*(ShadowMap+0.2) FinalColor.a = 1.0f; // prevent transparency return FinalColor; } ////////////////////////////////////////////////////////////////////////////////////////////////////// // technique mytechnique { // Define your passes pass p0 { VertexShader = compile vs_2_0 TMulti_VS(); PixelShader = compile ps_2_0 ps(); } } "; }
ACTION multi_rgb { my.material=multirgb;
}
|
|
|
Re: Terrainmaking
[Re: Iglarion]
#98021
11/09/06 11:04
11/09/06 11:04
|
Joined: Sep 2002
Posts: 8,177 Netherlands
PHeMoX
Senior Expert
|
Senior Expert
Joined: Sep 2002
Posts: 8,177
Netherlands
|
Very cool Loopix, thanks!
Edit: A little question btw, which map is the actual blendmap? Is it a greyscale image?
Cheers
Last edited by PHeMoX; 11/09/06 11:31.
|
|
|
Re: Terrainmaking
[Re: Loopix]
#98022
11/09/06 11:52
11/09/06 11:52
|
Joined: Mar 2006
Posts: 2,758 Antwerp,Belgium
frazzle
Expert
|
Expert
Joined: Mar 2006
Posts: 2,758
Antwerp,Belgium
|
This is a quite helpfull tool you contributed Loopix I'll try it out tonight One request I have, could you make a complided version in WED with a terrain (heightmap and textures included) in it and the shader attached to it, that way I think the users will get the right information about it and also to be sure that the user doesn't apply it the wrong way to avoid the frustrasion ^^ Cheers Frazzle
|
|
|
Re: Terrainmaking
[Re: Tempelbauer]
#98024
11/09/06 12:23
11/09/06 12:23
|
Joined: Oct 2004
Posts: 1,856
TheExpert
Senior Developer
|
Senior Developer
Joined: Oct 2004
Posts: 1,856
|
Thanks a lot that's a really great and real "contribution" for community. i have asked for terrain editor for 3DS , some user is doing an outstanding tool that will allow that ... nothing released or done finally users will have at least your contribution for the moment. Thanks again Loopix
|
|
|
Re: Terrainmaking
[Re: TheExpert]
#98025
11/09/06 16:28
11/09/06 16:28
|
Joined: Nov 2003
Posts: 170
Tachys
Member
|
Member
Joined: Nov 2003
Posts: 170
|
TheExpert:
With all due respect, the strength of this system has never been in the tools that come with it. You know this, we know this... cease kicking the bones of this long dead horse.
It has been, and will probably remain, 2 things:
First, the system's flexibility. Almost no matter what level of the app you buy, there is a way to get some or all of the extras included in the higher levels. Few and far between are the development suites where you can get so much for so little. If there is something you want out of the system, no one is stopping you from coding it and adding it in.
Second, are the plethora of users like Loopix, who are more than willing to share their work with the community, if not for free, then for a nominal fee. With them on board, almost anything is within your reach.
Note the similarity in the ending statements above: YOU have to extend YOUR reach. I have seen nothing on these boards from you in recent times that shows that you are doing that, or helping others extend theirs.
Back on topic, Loopix, great work, and the contribution is awesome! I was loking into doing something like this for another project, so it was also very timely as well.
Thanks again!
|
|
|
|