Main Page | Class List | Directories | File List | Class Members | File Members

EnvMap.fx File Reference


Defines

#define CUBEMAP_SIZE   128
 size of the cube map taken from the reference point of the object
#define LR_CUBEMAP_SIZE   4
 size of the cube map for diffuse/glossy reflections
#define RATE   (CUBEMAP_SIZE/LR_CUBEMAP_SIZE)
 cube map downsampling rate for diffuse/glossy reflections
#define PI   3.14159f
#define TechniqueUsingCommonVS(name)
 a helpful macro to define techniques with a common vertex program
#define Technique(name)
 a helpful macro to define techniques

Functions

ReduceTextureVS_output ReduceTextureVS (ReduceTextureVS_input IN)
 See the pixel program.
float4 ReduceTexturePS (ReduceTextureVS_output IN)
 Downsamples a face of a cube map.
float4 GetContibution (float3 q, float3 L)
 Returns the precalculated contribution of a texel with regard to the specified query direction.
ConvolutionVS_output ConvolutionVS (ConvolutionVS_input IN)
 See the pixel program.
float4 ConvolutionPS (ConvolutionVS_output IN)
 Convolves the values of a cube map.
float3 Hit (float3 x, float3 R, sampler mp)
 This function approximately traces a ray from point x towards direction R. Depth information is obtained from the alpha channel of mp.
float4 metal_reflectivity (float3 L, float3 N, float3 V)
 Simple Fresnel term approximation for metals.
EnvMapVS_output EnvMapVS (EnvMapVS_input IN)
float4 EnvMapImpostorPS (EnvMapVS_output IN)
 Environment mapping with distance impostors.
float4 EnvMapImpostorMetalPS (EnvMapVS_output IN)
float4 EnvMapClassicPS (EnvMapVS_output IN)
 Classic environment mapping technique.
float4 EnvMapClassicMetalPS (EnvMapVS_output IN)
 Classic environment mapping technique with a simple Fresnel term approximation (metal_reflectivity()).
float4 EnvMapDiffusePS (EnvMapVS_output IN)
 Determines diffuse or specular illumination with a single lookup into PreconvolvedEnvironmentMap.
float4 GetContibution (float3 L, float3 pos, float3 N, float3 V)
 Calculates the contribution of a single texel of SmallEnvironmentMap to the illumination of the shaded point.
float4 EnvMapDiffuseLocalizedPS (EnvMapVS_output IN)
 Calculates diffuse or specular contributions of all texels in SmallEnvironmentMap to the current point. For each texel of SmallEnvironmentMap, function GetContibution(float3,float3,float3,float3) is called.
float4 GetContibutionWithCosLookup (float3 L, float3 pos, float3 N, float3 V)
 Calculates the contribution of a single texel of SmallEnvironmentMap to the illumination of the shaded point.
float4 EnvMapDiffuseLocalizedWithCosLookupPS (EnvMapVS_output IN)
 Calculates diffuse or specular contributions of all texels in SmallEnvironmentMap to the current point. For each texel of SmallEnvironmentMap, function GetContibutionWithCosLookup() is called.
IlluminatedSceneVS_output IlluminatedSceneVS (IlluminatedSceneVS_input IN)
float4 IlluminatedScenePS (IlluminatedSceneVS_output IN)
 Displays the environment with a simple shading.
 TechniqueUsingCommonVS (EnvMapClassic)
 TechniqueUsingCommonVS (EnvMapImpostor)
 TechniqueUsingCommonVS (EnvMapDiffuse)
 Technique (IlluminatedScene)
 Technique (ReduceTexture)
 Technique (Convolution)

Variables

float4x4 World
 World matrix for the current object.
float4x4 WorldIT
 World matrix IT (inverse transposed) to transform surface normals of the current object.
float4x4 WorldView
 World * View matrix.
float4x4 WorldViewProjection
 World * View * Projection matrix.
float texel_size
 upload this constant every time the viewport changes
float4 eyePos
 current eye (camera) position
float4 reference_pos
 Reference point for the last cube map generation.
int nFace
int iShowCubeMap
float4 objColor
float3 nMetal
 real part of the refraction coefficient for metals
float3 kMetal
 imaginary part of the refraction coefficient for metals
float sFresnel
 Fresnel refraction param.
float refractionIndex
float intensity
float shininess
float brightness
texture EnvironmentMap
texture SmallEnvironmentMap
texture PreconvolvedEnvironmentMap
texture Decoration
sampler EnvironmentMapSampler
sampler PreconvolvedEnvironmentMapSampler
sampler SmallEnvironmentMapSampler
sampler DecorationSampler

Define Documentation

#define CUBEMAP_SIZE   128
 

size of the cube map taken from the reference point of the object

#define LR_CUBEMAP_SIZE   4
 

size of the cube map for diffuse/glossy reflections

#define PI   3.14159f
 

#define RATE   (CUBEMAP_SIZE/LR_CUBEMAP_SIZE)
 

cube map downsampling rate for diffuse/glossy reflections

#define Technique name   ) 
 

Value:

;                                                               \
        technique name                                                                          \
        {                                                                                                       \
            pass p0                                                                                     \
            {                                                                                           \
                    VertexShader = compile vs_3_0 name##VS();   \
                    PixelShader  = compile ps_3_0 name##PS();   \
                }                                                                                               \
        }
a helpful macro to define techniques

#define TechniqueUsingCommonVS name   ) 
 

Value:

;                                       \
        technique name                                                                          \
        {                                                                                                       \
            pass p0                                                                                     \
            {                                                                                           \
                    VertexShader = compile vs_3_0 EnvMapVS();   \
                    PixelShader  = compile ps_3_0 name##PS();   \
                }                                                                                               \
        }
a helpful macro to define techniques with a common vertex program


Function Documentation

float4 ConvolutionPS ConvolutionVS_output  IN  ) 
 

Convolves the values of a cube map.

Calculates the diffuse/specular irradiance map of resolution LR_CUBEMAP_SIZE by summing up the contributions of all cube map texels with regard to the current query direction.

Parameters:
SmallEnvironmentMap is bound to EnvMap::pCubeTextureSmall (cube map of resolution LR_CUBEMAP_SIZE)

ConvolutionVS_output ConvolutionVS ConvolutionVS_input  IN  ) 
 

See the pixel program.

float4 EnvMapClassicMetalPS EnvMapVS_output  IN  ) 
 

Classic environment mapping technique with a simple Fresnel term approximation (metal_reflectivity()).

float4 EnvMapClassicPS EnvMapVS_output  IN  ) 
 

Classic environment mapping technique.

Simply determines the ideal reflection/refraction direction and performs a cube map lookup into that direction

Parameters:
EnvironmentMap is bound to EnvMap::pCubeTexture (cube map of resolution CUBEMAP_SIZE)

float4 EnvMapDiffuseLocalizedPS EnvMapVS_output  IN  ) 
 

Calculates diffuse or specular contributions of all texels in SmallEnvironmentMap to the current point. For each texel of SmallEnvironmentMap, function GetContibution(float3,float3,float3,float3) is called.

Parameters:
SmallEnvironmentMap is bound to EnvMap::pCubeTextureSmall (cube map of resolution LR_CUBEMAP_SIZE)

float4 EnvMapDiffuseLocalizedWithCosLookupPS EnvMapVS_output  IN  ) 
 

Calculates diffuse or specular contributions of all texels in SmallEnvironmentMap to the current point. For each texel of SmallEnvironmentMap, function GetContibutionWithCosLookup() is called.

Parameters:
SmallEnvironmentMap is bound to EnvMap::pCubeTextureSmall (cube map of resolution LR_CUBEMAP_SIZE)

float4 EnvMapDiffusePS EnvMapVS_output  IN  ) 
 

Determines diffuse or specular illumination with a single lookup into PreconvolvedEnvironmentMap.

Parameters:
PreconvolvedEnvironmentMap is bound to EnvMap::pCubeTexturePreConvolved (cube map of resolution LR_CUBEMAP_SIZE)

float4 EnvMapImpostorMetalPS EnvMapVS_output  IN  ) 
 

float4 EnvMapImpostorPS EnvMapVS_output  IN  ) 
 

Environment mapping with distance impostors.

Determines the ideal reflection/refraction direction and approximately traces a ray toward that direction using the Hit() function.

Parameters:
EnvironmentMap is bound to EnvMap::pCubeTexture (cube map of resolution CUBEMAP_SIZE)

EnvMapVS_output EnvMapVS EnvMapVS_input  IN  ) 
 

float4 GetContibution float3  L,
float3  pos,
float3  N,
float3  V
 

Calculates the contribution of a single texel of SmallEnvironmentMap to the illumination of the shaded point.

Parameters:
L vector pointing to the center of the texel under examination. We assume that the largest coordinate component of L is equal to one, i.e. L points to the face of a cube of edge length of 2.
pos is the position of the shaded point
N is the surface normal at the shaded point
V is the viewing direction at the shaded point

float4 GetContibution float3  q,
float3  L
 

Returns the precalculated contribution of a texel with regard to the specified query direction.

Parameters:
q query direction (i.e. surface normal in diffuse case, ideal reflection direction in specular case).
L vector pointing to the texel center

float4 GetContibutionWithCosLookup float3  L,
float3  pos,
float3  N,
float3  V
 

Calculates the contribution of a single texel of SmallEnvironmentMap to the illumination of the shaded point.

The only difference from GetContibution(float3,float3,float3,float3) is that now we use precalculated integral values to compute reflectivity (instead of using only one sample).

float3 Hit float3  x,
float3  R,
sampler  mp
 

This function approximately traces a ray from point x towards direction R. Depth information is obtained from the alpha channel of mp.

Returns:
the approximate hit point.

float4 IlluminatedScenePS IlluminatedSceneVS_output  IN  ) 
 

Displays the environment with a simple shading.

IlluminatedSceneVS_output IlluminatedSceneVS IlluminatedSceneVS_input  IN  ) 
 

float4 metal_reflectivity float3  L,
float3  N,
float3  V
 

Simple Fresnel term approximation for metals.

The metal is described by its (complex) refraction coefficient (nMetal,kMetal).

float4 ReduceTexturePS ReduceTextureVS_output  IN  ) 
 

Downsamples a face of a cube map.

Downsamples the nFace-th face of a cube map from resolution CUBEMAP_SIZE to LR_CUBEMAP_SIZE by averaging the corresponding texel values. The EnvironmentMap is sampled via EnvironmentMapSampler.

Parameters:
nFace uniform parameter identifies the current face (0...5)

ReduceTextureVS_output ReduceTextureVS ReduceTextureVS_input  IN  ) 
 

See the pixel program.

Technique Convolution   ) 
 

Technique ReduceTexture   ) 
 

Technique IlluminatedScene   ) 
 

TechniqueUsingCommonVS EnvMapDiffuse   ) 
 

TechniqueUsingCommonVS EnvMapImpostor   ) 
 

TechniqueUsingCommonVS EnvMapClassic   ) 
 


Variable Documentation

float brightness
 

texture Decoration
 

sampler DecorationSampler
 

Initial value:

 sampler_state 
{
    Texture   = <Decoration>;
    MinFilter = LINEAR;
    MagFilter = LINEAR;
    
    AddressU  = CLAMP; 
    AddressV  = CLAMP; 
}

texture EnvironmentMap
 

sampler EnvironmentMapSampler
 

Initial value:

 sampler_state 
{
    
    Texture   = <EnvironmentMap>;
    AddressU  = WRAP;
    AddressV  = WRAP;
}

float4 eyePos
 

current eye (camera) position

float intensity
 

int iShowCubeMap
 

float3 kMetal
 

imaginary part of the refraction coefficient for metals

int nFace
 

float3 nMetal
 

real part of the refraction coefficient for metals

float4 objColor
 

texture PreconvolvedEnvironmentMap
 

sampler PreconvolvedEnvironmentMapSampler
 

Initial value:

 sampler_state 
{
    MinFilter = LINEAR;
    MagFilter = LINEAR;
    
    Texture   = <PreconvolvedEnvironmentMap>;
    AddressU  = WRAP;
    AddressV  = WRAP;
}

float4 reference_pos
 

Reference point for the last cube map generation.

float refractionIndex
 

float sFresnel
 

Fresnel refraction param.

float shininess
 

texture SmallEnvironmentMap
 

sampler SmallEnvironmentMapSampler
 

Initial value:

 sampler_state 
{
    MinFilter = Point;
    MagFilter = Point;
    
    Texture   = <SmallEnvironmentMap>;
    AddressU  = WRAP;
    AddressV  = WRAP;
}

float texel_size
 

upload this constant every time the viewport changes

float4x4 World
 

World matrix for the current object.

float4x4 WorldIT
 

World matrix IT (inverse transposed) to transform surface normals of the current object.

float4x4 WorldView
 

World * View matrix.

float4x4 WorldViewProjection
 

World * View * Projection matrix.


Generated on Thu Apr 27 11:58:00 2006 for gyak by  doxygen 1.4.2