STORM-1819: Ternary/graded shadow support

a bunch of trivial clean-ups and commentary.
meow-7.2.2
Adam Moss 2012-04-21 18:33:07 +01:00
parent 03442801bd
commit 442c5cf339
7 changed files with 8 additions and 35 deletions

View File

@ -29,18 +29,13 @@ out vec4 frag_color;
#define frag_color gl_FragColor
#endif
uniform mat4 modelview_projection_matrix;
uniform float minimum_alpha;
uniform sampler2D diffuseMap;
//flat VARYING int foo;
VARYING float pos_zd2;
VARYING float pos_w;
VARYING float target_pos_x;
//VARYING vec4 pre_pos;
//VARYING vec4 post_pos;
VARYING vec4 vertex_color;
VARYING vec2 vary_texcoord0;

View File

@ -34,9 +34,6 @@ ATTRIBUTE vec2 texcoord0;
VARYING float pos_zd2;
VARYING float pos_w;
VARYING float target_pos_x;
//flat VARYING int foo;
//VARYING vec4 pre_pos;
//VARYING vec4 post_pos;
VARYING vec4 vertex_color;
VARYING vec2 vary_texcoord0;
@ -47,11 +44,9 @@ void main()
//transform vertex
vec4 pre_pos = vec4(position.xyz, 1.0);
vec4 pos = modelview_projection_matrix * pre_pos;
//post_pos = pos;
target_pos_x = 0.5 * (shadow_target_width - 1.0) * pos.x;
pos_w = pos.w;
pos_zd2 = pos.z * 0.5;
//foo = int(posxw.x);
gl_Position = vec4(pos.x, pos.y, pos.w*0.5, pos.w);

View File

@ -68,8 +68,7 @@ float pcfShadow(sampler2DRectShadow shadowMap, vec4 stc)
stc.xyz /= stc.w;
stc.z += shadow_bias;
//stc.x = floor(stc.x + fract(stc.y) * 1.5);
stc.x = floor(stc.x + fract(stc.y*12345));
stc.x = floor(stc.x + fract(stc.y*12345)); // add some chaotic jitter to X sample pos according to Y to disguise the snapping going on here
float cs = shadow2DRect(shadowMap, stc.xyz).x;
float shadow = cs;

View File

@ -81,8 +81,7 @@ float pcfShadow(sampler2DRectShadow shadowMap, vec4 stc)
stc.xyz /= stc.w;
stc.z += shadow_bias;
//stc.x = floor(stc.x + fract(stc.y) * 1.5);
stc.x = floor(stc.x + fract(stc.y*12345));
stc.x = floor(stc.x + fract(stc.y*12345)); // add some chaotic jitter to X sample pos according to Y to disguise the snapping going on here
float cs = shadow2DRect(shadowMap, stc.xyz).x;
float shadow = cs;

View File

@ -80,8 +80,7 @@ float pcfShadow(sampler2DRectShadow shadowMap, vec4 stc)
stc.xyz /= stc.w;
stc.z += shadow_bias;
//stc.x = floor(stc.x + fract(stc.y) * 1.5);
stc.x = floor(stc.x + fract(stc.y*12345));
stc.x = floor(stc.x + fract(stc.y*12345)); // add some chaotic jitter to X sample pos according to Y to disguise the snapping going on here
float cs = shadow2DRect(shadowMap, stc.xyz).x;
float shadow = cs;

View File

@ -88,20 +88,11 @@ float pcfShadow(sampler2DRectShadow shadowMap, vec4 stc, float scl, vec2 pos_scr
stc.xyz /= stc.w;
stc.z += shadow_bias*scl;
////stc.x = floor(stc.x + fract(stc.y*12345));
//stc.x = floor(stc.x + fract(stc.y));
stc.x = floor(stc.x + fract(pos_screen.y*0.666666666));
//stc.x = floor(stc.x);
//stc.y = floor(stc.y);
//stc.x += 0.5;
stc.x = floor(stc.x + fract(pos_screen.y*0.666666666)); // add some jitter to X sample pos according to Y to disguise the snapping going on here
float cs = shadow2DRect(shadowMap, stc.xyz).x;
float shadow = cs;
//return shadow;
shadow += mex(shadow2DRect(shadowMap, stc.xyz+vec3(2.0, 1.5, 0.0)).x,cs);
shadow += mex(shadow2DRect(shadowMap, stc.xyz+vec3(1.0, -1.5, 0.0)).x,cs);
shadow += mex(shadow2DRect(shadowMap, stc.xyz+vec3(-2.0, 1.5, 0.0)).x,cs);

View File

@ -425,8 +425,6 @@ LLPipeline::LLPipeline() :
mLightingDetail(0),
mScreenWidth(0),
mScreenHeight(0)
// mSunShadowMapWidth(0),
// mSpotShadowMapWidth(0)
{
mNoiseMap = 0;
mTrueNoiseMap = 0;
@ -851,10 +849,10 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples)
if (shadow_detail > 0)
{ //allocate 4 sun shadow maps
U32 mSunShadowMapWidth = ((U32(resX*scale)+1)&~1); // must be even to avoid a stripe in the horizontal shadow blur
U32 sun_shadow_map_width = ((U32(resX*scale)+1)&~1); // must be even to avoid a stripe in the horizontal shadow blur
for (U32 i = 0; i < 4; i++)
{
if (!mShadow[i].allocate(mSunShadowMapWidth,U32(resY*scale), 0, TRUE, FALSE, LLTexUnit::TT_RECT_TEXTURE)) return false;
if (!mShadow[i].allocate(sun_shadow_map_width,U32(resY*scale), 0, TRUE, FALSE, LLTexUnit::TT_RECT_TEXTURE)) return false;
}
}
else
@ -863,7 +861,6 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples)
{
mShadow[i].release();
}
//mSunShadowMapWidth = 0;
}
U32 width = nhpo2(U32(resX*scale))/2;
@ -871,10 +868,10 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples)
if (shadow_detail > 1)
{ //allocate two spot shadow maps
U32 mSpotShadowMapWidth = width;
U32 spot_shadow_map_width = width;
for (U32 i = 4; i < 6; i++)
{
if (!mShadow[i].allocate(mSpotShadowMapWidth, height, 0, TRUE, FALSE)) return false;
if (!mShadow[i].allocate(spot_shadow_map_width, height, 0, TRUE, FALSE)) return false;
}
}
else
@ -883,7 +880,6 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples)
{
mShadow[i].release();
}
//mSpotShadowMapWidth = 0;
}
// don't disable shaders on next session
@ -8394,7 +8390,6 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera
gDeferredShadowAlphaMaskProgram.bind();
gDeferredShadowAlphaMaskProgram.setMinimumAlpha(0.598f);
gDeferredShadowAlphaMaskProgram.uniform1f(LLShaderMgr::DEFERRED_SHADOW_TARGET_WIDTH, (float)target_width);
// llwarns << "target_width is " << target_width << llendl;
U32 mask = LLVertexBuffer::MAP_VERTEX |
LLVertexBuffer::MAP_TEXCOORD0 |