Original Post
Hello, I am trying to create a water plane that reflects the enviroment above it. But I am not having much success. I am trying to learn using the HDR HLSL env mapping demo included in the SDK. I belive the problem lies in the shader.
[Source]
//-----------------------------------------------------------------------------
// Vertex Shader: HDRVertEnvMap
// Desc: Process vertex for HDR environment mapping
//-----------------------------------------------------------------------------
void HDRVertEnvMap( float4 vPos : POSITION,
float3 vNormal : NORMAL,
float2 vTexCoord0 : TEXCOORD0,
out float4 oPos : POSITION,
out float3 EnvTex : TEXCOORD0 )
{
//g_mWorld = mul(g_mWorld, g_mView);
//
// Transform position to view space
//
oPos = mul( vPos, mul(g_mWorld,g_mView));
//
// Compute normal in camera space
//
float3 vN = mul( vNormal, g_mWorld );
vN = normalize( vN );
//
// Obtain the reverse eye vector
//
float3 vEyeR = -normalize( oPos );
//
// Compute the reflection vector
//
float3 vRef = 2 * dot( vEyeR, vN ) * vN - vEyeR;
//
// Store the reflection vector in texcoord0
//
EnvTex = vRef;
//
// Apply the projection
//
oPos = mul( oPos, g_mProj );
}
//-----------------------------------------------------------------------------
// Pixel Shader: HDRPixEnvMap
// Desc: Process pixel for HDR environment mapped object
//-----------------------------------------------------------------------------
float4 HDRPixEnvMap( float3 Tex : TEXCOORD0 ) : COLOR
{
return 1.0 * texCUBE( g_samCubeMap, Tex );
}
[/Source]