Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
3 registered members (AndrewAMD, TipmyPip, OptimusPrime), 15,229 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
reflecting lights on terrain by shader #318538
04/08/10 10:34
04/08/10 10:34
Joined: Feb 2010
Posts: 40
Germany
G
Grandma Offline OP
Newbie
Grandma  Offline OP
Newbie
G

Joined: Feb 2010
Posts: 40
Germany
Maybe someone can help me to fix this problem:
I tried to install “reflection-behaviour” in the following terrain-shader-script. There are no errors occurred but just the reflection on the water surface shows the influence of the sunlight - but not the terraintexture…
The included lines are 115 and 143.
Thx for your help!

Code:
// multirgb.c


// entSkin1   Texture Base
// entSkin2   Texture Layer Red

BMAP* tex1 = "rock.bmp"; 		// RGB Mask
BMAP* tex4 = "gras.bmp"; 		// Texture Layer Green
BMAP* tex5 = "trockengras.pcx"; 		// Texture Layer Blue
BMAP* tex6 = "detailmap_g.tga"; 	// DetailMap



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 = tex1;
	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;		
		
		float fAmbient;			
		
		//////////////////////////////////////////////////////////////////////////////////////////////////////
		// Texture settings
		sampler sTex1 = sampler_state			
		{
			Texture = <entSkin2>;   // RGB Mask
			MipFilter = Linear;
			MinFilter = Linear;
			MagFilter = Linear;
			AddressU = Wrap;	
			AddressV = Wrap;
		};
		sampler sTex2 = sampler_state			
		{
			Texture = <entSkin1>;   // Texture Base
			MipFilter = Linear;
			MinFilter = Linear;
			MagFilter = Linear;
			AddressU = Wrap;	
			AddressV = Wrap;
		};
		sampler sTex3 = sampler_state			
		{
			Texture = <mtlSkin1>;	// Texture Layer Red
			MipFilter = Linear;
			MinFilter = Linear;
			MagFilter = Linear;
			AddressU = Wrap;	
			AddressV = Wrap;
		};
		sampler sTex4 = sampler_state			
		{
			Texture = <mtlSkin2>;	// Texture Layer Green
			MipFilter = Linear;
			MinFilter = Linear;
			MagFilter = Linear;
			AddressU = Wrap;	
			AddressV = Wrap;
		};
		sampler sTex5 = sampler_state			
		{
			Texture = <mtlSkin3>;	// Texture Layer Blue
			MipFilter = Linear;
			MinFilter = Linear;
			MagFilter = Linear;
			AddressU = Wrap;	
			AddressV = Wrap;
		};
		sampler sTex6 = sampler_state			
		{
			Texture = <mtlSkin4>;	// Detailmap for Base Texture
			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;
			float4 Color	: COLOR0;
			float2 Tex1 	: TEXCOORD0;
			float2 Tex2 	: TEXCOORD1;
			float2 Tex3 	: TEXCOORD2;
			float2 Tex4		: TEXCOORD3;
			float2 Tex5		: TEXCOORD5;
			float2 Tex6		: TEXCOORD6;
		};


		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));
		//	float3 N = DoNormal(inNormal);
			float3 P = mul(inPos,matWorld);

			Out.Color = fAmbient; // Add ambient and sun light
		//	for (int i=0; i<8; i++)  // Add 8 dynamic lights
		//	Out.Color += DoLight(P,N,i);
			Out.Fog = DoFog(inPos);
			
			// scale the texture coordinates for the masked textures
			Out.Tex1  = inTexCoord0.xy;		// Tile Mask
			Out.Tex2  = inTexCoord0.xy;		// Tile Base Texture
			Out.Tex3  = inTexCoord0.xy*20;	// Tile Texture Layer Red
			Out.Tex4  = inTexCoord0.xy*20;	// Tile Texture Layer Green
			Out.Tex5  = inTexCoord0.xy*20;	// Tile Texture Layer Blue
			Out.Tex6  = inTexCoord0.xy*20;	// Tile Texture Layer Detailmap
			return Out;
		}
		
		
		//////////////////////////////////////////////////////////////////////////////////////////////////////
		// pixelshader
		float4 ps( TMULTI_VS_OUT In ) : COLOR
		{
			float4 MaskColor = tex2D(sTex1,In.Tex1);
			float4 BaseColor = tex2D(sTex2,In.Tex2);
			float4 RedColor = tex2D(sTex3,In.Tex3);
			float4 GreenColor = tex2D(sTex4,In.Tex4);
			float4 BlueColor = tex2D(sTex5,In.Tex5);
			float4 DetailColor = tex2D(sTex6,In.Tex5);
			
			BaseColor = BaseColor + DetailColor - 0.5;
			
			float4 BaseRed = lerp(BaseColor,RedColor,MaskColor.r);
			float4 BaseGreen = lerp(BaseRed,GreenColor,MaskColor.g);
			float4 FinalColor = lerp(BaseGreen,BlueColor,MaskColor.b);
			
			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: reflecting lights on terrain by shader [Re: Grandma] #318548
04/08/10 12:01
04/08/10 12:01
Joined: Mar 2006
Posts: 2,252
Hummel Offline
Expert
Hummel  Offline
Expert

Joined: Mar 2006
Posts: 2,252
there is no reflection stuff in this shader neither diffuse lighting...


Moderated by  Blink, Hummel, Superku 

Gamestudio download | 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