Jump to content
  • Advertisement
Sign in to follow this  
562538332

OpenGL Cracks appear when using MipMap for variance shadow map to filter csm

This topic is 1512 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I use OpenGL to implement a PSVSM,for a better filter,I use MipMap for the variance map.
 
 glGenTextures(1,&VarTex); 
   glBindTexture(GL_TEXTURE_2D_ARRAY,VarTex);
     glTexImage3D(GL_TEXTURE_2D_ARRAY, 0,GL_RG32F,Resolution,Resolution,nSplits, 0,GL_RG, GL_FLOAT, 0);    
     glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
     glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); 
     glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
     glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
     glTexParameterfv(GL_TEXTURE_2D_ARRAY,GL_TEXTURE_BORDER_COLOR,borderColor); 
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT,16);
 
I use glGenerateMipmap(GL_TEXTURE_2D_ARRAY); to generate the MipMap
[attachment=24354:map.JPG]
As you can see in the attach files,Cracks appear between each split frustum.But it only appears when i use MipMap.
 
I very want to know why it happen while using the MipMap.More importantly,HOW TO SOLVE IT!
 
This is the code of the shader:

#version 330
layout(location=0) out vec2 FragColor;
void main()
{float dep=gl_FragCoord.z;
 FragColor.x=dep;
 FragColor.y=dep*dep;
 }
 
///////////////////////////////////////////////////////////////////////////

#version 330 core
#extension GL_EXT_texture_array:enable
layout(location = 0) out vec3 FragColor;
 
uniform mat4 BMVP[8];
uniform float dis[8];
uniform int nSplits; 
 
in VS_OUT
{float factor;
 vec4 V_WORLD; 
}fs_in;
 
 
uniform sampler2DArray VarMap;
 
float UppderBound(vec2 Moments,float t)
{if(t<=Moments.x)return 1.0;
 float var=Moments.y-(Moments.x*Moments.x);
 var=max(var,0.0002);
 float d=t-Moments.x;
 return var/(var+d*d);
 }
 
void main()
{float offset=-0.00001;
 vec4 texCoord;  
 int index=nSplits-1;
 for(int i=0;i<nSplits;i++)
 if(gl_FragCoord.z<dis){index=i;break;}
 texCoord=BMVP[index]*fs_in.V_WORLD; 
 vec2 uvs=texCoord.xy/texCoord.w;
 float z=texCoord.z/texCoord.w;
 
 
 
 FragColor=vec3(
 UppderBound(
  texture2DArray(VarMap,vec3(uvs,index)).rg
  ,z+offset));
 
 }
Edited by 562538332

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!