how would on use nvidia hw pcf?
also im unsure how i would use a regular depthmap for shadowmaps… right now i simply convert the depth to fit a rgba8 texture liek this…
//FBO
size = 2048.0;
GLint type = GL_RGBA8;
glActiveTexture(GL_TEXTURE10);
// Setup our FBO
glGenFramebuffersEXT(1, &fbo);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo);
// Create the render buffer for depth
glGenRenderbuffersEXT(1, &depthBuffer);
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, depthBuffer);
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT, size, size);
// Now setup a texture to render to
glGenTextures(1, &img);
glBindTexture(GL_TEXTURE_2D, img);
glTexImage2D(GL_TEXTURE_2D, 0, type, size, size, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
// And attach it to the FBO so we can render to it
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, img, 0);
// Attach the depth render buffer to the FBO as it's depth attachment
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, depthBuffer);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); // Unbind the FBO for now
GLenum status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
/// WRITE TO SHADOWMAP
// FRAGMENT
varying float Depth;
void main()
{
const vec4 bitSh = vec4( 256*256*256, 256*256, 256, 1);
const vec4 bitMsk = vec4( 0, 1.0/256.0, 1.0/256.0, 1.0/256.0);
float dist = Depth;
vec4 comp;
comp=dist*bitSh;
comp=fract(comp);
comp-=comp.xxyz*bitMsk;
gl_FragColor= vec4(comp);
}
// CALCULATE SHADOWS
// FRAGMENT
varying vec4 ProjShadow;
varying float Depth;
uniform sampler2D Shadow;
const vec4 bitShifts = vec4(1.0/(256.0*256.0*256.0),1.0/(256.0*256.0), 1.0/256.0, 1);
float GetShadow(vec2 TexCoord)
{
vec4 shadmap = texture2D(Shadow,TexCoord);
float shad = dot(shadmap , bitShifts);
return (shad < Depth+0.0065);
}
i dont think is the best way to do it… but as i said im unsure how to write to a 32bit depthmap and use HW pcf