Shaders for Shadows
Shader code for rendering shadows of translucent occluders, soft shadows and single scattering with moment shadow maps.
 All Classes Files Functions Variables Pages
Sampling.fx
1 
2 void Sample2DTexture_float(out float4 Sample,SSamplerTexturePair2D_float UsedSampler,float2 TexCoord){
3  Sample.x=UsedSampler.Texture.Sample(UsedSampler.Sampler,TexCoord);
4  Sample.yzw=float3(0.0f,0.0f,1.0f);
5 }
6 void Sample2DTexture_float2(out float4 Sample,SSamplerTexturePair2D_float2 UsedSampler,float2 TexCoord){
7  Sample.xy=UsedSampler.Texture.Sample(UsedSampler.Sampler,TexCoord);
8  Sample.zw=float2(0.0f,1.0f);
9 }
10 void Sample2DTexture_float3(out float4 Sample,SSamplerTexturePair2D_float3 UsedSampler,float2 TexCoord){
11  Sample.xyz=UsedSampler.Texture.Sample(UsedSampler.Sampler,TexCoord);
12  Sample.w=1.0f;
13 }
14 void Sample2DTexture_float4(out float4 Sample,SSamplerTexturePair2D UsedSampler,float2 TexCoord){
15  Sample=UsedSampler.Texture.Sample(UsedSampler.Sampler,TexCoord);
16 }
17 
19 /*void SampleCubeTexture(out float4 Sample,SSamplerTexturePairCube UsedSampler,float3 TexCoord){
20  Sample=UsedSampler.Texture.Sample(UsedSampler.Sampler,TexCoord);
21 }*/
22 
23 
44 void ApplyQuadTexCoordOffset(out float2 OutOffsetTexCoord,float2 TexCoord,float4 TextureSize){
45 #if D3D_VERSION==11
46  OutOffsetTexCoord=TexCoord;
47 #elif D3D_VERSION==9
48  OutOffsetTexCoord=TexCoord+0.5f*TextureSize.zw;
49 #endif
50 }
51 
58 void ComputeTexelIndex(out int2 OutTexelIndex,float2 TexCoord,float4 TextureSize){
59  OutTexelIndex=int2(TexCoord*TextureSize.xy);
60 }