i doing depth shadow mapping,and learning tutorial (http://www.ogre3d.org/tikiwiki/depth+shadow+mapping)
i have 3 questions following:
(1)is right when use custom shadow caster,i can depth in shadow receiver using "uniform sampler2d shadowmap "?
void castervp( out float2 outdepth : texcoord0) { outpos = mul(worldviewproj, position); outdepth.x = (outpos.z - depthrange.x) * depthrange.w; } void casterfp( float2 depth : texcoord0, out float4 result : color) { result = float4(finaldepth, finaldepth, finaldepth, 1); } //shadow receiver fragment program void receiverfp(uniform sampler2d shadowmap : register( s0 )) { } (2) not sure matrix(texture_viewproj_matrix) used for.
i guess,
texture coordinate->camera coordinate->screen coordinate??
and texture coordinates should 2-d. right?
(3) in shadow receiver fragment shader,i don't know line mean. and,do these 3 variable(finalcenterdepth,shadowuv.z , vertexcolour) stand depth?
result = (finalcenterdepth > shadowuv.z) ? vertexcolour : float4(0,0,0,1); thank you~ advice useful newbie :d
(1) not sure if understood question correctly. if wrote depth render target can read associated texture.
(2) texture_viewproj_matrix transforms world space light's screen space , rescales resulting xy [-1;1] [0;1]. in xy/w shadow map uv coordinates of receiver , in z - shadow map depth of receiver.
(3) finalcenterdepth - depth read shadow map , adjusted depth bias in order fix acne artifacts. shadowuv.z - depth of receiver adjusted depth bias. vertexcolour - lit color, calculated in vertex shader (see outcolour in receivervp).
Comments
Post a Comment