s3d_pixellit.frag   s3d_pixellit.frag 
skipping to change at line 34 skipping to change at line 34
This is a shader for phong/per-pixel lighting. This is a shader for phong/per-pixel lighting.
Note: This shader currently requires some #version 120 features! Note: This shader currently requires some #version 120 features!
*/ */
//macros that can be set by ShaderManager (simple true/false flags) //macros that can be set by ShaderManager (simple true/false flags)
#define BLENDING 1 #define BLENDING 1
#define SHADOWS 1 #define SHADOWS 1
#define SHADOW_FILTER 0 #define SHADOW_FILTER 0
#define SHADOW_FILTER_HQ 0 #define SHADOW_FILTER_HQ 0
#define SINGLE_SHADOW_FRUSTUM 1 #define SINGLE_SHADOW_FRUSTUM 1
#define HW_SHADOW_SAMPLERS 0
#define PCSS 0 #define PCSS 0
#define MAT_DIFFUSETEX 1 #define MAT_DIFFUSETEX 1
#define MAT_EMISSIVETEX 1 #define MAT_EMISSIVETEX 1
#define MAT_SPECULAR 1 #define MAT_SPECULAR 1
#define BUMP 0 #define BUMP 0
#define HEIGHT 0 #define HEIGHT 0
#define ALPHATEST 1 #define ALPHATEST 1
#define TORCH 1 #define TORCH 1
#if SHADOW_FILTER_HQ #if SHADOW_FILTER_HQ
skipping to change at line 256 skipping to change at line 257
#if SHADOWS #if SHADOWS
//in a later version, this may become configurable //in a later version, this may become configurable
#if SINGLE_SHADOW_FRUSTUM #if SINGLE_SHADOW_FRUSTUM
#define FRUSTUM_SPLITS 1 #define FRUSTUM_SPLITS 1
#else #else
#define FRUSTUM_SPLITS 4 #define FRUSTUM_SPLITS 4
#endif #endif
//shadow related uniforms //shadow related uniforms
uniform vec4 u_vSplits; //the frustum splits uniform vec4 u_vSplits; //the frustum splits
#if PCSS #if HW_SHADOW_SAMPLERS
#define SHADOWSAMPLER sampler2D
#else
#define SHADOWSAMPLER sampler2DShadow #define SHADOWSAMPLER sampler2DShadow
#else
#define SHADOWSAMPLER sampler2D
#endif #endif
//for some reason, Intel does absolutely not like it if the shadowmaps are passed as an array //for some reason, Intel does absolutely not like it if the shadowmaps are passed as an array
//nothing is drawn, but no error is shown ... //nothing is drawn, but no error is shown ...
//therefore, use 4 ugly uniforms //therefore, use 4 ugly uniforms
uniform SHADOWSAMPLER u_texShadow0; uniform SHADOWSAMPLER u_texShadow0;
#if !SINGLE_SHADOW_FRUSTUM #if !SINGLE_SHADOW_FRUSTUM
uniform SHADOWSAMPLER u_texShadow1; uniform SHADOWSAMPLER u_texShadow1;
uniform SHADOWSAMPLER u_texShadow2; uniform SHADOWSAMPLER u_texShadow2;
uniform SHADOWSAMPLER u_texShadow3; uniform SHADOWSAMPLER u_texShadow3;
skipping to change at line 313 skipping to change at line 314
{ {
#if FILTER_STEPS #if FILTER_STEPS
// a filter is defined // a filter is defined
float sum =0.0; float sum =0.0;
vec3 texC = coord.xyz / coord.w; vec3 texC = coord.xyz / coord.w;
for(int i=0;i<FILTER_STEPS;++i) for(int i=0;i<FILTER_STEPS;++i)
{ {
vec2 offset = poissonDisk[i] * filterRadiusUV; vec2 offset = poissonDisk[i] * filterRadiusUV;
//TODO offsets should probably depend on light ortho size? //TODO offsets should probably depend on light ortho size?
#if PCSS #if HW_SHADOW_SAMPLERS
sum+=shadow2D(tex,vec3(texC.xy + offset, texC.z)).x;
#else
//texture is a normal sampler2D because we need depth values in blocker calculation //texture is a normal sampler2D because we need depth values in blocker calculation
//opengl does not allow to sample this texture in 2 differen t ways (unless sampler objects are used, but needs version >= 3.3) //opengl does not allow to sample this texture in 2 differen t ways (unless sampler objects are used, but needs version >= 3.3)
//so we have to do comparison ourselves //so we have to do comparison ourselves
sum+= (texture2D(tex,texC.xy + offset).r > texC.z) ? 1.0f : 0.0f; sum+= (texture2D(tex,texC.xy + offset).r > texC.z) ? 1.0f : 0.0f;
#else
sum+=shadow2D(tex,vec3(texC.xy + offset, texC.z)).x;
#endif #endif
} }
return sum / FILTER_STEPS; return sum / FILTER_STEPS;
#else #elif HW_SHADOW_SAMPLERS
//no filtering performed, just return the sampled tex //no filtering performed, just return the sampled tex
return shadow2DProj(tex,coord).x; return shadow2DProj(tex,coord).x;
#else
vec3 texC = coord.xyz / coord.w;
return texture2D(tex,texC.xy).x > texC.z ? 1.0f : 0.0f;
#endif #endif
} }
#if PCSS #if PCSS
#if HW_SHADOW_SAMPLERS
#error Tried to compile PCSS shader compiled with HW shadow samplers
#endif
//Based on the PCSS implementation of NVidia, ported to GLSL //Based on the PCSS implementation of NVidia, ported to GLSL
//see http://developer.download.nvidia.com/whitepapers/2008/PCSS_Integratio n.pdf //see http://developer.download.nvidia.com/whitepapers/2008/PCSS_Integratio n.pdf
//Some modifications to work better with directional light are included //Some modifications to work better with directional light are included
//convert shadowmap depth to view-space Z value (for an orthographic projec tion) //convert shadowmap depth to view-space Z value (for an orthographic projec tion)
float depthToViewZ(float depth, float nearPlane, float farPlane) float depthToViewZ(float depth, float nearPlane, float farPlane)
{ {
return depth * (farPlane - nearPlane) + nearPlane; return depth * (farPlane - nearPlane) + nearPlane;
} }
 End of changes. 8 change blocks. 
7 lines changed or deleted 14 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/