///////////////////////////////////////////////////////////////////////////////////////////////////
////MystyMood terrain materias. Just to keep the terrain_template more tidy!
////
////Jun 07 by www.loopix-project.com
////Nov 07 Lite-C conversion by Alexis Rozhkov aka Shadow
///////////////////////////////////////////////////////////////////////////////////////////////////
////bitmaps for terrain 1
BMAP* terr_blendtex_red_1 = "terr_red_1.bmp";
BMAP* terr_blendtex_green_1 = "terr_green_1.bmp";
BMAP* terr_blendtex_blue_1 = "terr_blue_1.bmp";
BMAP* terr_blendtex_black_1 = "terr_black_1.bmp";
BMAP* terr_colormap_1 = "terr_colormap_1.bmp";
BMAP* terr_detailmap_1 = "terr_detailmap_1.bmp";
BMAP* terr_shadowmap_1 = "terr_shadowmap_1.tga";
////bitmaps for terrain 2
//bmap terr_blendtex_red_2 = "terr_red_2.bmp";
//bmap terr_blendtex_green_2 = "terr_green_2.bmp";
//bmap terr_blendtex_blue_2 = "terr_blue_2.bmp";
//bmap terr_blendtex_black_2 = "terr_black_2.bmp";
//bmap terr_colormap_2 = "terr_colormap_2.bmp";
//bmap terr_detailmap_2 = "terr_detailmap_2.bmp";
//bmap terr_shadowmap_2 = "terr_shadowmap_2.tga";
////bitmaps for terrain 3
//bmap terr_blendtex_red_3 = "terr_red_3.bmp";
//bmap terr_blendtex_green_3 = "terr_green_3.bmp";
//bmap terr_blendtex_blue_3 = "terr_blue_3.bmp";
//bmap terr_blendtex_black_3 = "terr_black_3.bmp";
//bmap terr_colormap_3 = "terr_colormap_3.bmp";
//bmap terr_detailmap_3 = "terr_detailmap_3.bmp";
//bmap terr_shadowmap_3 = "terr_shadowmap_3.tga";
////bitmaps for terrain 4
//bmap terr_blendtex_red_4 = "terr_red_4.bmp";
//bmap terr_blendtex_green_4 = "terr_green_4.bmp";
//bmap terr_blendtex_blue_4 = "terr_blue_4.bmp";
//bmap terr_blendtex_black_4 = "terr_black_4.bmp";
//bmap terr_colormap_4 = "terr_colormap_4.bmp";
//bmap terr_detailmap_4 = "terr_detailmap_4.bmp";
//bmap terr_shadowmap_4 = "terr_shadowmap_4.tga";
//add more bitmap-sets for more terrains...
//prototype functions
function mat_terr_hlsl_refl_event();
//function mat_terr_hlsl_no_caust_refl_event();
function init_mat_terr_hlsl();
function init_mat_terr_ffe();
//HLSL MATERIALS FOR TERRAINS
MATERIAL* mat_terr_hlsl_1 =
{
flags = tangent;
skin1 = terr_blendtex_red_1;
skin2 = terr_blendtex_green_1;
skin3 = terr_blendtex_blue_1;
skin4 = terr_blendtex_black_1;
event=init_mat_terr_hlsl;
effect
"
/////////////////////////////////////////////////////////////////////////////////////////////
// Define your needed values
float4x4 matWorldViewProj;
float4x4 matWorld;
float4x4 matWorldInv;
float4x4 matWorldView;
float4 mtlSkill1;
float4 mtlSkill2;
float4 vecSkill41;
float4 vecSunDir;
float4 vecFog;
float4 vecLight;
float4 vecLightPos[8]; // preset this with light positions (xyz) and ranges (w)
float4 vecLightColor[8]; // preset this with light colors
float3 vecFalloff = float3(0.f, 0.f, 1.5f);
float4 vecSunDiffuse = {1.0f, 1.0f, 0.8f, 1.0f};
float sunStrength = 0.3f;
float dynalightStrength = 10;
// Define your textures
texture mtlSkin1;
texture mtlSkin2;
texture mtlSkin3;
texture mtlSkin4;
texture entSkin1;
texture entSkin2;
texture entSkin3;
texture entSkin4;
/////////////////////////////////////////////////////////////////////////////////////////////
// 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 = <entSkin3>; // causticsA
MipFilter = Linear;
MinFilter = Linear;
MagFilter = Linear;
AddressU = Wrap;
AddressV = Wrap;
};
sampler sTex4= sampler_state
{
Texture = <entSkin4>; // causticsB
MipFilter = Linear;
MinFilter = Linear;
MagFilter = Linear;
AddressU = Wrap;
AddressV = Wrap;
};
sampler sTex5 = sampler_state
{
Texture = <mtlSkin1>; // red
MipFilter = Linear;
MinFilter = Linear;
MagFilter = Linear;
AddressU = Wrap;
AddressV = Wrap;
};
sampler sTex6 = sampler_state
{
Texture = <mtlSkin2>; // green
MipFilter = Linear;
MinFilter = Linear;
MagFilter = Linear;
AddressU = Wrap;
AddressV = Wrap;
};
sampler sTex7 = sampler_state
{
Texture = <mtlSkin3>; // blue
MipFilter = Linear;
MinFilter = Linear;
MagFilter = Linear;
AddressU = Wrap;
AddressV = Wrap;
};
sampler sTex8 = sampler_state
{
Texture = <mtlSkin4>; // black
MipFilter = Linear;
MinFilter = Linear;
MagFilter = Linear;
AddressU = Wrap;
AddressV = Wrap;
};
//////////////////////////////////////////////////////////////////////
// return the sun light on the surface
float4 DoSunLight(float3 N)
{
// modulate the sunlight by the surface angle
return vecSunDiffuse * dot(N,-vecSunDir);
}
// return the dynamic light on the surface
float4 DoPointLight(float3 P, float3 N, int i)
{
// calculate the light ray pointing from the light to the surface
float3 D = vecLightPos[i].xyz - P;
// calculate the angle between surface and light ray
float NdotL = dot(N, normalize(D));
// modulate the light by the surface angle
float4 Color = vecLightColor[i] * NdotL;
// calculate the light attenuation factor, DX uses a really strange formula here
float fac = 0.f;
if (NdotL >= 0.f && vecLightPos[i].w > 0.f)
{
// get the distance factor
float LD = length(D)/vecLightPos[i].w;
#ifdef DXLIGHTING
if (LD < 1.3f)
fac = 1.f/(vecFalloff.x + vecFalloff.y*LD + vecFalloff.z*LD*LD);
#else // linear Lighting
if (LD < 1.f)
fac = 1.f - LD;
#endif
}
return Color * fac;
}
float DoFog(float4 Pos)
{
// convert the vector position to view space to get it's depth (.z)
float3 P = mul(Pos,matWorldView);
// apply the linear fog formula
return saturate((vecFog.y-P.z) * vecFog.z);
}
struct TMULTI_VS_OUT // Output to the pixelshader fragment
{
float4 Pos : POSITION;
float Fog : FOG;
float4 tColor : COLOR0;
float2 Tex1 : TEXCOORD0;
float2 Tex2 : TEXCOORD1;
float2 Tex3 : TEXCOORD2;
float2 Tex4 : TEXCOORD3;
float2 Tex5 : TEXCOORD4;
float2 Tex6 : TEXCOORD5;
float2 Tex7 : TEXCOORD6;
float2 Tex8 : TEXCOORD7;
};
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);
float3 N = normalize(mul(inNormal, matWorldInv));
float3 P = mul(inPos, matWorld);
// Add ambient and sun light
Out.tColor = ((DoSunLight(N) - 0.2f)*sunStrength)+0.6;
// Add 8 dynamic lights (maximum for vs 1.1)
for (int i=0; i<6; i++)
Out.tColor += DoPointLight(P,N,i)*dynalightStrength;
// Add fog
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*vecSkill41.w+vecSkill41.w/50)+0.1* vecSkill41.xy;//sin(vecSkill41);//moving the caustics texture
Out.Tex4 = (inTexCoord0.xy*vecSkill41.w)-0.1* vecSkill41.y;//moving the caustics texture
Out.Tex5 = inTexCoord0.xy*40; // tiling texture red
Out.Tex6 = inTexCoord0.xy*60; // tiling texture green
Out.Tex7 = inTexCoord0.xy*20; // tiling texture blue
Out.Tex8 = inTexCoord0.xy*40; // 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)*1.5);
float4 causticsA = tex2D(sTex3,In.Tex3);
float4 causticsB = tex2D(sTex4,In.Tex4);
float4 RedColor = tex2D(sTex5,In.Tex5);
float4 GreenColor = tex2D(sTex6,In.Tex6);
float4 BlueColor = tex2D(sTex7,In.Tex7);
float4 BlackColor = tex2D(sTex8,In.Tex8);
float4 BaseRed = lerp(BlackColor,RedColor,BlendColor.r);
float4 BaseGreen = lerp(BaseRed,GreenColor,BlendColor.g);
float4 FinalColor = lerp(BaseGreen,BlueColor,BlendColor.b);
float4 BaseCaustics = lerp(FinalColor,(FinalColor*(causticsA+causticsB)),(ShadowMap.a*mtlSkill2));
//////////////////////////////////////////////////////////////////////////////////////////////
FinalColor = In.tColor*(BaseCaustics*(ShadowMap));
FinalColor = (FinalColor*mtlSkill1)*(ShadowMap);
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();
}
}
technique fallback{pass p0{}}
";
}
//MATERIAL* mat_terr_hlsl_2 =
//{
//
// flags = tangent;
//
// skin1 = terr_blendtex_red_2;
// skin2 = terr_blendtex_green_2;
// skin3 = terr_blendtex_blue_2;
// skin4 = terr_blendtex_black_2;
//
// event=init_mat_terr_hlsl;
//
// effect
// "
// /////////////////////////////////////////////////////////////////////////////////////////////
// // Define your needed values
// float4x4 matWorldViewProj;
// float4x4 matWorld;
// float4x4 matWorldInv;
// float4x4 matWorldView;
//
// float4 mtlSkill1;
// float4 mtlSkill2;
//
// float4 vecSkill41;
//
//
// float4 vecSunDir;
// float4 vecFog;
// float4 vecLight;
//
// float4 vecLightPos[8]; // preset this with light positions (xyz) and ranges (w)
// float4 vecLightColor[8]; // preset this with light colors
// float3 vecFalloff = float3(0.f, 0.f, 1.5f);
// float4 vecSunDiffuse = {1.0f, 1.0f, 0.8f, 1.0f};
//
// float sunStrength = 0.3f;
// float dynalightStrength = 10;
//
// // Define your textures
// texture mtlSkin1;
// texture mtlSkin2;
// texture mtlSkin3;
// texture mtlSkin4;
//
// texture entSkin1;
// texture entSkin2;
// texture entSkin3;
// texture entSkin4;
//
// /////////////////////////////////////////////////////////////////////////////////////////////
// // 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 = <entSkin3>; // causticsA
// MipFilter = Linear;
// MinFilter = Linear;
// MagFilter = Linear;
// AddressU = Wrap;
// AddressV = Wrap;
// };
// sampler sTex4= sampler_state
// {
// Texture = <entSkin4>; // causticsB
// MipFilter = Linear;
// MinFilter = Linear;
// MagFilter = Linear;
// AddressU = Wrap;
// AddressV = Wrap;
// };
//
//
// sampler sTex5 = sampler_state
// {
// Texture = <mtlSkin1>; // red
// MipFilter = Linear;
// MinFilter = Linear;
// MagFilter = Linear;
// AddressU = Wrap;
// AddressV = Wrap;
// };
// sampler sTex6 = sampler_state
// {
// Texture = <mtlSkin2>; // green
// MipFilter = Linear;
// MinFilter = Linear;
// MagFilter = Linear;
// AddressU = Wrap;
// AddressV = Wrap;
// };
// sampler sTex7 = sampler_state
// {
// Texture = <mtlSkin3>; // blue
// MipFilter = Linear;
// MinFilter = Linear;
// MagFilter = Linear;
// AddressU = Wrap;
// AddressV = Wrap;
// };
// sampler sTex8 = sampler_state
// {
// Texture = <mtlSkin4>; // black
// MipFilter = Linear;
// MinFilter = Linear;
// MagFilter = Linear;
// AddressU = Wrap;
// AddressV = Wrap;
// };
//
// //////////////////////////////////////////////////////////////////////
// // return the sun light on the surface
// float4 DoSunLight(float3 N)
// {
// // modulate the sunlight by the surface angle
// return vecSunDiffuse * dot(N,-vecSunDir);
// }
//
// // return the dynamic light on the surface
// float4 DoPointLight(float3 P, float3 N, int i)
// {
// // calculate the light ray pointing from the light to the surface
// float3 D = vecLightPos[i].xyz - P;
// // calculate the angle between surface and light ray
// float NdotL = dot(N, normalize(D));
// // modulate the light by the surface angle
// float4 Color = vecLightColor[i] * NdotL;
//
// // calculate the light attenuation factor, DX uses a really strange formula here
// float fac = 0.f;
// if (NdotL >= 0.f && vecLightPos[i].w > 0.f)
// {
// // get the distance factor
// float LD = length(D)/vecLightPos[i].w;
// #ifdef DXLIGHTING
// if (LD < 1.3f)
// fac = 1.f/(vecFalloff.x + vecFalloff.y*LD + vecFalloff.z*LD*LD);
// #else // linear Lighting
// if (LD < 1.f)
// fac = 1.f - LD;
// #endif
// }
// return Color * fac;
// }
//
//
// float DoFog(float4 Pos)
// {
// // convert the vector position to view space to get it's depth (.z)
// float3 P = mul(Pos,matWorldView);
// // apply the linear fog formula
// return saturate((vecFog.y-P.z) * vecFog.z);
// }
//
//
// struct TMULTI_VS_OUT // Output to the pixelshader fragment
// {
// float4 Pos : POSITION;
// float Fog : FOG;
//
// float4 tColor : COLOR0;
//
// float2 Tex1 : TEXCOORD0;
// float2 Tex2 : TEXCOORD1;
//
// float2 Tex3 : TEXCOORD2;
// float2 Tex4 : TEXCOORD3;
//
// float2 Tex5 : TEXCOORD4;
// float2 Tex6 : TEXCOORD5;
// float2 Tex7 : TEXCOORD6;
// float2 Tex8 : TEXCOORD7;
// };
//
// 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);
// float3 N = normalize(mul(inNormal, matWorldInv));
// float3 P = mul(inPos, matWorld);
//
// // Add ambient and sun light
// Out.tColor = ((DoSunLight(N) - 0.2f)*sunStrength)+0.6;
//
// // Add 8 dynamic lights (maximum for vs 1.1)
// for (int i=0; i<6; i++)
// Out.tColor += DoPointLight(P,N,i)*dynalightStrength;
//
// // Add fog
// 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*vecSkill41.w+vecSkill41.w/50)+0.1* vecSkill41.xy;//sin(vecSkill41);//moving the caustics texture
// Out.Tex4 = (inTexCoord0.xy*vecSkill41.w)-0.1* vecSkill41.y;//moving the caustics texture
//
// Out.Tex5 = inTexCoord0.xy*40; // tiling texture red
// Out.Tex6 = inTexCoord0.xy*60; // tiling texture green
// Out.Tex7 = inTexCoord0.xy*20; // tiling texture blue
// Out.Tex8 = inTexCoord0.xy*40; // 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)*1.5);
//
// float4 causticsA = tex2D(sTex3,In.Tex3);
// float4 causticsB = tex2D(sTex4,In.Tex4);
//
// float4 RedColor = tex2D(sTex5,In.Tex5);
// float4 GreenColor = tex2D(sTex6,In.Tex6);
// float4 BlueColor = tex2D(sTex7,In.Tex7);
// float4 BlackColor = tex2D(sTex8,In.Tex8);
//
//
// float4 BaseRed = lerp(BlackColor,RedColor,BlendColor.r);
// float4 BaseGreen = lerp(BaseRed,GreenColor,BlendColor.g);
//
//
// float4 FinalColor = lerp(BaseGreen,BlueColor,BlendColor.b);
//
//
// float4 BaseCaustics = lerp(FinalColor,(FinalColor*(causticsA+causticsB)),(ShadowMap.a*mtlSkill2));
//
// //////////////////////////////////////////////////////////////////////////////////////////////
//
//
// FinalColor = In.tColor*(BaseCaustics*(ShadowMap));
//
// FinalColor = (FinalColor*mtlSkill1)*(ShadowMap);
//
// 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();
// }
// }
//
//technique fallback{pass p0{}}
//
// ";
//}
//FFE FALLBACK MATERIALS FOR TERRAINS
MATERIAL* mat_terr_ffe_1 =
{
skin1 = terr_colormap_1;
skin2 = terr_detailmap_1;
skin3 = terr_shadowmap_1;
event = init_mat_terr_ffe;
effect = "
float4 mtlSkill1;
Texture mtlSkin1;
Texture mtlSkin2;
Texture mtlSkin3;
texture mtlSkin4;
technique technique_two
{
pass p0
{
Texture[0] = <mtlSkin1>;
Texture[1] = <mtlSkin2>;
Texture[2]=<mtlSkin3>;
ColorArg1[0] = Texture;
ColorOp[0] = modulate2x;
ColorArg2[0] = current;
ColorArg1[1] = Texture;
ColorOp[1] = addsigned;
TextureTransformFlags[0] = Disable;
TexCoordIndex[0] = 0;
TextureTransformFlags[1] = Count2;
TexCoordIndex[1] = 1;
TextureTransform[1]= {
8.0, 0.0, 0.0 ,0.0,//u-scale detailmap CHANGE THIS TO YOUR NEEDS!
0.0, 8.0, 0.0, 0.0,//v-scale detailmap CHANGE THIS TO YOUR NEEDS!
0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0
};
ColorArg1[2]=Texture;
ColorOp[2]=Modulate;
ColorArg2[2]=Current;
TexCoordIndex[2]=0;
TextureTransformFlags[2]=Count2;
TextureTransform[2]={1.0,0.0,0.0,0.0,
0.0,1.0,0.0,0.0,
0.0,0.0,0.0,0.0,
0.0,0.0,0.0,0.0};
Texture[4] = <mtlSkin4>;//alpha in this texture makes entSkin1-texture transparent
TexCoordIndex[4] = 0;
ColorArg1[4] = <mtlSkill1>;//Current;// Get current texture (0)
ColorOp[4] = Modulate2x;//ModulateAlpha_AddColor;//and add alpha to indicate transparency
ColorArg2[4] = Current;
}
}
";
}
//MATERIAL* mat_terr_ffe_2 =
//{
//
// skin1 = terr_colormap_2;
// skin2 = terr_detailmap_2;
//
// skin3 = terr_shadowmap_2;
//
// event = init_mat_terr_ffe;
//
// effect = "
//
// float4 mtlSkill1;
//
// Texture mtlSkin1;
// Texture mtlSkin2;
//
// Texture mtlSkin3;
//
// texture mtlSkin4;
//
// technique technique_two
// {
// pass p0
// {
// Texture[0] = <mtlSkin1>;
// Texture[1] = <mtlSkin2>;
//
// Texture[2]=<mtlSkin3>;
//
//
// ColorArg1[0] = Texture;
// ColorOp[0] = modulate2x;
// ColorArg2[0] = current;
//
// ColorArg1[1] = Texture;
// ColorOp[1] = addsigned;
//
// TextureTransformFlags[0] = Disable;
// TexCoordIndex[0] = 0;
//
// TextureTransformFlags[1] = Count2;
// TexCoordIndex[1] = 1;
// TextureTransform[1]= {
// 15.0, 0.0, 0.0 ,0.0,//u-scale detailmap CHANGE THIS TO YOUR NEEDS!
// 0.0, 15.0, 0.0, 0.0,//v-scale detailmap CHANGE THIS TO YOUR NEEDS!
// 0.0, 0.0, 0.0, 0.0,
// 0.0, 0.0, 0.0, 0.0
// };
//
//
// ColorArg1[2]=Texture;
// ColorOp[2]=Modulate;
// ColorArg2[2]=Current;
// TexCoordIndex[2]=0;
// TextureTransformFlags[2]=Count2;
// TextureTransform[2]={1.0,0.0,0.0,0.0,
// 0.0,1.0,0.0,0.0,
// 0.0,0.0,0.0,0.0,
// 0.0,0.0,0.0,0.0};
//
//
// Texture[4] = <mtlSkin4>;//alpha in this texture makes entSkin1-texture transparent
//
// TexCoordIndex[4] = 0;
//
// ColorArg1[4] = <mtlSkill1>;//Current;// Get current texture (0)
// ColorOp[4] = Modulate2x;//ModulateAlpha_AddColor;//and add alpha to indicate transparency
// ColorArg2[4] = Current;
// }
// }
// ";
//}
function mat_terr_hlsl_refl_event()
{
if(render_view != view_rr)//displays shader terrain above watersurface...the real terrain
{
if(my.terr_id_number == 1){
mtl = mat_terr_hlsl_1;
}
// if(my.terr_id_number == 2){
// mtl = mat_terr_hlsl_2;
// }
// if(my.terr_id_number == 3){
// mtl = mat_terr_hlsl_3;
// }
// if(my.terr_id_number == 4){
// mtl = mat_terr_hlsl_4;
// }
////add more terrain materials the same way...
mtl.skill1 = pixel_for_vec (vector(clamp((d3d_fogcolor1.blue*my.terr_fogcol_fac)+(my.terr_add_blue*clamp(sun_angle.tilt/30,0.4,1))+(lightning),0,255),clamp((d3d_fogcolor1.green*my.terr_fogcol_fac)+(my.terr_add_green*clamp(sun_angle.tilt/30,0.4,1))+(lightning),0,255),clamp((d3d_fogcolor1.red*my.terr_fogcol_fac)+(my.terr_add_red*clamp(sun_angle.tilt/30,0.4,1))+(lightning),0,255)),100,8888);
if(is(my,terr_no_caustics)){
mtl.skill2 = pixel_for_vec(vector(0,0,0),100,8888);
}
else{
mtl.skill2 = pixel_for_vec(vector(my.terr_caust_strenght,my.terr_caust_strenght,my.terr_caust_strenght),100,8888);
}
}
else//displays ffe terrain on reflecting watersurface...because shader terrain doesen't display correctly in a render to texture view
{
if(my.terr_id_number == 1){
mtl = mat_terr_ffe_1;
}
// if(my.terr_id_number == 2){
// mtl = mat_terr_ffe_2;
// }
// if(my.terr_id_number == 3){
// mtl = mat_terr_ffe_3;
// }
// if(my.terr_id_number == 4){
// mtl = mat_terr_ffe_4;
// }
////add more terrain materials the same way...
vec_set(mtl.ambient_blue,vector(clamp((d3d_fogcolor1.blue*my.terr_fogcol_fac)+(my.terr_add_blue*clamp(sun_angle.tilt/30,0.2,1))+(lightning),0,255),clamp((d3d_fogcolor1.green*my.terr_fogcol_fac)+(my.terr_add_green*clamp(sun_angle.tilt/30,0.2,1))+(lightning),0,255),clamp((d3d_fogcolor1.red*my.terr_fogcol_fac)+(my.terr_add_red*clamp(sun_angle.tilt/30,0.2,1))+(lightning),0,255)));
}
}
function init_mat_terr_hlsl()
{
bmap_to_mipmap(mtl.skin1);
bmap_to_mipmap(mtl.skin2);
bmap_to_mipmap(mtl.skin3);
bmap_to_mipmap(mtl.skin4);
if(is(view_rr,VISIBLE))
{
mtl.event = mat_terr_hlsl_refl_event;
}
else{
mtl.skill1 = pixel_for_vec(vector(clamp((d3d_fogcolor1.blue*my.terr_fogcol_fac)+(my.terr_add_blue*clamp(sun_angle.tilt/30,0.4,1))+(lightning),0,255),clamp((d3d_fogcolor1.green*my.terr_fogcol_fac)+(my.terr_add_green*clamp(sun_angle.tilt/30,0.4,1))+(lightning),0,255),clamp((d3d_fogcolor1.red*my.terr_fogcol_fac)+(my.terr_add_red*clamp(sun_angle.tilt/30,0.4,1))+(lightning),0,255)),100,8888);
if(is(my,terr_no_caustics)){
mtl.skill2 = pixel_for_vec(vector(0,0,0),100,8888);
}
else{
mtl.skill2 = pixel_for_vec(vector(my.terr_caust_strenght,my.terr_caust_strenght,my.terr_caust_strenght),100,8888);
}
}
set(mtl,ENABLE_RENDER);
}
function init_mat_terr_ffe()
{
bmap_to_mipmap(mtl.skin1);
bmap_to_mipmap(mtl.skin2);
vec_set(mtl.ambient_blue,vector(clamp((d3d_fogcolor1.blue*my.terr_fogcol_fac)+(my.terr_add_blue*clamp(sun_angle.tilt/30,0.2,1))+(lightning),0,255),clamp((d3d_fogcolor1.green*my.terr_fogcol_fac)+(my.terr_add_green*clamp(sun_angle.tilt/30,0.2,1))+(lightning),0,255),clamp((d3d_fogcolor1.red*my.terr_fogcol_fac)+(my.terr_add_red*clamp(sun_angle.tilt/30,0.2,1))+(lightning),0,255)));
set(mtl,ENABLE_RENDER);
}