If understanding right.I don`t have reflection view. I have shader.
function init_mat_hlsl_river_rr()
{
bmap_to_mipmap(mtl.skin1);
bmap_to_normals(mtl.skin1,1);
mtl.skill1 = pixel_for_vec(vector(clamp((d3d_fogcolor1.blue*my.riv_fogcol_fac)+(my.riv_add_blue*clamp(sun_angle.tilt/30,0.2,1))+(lightning),0,255),clamp((d3d_fogcolor1.green*my.riv_fogcol_fac)+(my.riv_add_green*clamp(sun_angle.tilt/30,0.2,1))+(lightning),0,255),clamp((d3d_fogcolor1.red*my.riv_fogcol_fac)+(my.riv_add_red*clamp(sun_angle.tilt/30,0.2,1))+(lightning),0,255)),100,8888);
mtl.skill2 = pixel_for_vec(nullvector,my.riv_alpha,8888);
mtl.skill3 = pixel_for_vec(vector(200*clamp(sun_angle.tilt/30,0,1),200*clamp(sun_angle.tilt/30,0,1),200*clamp(sun_angle.tilt/30,0,1)),100,8888);
set(mtl,ENABLE_RENDER);
}
MATERIAL* mat_hlsl_river_rr =
{
flags = tangent;
skin1 = bmp_river_bump;
skin3 = bmp_lake_shoreA;
skin4 = bmp_lake_shoreB;
event = init_mat_hlsl_river_rr;
effect=
"
float4x4 matWorld;
float4x4 matViewInv;
float4x4 matWorldViewProj;
float4 vecFog;
float4 vecViewPos;
float4 vecTime;
float4 vecColor;
float4 vecSkill41; // Wind_X, Wind_Y, Ripple, Scale
float4 mtlSkill1;
float4 mtlSkill2;
float4 mtlSkill3;
#define ShoreScale 100
#define ShoreBewegung 50
#define ShoreSpeed 0.03
texture entSkin1;
texture mtlSkin1;
texture mtlSkin2;
texture mtlSkin3;
texture mtlSkin4;
sampler sBumpTex = sampler_state { Texture = (mtlSkin1); };
sampler sReflectTex = sampler_state
{
Texture = (mtlSkin2);
AddressU = Clamp;
AddressV = Clamp;
};
sampler sAlphaTex = sampler_state { Texture = (entSkin1); };
sampler sShoreATex = sampler_state { Texture = (mtlSkin3); };
sampler sShoreBTex = sampler_state { Texture = (mtlSkin4); };
//////////////////////////////////////////////////////////////////////
//section: transform - calculate vertex position /////////////////////
float4 DoTransform(float4 Pos)
{
return mul(Pos,matWorldViewProj);
}
//////////////////////////////////////////////////////////////////////
//section: fog ///////////////////////////////////////////////////////
float DoFog(float4 Pos)
{
float3 P = mul(Pos,matWorld);
return 1 - (distance(P,vecViewPos)-vecFog.x) * vecFog.z;
}
//////////////////////////////////////////////////////////////////////
//section: pos - transform vertex position to world space ////////////
float4 DoPos(float4 Pos)
{
return (mul(Pos,matWorld));
}
float3 DoPos(float3 Pos)
{
return (mul(Pos,matWorld));
}
//////////////////////////////////////////////////////////////////////
//section: normal - transform vertex normal //////////////////////////
float3 DoNormal(float3 inNormal)
{
return normalize(mul(inNormal,matWorld));
}
struct out_water_env // Output to the pixelshader
{
float4 Pos : POSITION;
float4 Color: COLOR0;
float Fog : FOG;
float2 Tex0 : TEXCOORD0; //Bumpmap
float2 Tex1 : TEXCOORD1; //Shoremap
float2 Tex2 : TEXCOORD2; //Shore 1
float2 Tex3 : TEXCOORD3; //Shore 2
float3 Tex4 : TEXCOORD4; //Reflection
};
out_water_env vs_water_env
(
float4 inPos : POSITION,
float3 inNormal : NORMAL,
float2 inTex0 : TEXCOORD0
)
{
out_water_env Out;
Out.Pos = DoTransform(inPos); // transform to screen coordinates
Out.Fog = DoFog(inPos);
// bump and reflection coordinates
Out.Tex0 = (inTex0 + vecSkill41.xy * vecTime.w) * vecSkill41.w;
Out.Tex1 = inTex0;
// Out.Tex1 = (inTex0 + vecSkill41.xy * sin(vecTime.w*ShoreSpeed*2)*ShoreBewegung);//slightly moving the shore-blendmap
Out.Tex2 = (inTex0 + vecSkill41.xy * sin(vecTime.w*ShoreSpeed)*ShoreBewegung) * ShoreScale;//moving the shore texture
Out.Tex3 = (inTex0 + vecSkill41.xy * cos(vecTime.w*ShoreSpeed)*ShoreBewegung) * ShoreScale;//moving the shore texture
Out.Tex4 = Out.Pos.xyw;
// color and transparency
Out.Color = vecColor;
//Fresnel
float4 P = DoPos(inPos); // vector world position
float4 vecToView = normalize(vecViewPos-P); // direction towards camera
float3 N = DoNormal(inNormal); // normal world orientation
Out.Color = (0.6 + (vecColor.a * mtlSkill2) * (1.0 - dot(vecToView,N)))*mtlSkill1;
return Out;
}
float4 PS_p0( float4 VertColor: COLOR0, float2 texCoord: TEXCOORD0,
float2 Tex1: TEXCOORD1, float2 ShoreATex : TEXCOORD2,
float2 ShoreBTex : TEXCOORD3, float3 Tex4 : TEXCOORD4
) : COLOR
{
//Read ShoreMapPixel
float4 ShoreMapColor = tex2D(sAlphaTex,Tex1);
// die Bumpmap mit der waterCoord Koordinaten
float4 Bump = tex2D(sBumpTex, texCoord) * 2 - 1;
float2 temp = Tex4.xy/Tex4.z;
float2 Coord = 0.5*(1.0+temp)+Bump.xy*vecSkill41.z;
// Reflektierte Wasseroberfläche
float4 reflection = tex2D(sReflectTex, Coord);
reflection.a = 1;
reflection *= VertColor;
if(ShoreMapColor.r > 0)
{
//Shoreline
float4 ShoreColor;
float4 ShoreAColor = tex2D(sShoreATex,ShoreATex);
float4 ShoreBColor = tex2D(sShoreBTex,ShoreBTex);
ShoreColor = (ShoreAColor+ShoreBColor-1)*(mtlSkill3+0.3);
reflection = lerp(reflection,ShoreColor,ShoreMapColor.r);
}
reflection.a *= (1-ShoreMapColor.g);
// Output
return reflection;
}
//////////////////////////////////////////////////////////////////
technique water_env
{
pass one
{
alphablendenable = true;
alphatestenable = false;//true;
zenable = true;
zwriteenable=true;
CullMode=none;
VertexShader = compile vs_1_1 vs_water_env();
PixelShader = compile ps_2_0 PS_p0();
}
}
technique fallback { pass one { } }";
}