This commit is contained in:
luboslenco 2019-05-30 20:22:57 +02:00
parent ae0fa5da1e
commit 00237fdd42
3 changed files with 26 additions and 13 deletions

View file

@ -299,12 +299,10 @@ void main() {
#endif
#ifdef _SSRS
float tvis = traceShadowSS(-sunDir, p, gbufferD, invVP, eye);
// vec2 coords = getProjectedCoord(hitCoord);
// vec2 deltaCoords = abs(vec2(0.5, 0.5) - coords.xy);
// float screenEdgeFactor = clamp(1.0 - (deltaCoords.x + deltaCoords.y), 0.0, 1.0);
// tvis *= screenEdgeFactor;
svisibility *= tvis;
svisibility *= traceShadowSS(sunDir, p, gbufferD, invVP, eye);
#endif
#ifdef _LightClouds
@ -357,6 +355,9 @@ void main() {
#ifdef _MicroShadowing
, occspec.x
#endif
#ifdef _SSRS
, gbufferD, invVP, eye
#endif
);
#ifdef _Spot
@ -406,6 +407,9 @@ void main() {
#ifdef _MicroShadowing
, occspec.x
#endif
#ifdef _SSRS
, gbufferD, invVP, eye
#endif
);
}
#endif // _Clusters

View file

@ -16,6 +16,9 @@
#ifdef _LightIES
#include "std/ies.glsl"
#endif
#ifdef _SSRS
#include "std/ssrs.glsl"
#endif
#ifdef _ShadowMap
#ifdef _SinglePoint
@ -80,6 +83,9 @@ vec3 sampleLight(const vec3 p, const vec3 n, const vec3 v, const float dotNV, co
#ifdef _MicroShadowing
, float occ
#endif
#ifdef _SSRS
, sampler2D gbufferD, mat4 invVP, vec3 eye
#endif
) {
vec3 ld = lp - p;
vec3 l = normalize(ld);
@ -112,6 +118,10 @@ vec3 sampleLight(const vec3 p, const vec3 n, const vec3 v, const float dotNV, co
direct *= dotNL + 2.0 * occ * occ - 1.0;
#endif
#ifdef _SSRS
direct *= traceShadowSS(l, p, gbufferD, invVP, eye);
#endif
#ifdef _VoxelAOvar
#ifdef _VoxelShadow
direct *= 1.0 - traceShadow(voxels, voxpos, l);

View file

@ -1,3 +1,6 @@
#ifndef _SSRS_GLSL_
#define _SSRS_GLSL_
#include "std/gbuffer.glsl"
uniform mat4 VP;
@ -23,15 +26,11 @@ float getDeltaDepth(vec3 hitCoord, sampler2D gbufferD, mat4 invVP, vec3 eye) {
float traceShadowSS(vec3 dir, vec3 hitCoord, sampler2D gbufferD, mat4 invVP, vec3 eye) {
dir *= ssrsRayStep;
// for (int i = 0; i < maxSteps; i++) {
for (int i = 0; i < 4; i++) {
hitCoord += dir;
if (getDeltaDepth(hitCoord, gbufferD, invVP, eye) > 0.0) return 0.6;
hitCoord += dir;
if (getDeltaDepth(hitCoord, gbufferD, invVP, eye) > 0.0) return 0.7;
hitCoord += dir;
if (getDeltaDepth(hitCoord, gbufferD, invVP, eye) > 0.0) return 0.8;
hitCoord += dir;
if (getDeltaDepth(hitCoord, gbufferD, invVP, eye) > 0.0) return 0.9;
//}
return 1.0;
if (getDeltaDepth(hitCoord, gbufferD, invVP, eye) > 0.0) return 1.0;
}
return 0.0;
}
#endif