Browse Source

阴影优化

master
blobt 4 years ago
parent
commit
8dde39a9dc
  1. BIN
      .vs/shader3/v14/.suo
  2. 11
      res/shader/hdr.fs

BIN
.vs/shader3/v14/.suo

11
res/shader/hdr.fs

@ -22,7 +22,16 @@ float CalculateShadow(){
float depthInShadowMap = texture2D(U_ShadowMap, fragPos.xy).r; float depthInShadowMap = texture2D(U_ShadowMap, fragPos.xy).r;
float currentDepth = fragPos.z; float currentDepth = fragPos.z;
float shadow = currentDepth > depthInShadowMap ? 1.0 : 0.0;
vec2 texelSize = 1.0/textureSize(U_ShadowMap, 0);
float shadow = 0;
for(int y = -1; y < 1; ++y){
for(int x = -1; x < 1; ++x){
float pcfDepth = texture2D(U_ShadowMap, fragPos.xy + texelSize * vec2(x,y)).r;
shadow += (currentDepth-0.05) > pcfDepth ? 1.0 : 0.0;
}
}
shadow/=9.0;
return shadow; return shadow;
} }

Loading…
Cancel
Save