Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (Akow), 1,361 guests, and 9 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19055 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
terrain shader clipping issue #211920
06/19/08 04:28
06/19/08 04:28
Joined: Jul 2004
Posts: 74
Inside Maya
S
Sichlid Offline OP
Junior Member
Sichlid  Offline OP
Junior Member
S

Joined: Jul 2004
Posts: 74
Inside Maya
I have implemeted the terrain multitexture shader and the code is below :

/This terrainshader is a reworked version of Thorsten Kunze 's terrainshader.



//2006 By www.loopix-project.com

/////////////////////////////////////////////////////////////////////////////////////////////////////////////







// entSkin1 rgb-blendmap

// entSkin2 shadowmap

////////////////////////

bmap tex8 = <grass.bmp>; // Texture Layer Red //steep

bmap tex9 = <cliff.bmp>; // longGrass Texture Layer Green//flat

bmap tex10 = <sand.bmp>; // Texture Layer Blue//built(roads etc..)

bmap tex11 = <snow.bmp>;// Texture Layer Black///detail color

/////////////////////////////

function multirgb_roughness1()

{

bmap_to_mipmap(mtl.Skin1);

bmap_to_mipmap(mtl.Skin2);

bmap_to_mipmap(mtl.Skin3);

bmap_to_mipmap(mtl.Skin4);

}

material terra_shader2

{



flags = tangent;

skin1 = tex8;

skin2 = tex9;

skin3 = tex10;

skin4 = tex11;



event=multirgb_roughness1;



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 sTex8 = sampler_state

{

Texture = <mtlSkin1>; // red

MipFilter = Linear;

MinFilter = Linear;

MagFilter = Linear;

AddressU = Wrap;

AddressV = Wrap;

};

sampler sTex9 = sampler_state

{

Texture = <mtlSkin2>; // green

MipFilter = Linear;

MinFilter = Linear;

MagFilter = Linear;

AddressU = Wrap;

AddressV = Wrap;

};

sampler sTex10 = sampler_state

{

Texture = <mtlSkin3>; // blue

MipFilter = Linear;

MinFilter = Linear;

MagFilter = Linear;

AddressU = Wrap;

AddressV = Wrap;

};

sampler sTex11 = 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 Tex8 : TEXCOORD2;

float2 Tex9 : TEXCOORD3;

float2 Tex10 : TEXCOORD4;

float2 Tex11 : 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.Tex8 = inTexCoord0.xy*16; // tiling texture red

Out.Tex9 = inTexCoord0.xy*16; // tiling texture green

Out.Tex10 = inTexCoord0.xy*8; // tiling texture blue

Out.Tex11 = inTexCoord0.xy*8; // 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(sTex8,In.Tex8);

float4 GreenColor = tex2D(sTex9,In.Tex9);

float4 BlueColor = tex2D(sTex10,In.Tex10);

float4 BlackColor = tex2D(sTex11,In.Tex11);









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 terrain_action

{

while(1)

{

my.material = terra_shader2;

wait(1);

}

}




The clip error that i get is shown below :


[img][IMG]http://img294.imageshack.us/img294/8379/terriancliperrvc8.th.jpg[/img][/img]







if anyone knows what is going wrong in this code , kindly let me know.

thaks in advance for any help.

Regards,
Sichlid


Last edited by Sichlid; 06/23/08 04:29.

Best Regards, Sichlid
Re: terrain shader clipping issue [Re: Sichlid] #211934
06/19/08 07:51
06/19/08 07:51
Joined: May 2005
Posts: 2,713
Lübeck
Slin Offline
Expert
Slin  Offline
Expert

Joined: May 2005
Posts: 2,713
Lübeck
The address is wrong so I can´t see the problem, but I guess itwhat is mentioned here:
http://www.conitec.net/beta/portal_x.htm

Re: terrain shader clipping issue [Re: Slin] #212090
06/20/08 10:29
06/20/08 10:29
Joined: Jul 2004
Posts: 74
Inside Maya
S
Sichlid Offline OP
Junior Member
Sichlid  Offline OP
Junior Member
S

Joined: Jul 2004
Posts: 74
Inside Maya
anyone can help me with the above code ?

Regards,
Sichlid


Best Regards, Sichlid
Re: terrain shader clipping issue [Re: Sichlid] #212093
06/20/08 10:59
06/20/08 10:59
Joined: May 2005
Posts: 2,713
Lübeck
Slin Offline
Expert
Slin  Offline
Expert

Joined: May 2005
Posts: 2,713
Lübeck
o.O why did you ignore my answer?
At least correct the link so that everyone can see your problem.

Re: terrain shader clipping issue [Re: Slin] #212257
06/21/08 05:34
06/21/08 05:34
Joined: Jul 2004
Posts: 74
Inside Maya
S
Sichlid Offline OP
Junior Member
Sichlid  Offline OP
Junior Member
S

Joined: Jul 2004
Posts: 74
Inside Maya
hello Slin , I did not ignore your answer but my question is totally different from what you have posted. Please read that page and my query and you will know the difference.

As for the image , I used to upload images to the post but i am not able to do it as there is no option in EDIT POST to upload image. there is one ENTER IMAGE option but it asks for a URL and i have the image on my desktop.

Can anyone help me please ?

Regards,
Sichlid


Best Regards, Sichlid
Re: terrain shader clipping issue [Re: Sichlid] #212410
06/22/08 10:36
06/22/08 10:36
Joined: May 2005
Posts: 2,713
Lübeck
Slin Offline
Expert
Slin  Offline
Expert

Joined: May 2005
Posts: 2,713
Lübeck
I meant this:
Quote:

Microsoft has the following comment for using clip planes in DirectX: "When the fixed function pipeline is used the plane equations are assumed to be in world space. When the programmable pipeline is used the plane equations are assumed to be in the clipping space." This euphemism expresses that clip planes won't work for shaders and particles. The engine overcomes that for all objects above and below the clip plane.


Upload the image at www.imageshack.us because it is not possible to upload files on the forum.

Re: terrain shader clipping issue [Re: Slin] #212540
06/22/08 21:20
06/22/08 21:20
Joined: Mar 2006
Posts: 2,252
Hummel Offline
Expert
Hummel  Offline
Expert

Joined: Mar 2006
Posts: 2,252
I already wrote a demo which shows how to implement a clipplane via shader, because the engine-clipplanes doesnt work with shaders.

Re: terrain shader clipping issue [Re: Hummel] #212947
06/25/08 03:50
06/25/08 03:50
Joined: Jul 2004
Posts: 74
Inside Maya
S
Sichlid Offline OP
Junior Member
Sichlid  Offline OP
Junior Member
S

Joined: Jul 2004
Posts: 74
Inside Maya
dear Hummel,

Thank you for the reply. can you send me a link to the demo of yours ?

Regards,
Sichlid


Best Regards, Sichlid

Moderated by  Blink, Hummel, Superku 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1