Graphics Reference
In-Depth Information
3.
Unlike the TextureCube texture, there is no built-in support for sampling a
paraboloid texture; therefore, we need to implement our own method.
float4 SampleEnvMap(SamplerState s, float3 R)
{
// Transform to the Paraboloid view-space
R = mul(R, (float3x3)DualMapView);
float3 texCoord = (float3)0;
texCoord.xy = (R.xy / (2*(1 + abs(R.z)))) + 0.5f;
texCoord.y = 1-texCoord.y;
if (R.z > 0) {
texCoord.z = 0; // Front half (texture array index 0)
} else {
texCoord.z = 1; // Back half (texture array index 1)
}
return Reflection.Sample(s, texCoord.xyz);
}
4.
Within the DualParaboloidMap.hlsl file, we add the following include
directives and structures:
#include "Common.hlsl"
#include "EnvironmentMap.hlsl"
// Geometry shader input structure (from Vertex shader)
struct GS_DualMapInput
{
float4 Position : SV_Position;
...SNIP - same as PixelShaderInput properties
// Normalized Z for Paraboloid
float DualMapZ: TEXCOORD4;
};
// Pixel Shader input structure (from Geometry Shader)
struct GS_DualMapOutput
{
float4 Position : SV_Position;
...SNIP - same as PixelShaderInput properties
// Normalized Z for Paraboloid
float DualMapZ: TEXCOORD4;
// Allows us to write to multiple render targets
uint RTIndex : SV_RenderTargetArrayIndex;
};
 
Search WWH ::




Custom Search