Ich hab folgenden code von was-weis-ich-wehm, hab ihn noch ein bissien ausgebaut und würde jetzt noch gerne transparenz ala Farcry hinzufügen.
Kann mir jemand sagen wie?
float4x4 matWorldViewProj: register(c0);
texture entSkin1;
texture entSkin2;
texture entSkin3;
vector vecSkill41;
float1 mtlSkill1;
struct VS_OUTPUT
{
float4 Pos: POSITION;
float2 texCoord: TEXCOORD0;
float3 eyeLinear: TEXCOORD1;
}
VS_OUTPUT VS_p0(float4 Pos: POSITION)
{
VS_OUTPUT Out;
float4 pos = float4(1 * Pos.x, 1 * Pos.y - 1, 1 * Pos.z, 1);
float4 pPos = mul(float4(pos.xyz,1), matWorldViewProj);
Out.Pos = pPos;
Out.texCoord.x = Pos.x * 0.5;
Out.texCoord.y = Pos.z * 0.5;
Out.eyeLinear.x = 0.5 * (pPos.z + pPos.x);
Out.eyeLinear.y = 0.5 * (pPos.z - pPos.y);
Out.eyeLinear.z = pPos.z * 1;
return Out;
}
sampler BumpMap = sampler_state
{
texture=(entSkin3);
MAGFILTER = LINEAR;
MINFILTER = LINEAR;
MIPFILTER = LINEAR;
}
sampler RefractionMap = sampler_state
{
texture=(entSkin2);
MAGFILTER = LINEAR;
MINFILTER = LINEAR;
MIPFILTER = LINEAR;
};
sampler ReflectionMap = sampler_state
{
texture=(entSkin1);
MAGFILTER = LINEAR;
MINFILTER = LINEAR;
MIPFILTER = LINEAR;
};
float4 PS_p0( float2 texCoord: TEXCOORD0,
float3 eyeLinear: TEXCOORD1) : COLOR
{
// addiere die Geschindigkeit von vecSkill41 hinzu für Wellenbewegung
float2 waterCoord = texCoord.xy * 0.001 * vecSkill41;
// die Bumpmap mit der waterCoord Koordinaten
float4 bump = tex2D(BumpMap, waterCoord) * 2 - 1;
bump = normalize(bump);
float2 mid = eyeLinear.xy / eyeLinear.z + bump.xy * 0.1f ;
// Reflektierte Wasseroberfläche
float4 reflection = tex2D(ReflectionMap, mid);
// Output
return reflection;
}
technique water
{
pass p1
{ VertexShader = compile vs_1_1 VS_p0();
PixelShader = compile ps_2_0 PS_p0();
}
}