mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 19:36:45 +02:00
Removed falloff distance from shader
This commit is contained in:
parent
acab748f57
commit
ad5064b045
4 changed files with 10 additions and 11 deletions
|
@ -79,7 +79,7 @@ public:
|
||||||
|
|
||||||
void setRadius(float newRadius) { radius = std::max(0.01f, newRadius); emit dirty(); }
|
void setRadius(float newRadius) { radius = std::max(0.01f, newRadius); emit dirty(); }
|
||||||
void setObscuranceLevel(float level) { obscuranceLevel = std::max(0.01f, level); emit dirty(); }
|
void setObscuranceLevel(float level) { obscuranceLevel = std::max(0.01f, level); emit dirty(); }
|
||||||
void setFalloffAngle(float bias) { falloffAngle = std::max(0.0f, std::min(bias, 0.2f)); emit dirty(); }
|
void setFalloffAngle(float bias) { falloffAngle = std::max(0.0f, std::min(bias, 1.0f)); emit dirty(); }
|
||||||
void setFalloffDistance(float value) { falloffDistance = std::max(0.0f, value); emit dirty(); }
|
void setFalloffDistance(float value) { falloffDistance = std::max(0.0f, value); emit dirty(); }
|
||||||
void setEdgeSharpness(float sharpness) { edgeSharpness = std::max(0.0f, (float)sharpness); emit dirty(); }
|
void setEdgeSharpness(float sharpness) { edgeSharpness = std::max(0.0f, (float)sharpness); emit dirty(); }
|
||||||
void setBlurDeviation(float deviation) { blurDeviation = std::max(0.0f, deviation); emit dirty(); }
|
void setBlurDeviation(float deviation) { blurDeviation = std::max(0.0f, deviation); emit dirty(); }
|
||||||
|
|
|
@ -290,14 +290,14 @@ float evalVisibilitySSAO(in vec3 centerPosition, in vec3 centerNormal, in vec3 t
|
||||||
return f * f * f * max((vn - getFalloffAngle()) / (epsilon + vv), 0.0);
|
return f * f * f * max((vn - getFalloffAngle()) / (epsilon + vv), 0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
float computeHorizonFromTap(vec3 tapPositionES, vec3 fragPositionES, vec3 fragNormalES, float normalizedRadius) {
|
float computeHorizonFromTap(vec3 tapPositionES, vec3 fragPositionES, vec3 fragNormalES) {
|
||||||
vec3 deltaVec = tapPositionES - fragPositionES;
|
vec3 deltaVec = tapPositionES - fragPositionES;
|
||||||
float distance = abs(deltaVec.z);
|
float distanceSquared = dot(deltaVec, deltaVec);
|
||||||
float rawHorizon = dot(normalize(deltaVec), fragNormalES);
|
float rawHorizon = dot(normalize(deltaVec), fragNormalES);
|
||||||
|
float radiusFalloff = distanceSquared / getRadius2();
|
||||||
|
|
||||||
rawHorizon = (rawHorizon - getFalloffAngle()) / (1.0 - getFalloffAngle());
|
rawHorizon = max(0.0, (rawHorizon - getFalloffAngle()) / (1.0 - getFalloffAngle()));
|
||||||
rawHorizon *= 1.0 - normalizedRadius * normalizedRadius;
|
rawHorizon *= 1.0 - radiusFalloff;
|
||||||
rawHorizon *= 1.0 - smoothstep(getFalloffDistance()/2, getFalloffDistance(), distance);
|
|
||||||
|
|
||||||
return rawHorizon;
|
return rawHorizon;
|
||||||
}
|
}
|
||||||
|
@ -306,12 +306,12 @@ float computeHorizonFromTap(vec3 tapPositionES, vec3 fragPositionES, vec3 fragNo
|
||||||
vec3 tap = vec3(tapPixelPos, radius);
|
vec3 tap = vec3(tapPixelPos, radius);
|
||||||
vec4 tapUVZ_mip = fetchTap(side, centerPixelPos, tap, imageSize);
|
vec4 tapUVZ_mip = fetchTap(side, centerPixelPos, tap, imageSize);
|
||||||
vec3 tapPositionES = evalEyePositionFromZeye(side.x, tapUVZ_mip.z, tapUVZ_mip.xy);
|
vec3 tapPositionES = evalEyePositionFromZeye(side.x, tapUVZ_mip.z, tapUVZ_mip.xy);
|
||||||
float rawHorizon = computeHorizonFromTap(tapPositionES, fragPositionES, fragNormalES, radius / searchRadius);
|
float rawHorizon = computeHorizonFromTap(tapPositionES, fragPositionES, fragNormalES);
|
||||||
|
|
||||||
<$horizon$> = max(<$horizon$>, rawHorizon);
|
<$horizon$> = max(<$horizon$>, rawHorizon);
|
||||||
<@endfunc@>
|
<@endfunc@>
|
||||||
|
|
||||||
#define SSAO_LINEAR_SAMPLING 0
|
#define SSAO_LINEAR_SAMPLING 1
|
||||||
|
|
||||||
<@func updateHorizon(horizon, deltaPixelTap)@>
|
<@func updateHorizon(horizon, deltaPixelTap)@>
|
||||||
{
|
{
|
||||||
|
|
|
@ -69,8 +69,7 @@ void main(void) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
visibilitySum = visibilitySum * getInvNumSamples();
|
float occlusion = clamp(1.0 - visibilitySum * getObscuranceScaling() * getInvNumSamples(), 0.0, 1.0);
|
||||||
float occlusion = clamp(1.0 - visibilitySum * getObscuranceScaling(), 0.0, 1.0);
|
|
||||||
|
|
||||||
// KEEP IT for Debugging
|
// KEEP IT for Debugging
|
||||||
// Bilateral box-filter over a quad for free, respecting depth edges
|
// Bilateral box-filter over a quad for free, respecting depth edges
|
||||||
|
|
|
@ -37,7 +37,7 @@ Rectangle {
|
||||||
"Level:obscuranceLevel:1.0:false",
|
"Level:obscuranceLevel:1.0:false",
|
||||||
"Num Taps:numSamples:32:true",
|
"Num Taps:numSamples:32:true",
|
||||||
"Taps Spiral:numSpiralTurns:10.0:false",
|
"Taps Spiral:numSpiralTurns:10.0:false",
|
||||||
"Falloff Angle:falloffAngle:0.2:false",
|
"Falloff Angle:falloffAngle:0.5:false",
|
||||||
"Falloff Distance:falloffDistance:2.0:false",
|
"Falloff Distance:falloffDistance:2.0:false",
|
||||||
"Blur Edge Sharpness:edgeSharpness:1.0:false",
|
"Blur Edge Sharpness:edgeSharpness:1.0:false",
|
||||||
"Blur Radius:blurRadius:15.0:false",
|
"Blur Radius:blurRadius:15.0:false",
|
||||||
|
|
Loading…
Reference in a new issue