mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-07-23 06:44:10 +02:00
exploring how to to expose occluded/unoccluded outline styles
This commit is contained in:
parent
c1dfa24c12
commit
fcb3cee092
1 changed files with 26 additions and 3 deletions
|
@ -39,6 +39,7 @@ void main(void) {
|
||||||
vec2 texCoord0 = varTexCoord0+halfTexel;
|
vec2 texCoord0 = varTexCoord0+halfTexel;
|
||||||
float outlinedDepth = texture(outlinedDepthMap, texCoord0).x;
|
float outlinedDepth = texture(outlinedDepthMap, texCoord0).x;
|
||||||
float intensity = 0.0;
|
float intensity = 0.0;
|
||||||
|
float isOccluded = 0.0;
|
||||||
|
|
||||||
if (outlinedDepth < FAR_Z) {
|
if (outlinedDepth < FAR_Z) {
|
||||||
// We're not on the far plane so we are on the outlined object, thus no outline to do!
|
// We're not on the far plane so we are on the outlined object, thus no outline to do!
|
||||||
|
@ -52,6 +53,7 @@ void main(void) {
|
||||||
// Are we occluded?
|
// Are we occluded?
|
||||||
if (sceneDepth < (outlinedDepth-LINEAR_DEPTH_BIAS)) {
|
if (sceneDepth < (outlinedDepth-LINEAR_DEPTH_BIAS)) {
|
||||||
intensity = params._fillOpacityOccluded;
|
intensity = params._fillOpacityOccluded;
|
||||||
|
isOccluded = 1.0;
|
||||||
} else {
|
} else {
|
||||||
intensity = params._fillOpacityUnoccluded;
|
intensity = params._fillOpacityUnoccluded;
|
||||||
}
|
}
|
||||||
|
@ -66,6 +68,8 @@ void main(void) {
|
||||||
int x;
|
int x;
|
||||||
int y;
|
int y;
|
||||||
|
|
||||||
|
float sumOutlineDepth = 0;
|
||||||
|
|
||||||
for (y=0 ; y<params._blurKernelSize ; y++) {
|
for (y=0 ; y<params._blurKernelSize ; y++) {
|
||||||
uv = lineStartUv;
|
uv = lineStartUv;
|
||||||
lineStartUv.y += deltaUv.y;
|
lineStartUv.y += deltaUv.y;
|
||||||
|
@ -75,7 +79,10 @@ void main(void) {
|
||||||
if (uv.x>=0.0 && uv.x<=1.0)
|
if (uv.x>=0.0 && uv.x<=1.0)
|
||||||
{
|
{
|
||||||
outlinedDepth = texture(outlinedDepthMap, uv).x;
|
outlinedDepth = texture(outlinedDepthMap, uv).x;
|
||||||
intensity += (outlinedDepth < FAR_Z) ? 1.0 : 0.0;
|
float touch = (outlinedDepth < FAR_Z) ? 1.0 : 0.0;
|
||||||
|
//sumOutlineDepth = min(outlinedDepth, sumOutlineDepth);
|
||||||
|
sumOutlineDepth += (outlinedDepth * touch);
|
||||||
|
intensity += touch;
|
||||||
weight += 1.f;
|
weight += 1.f;
|
||||||
}
|
}
|
||||||
uv.x += deltaUv.x;
|
uv.x += deltaUv.x;
|
||||||
|
@ -83,15 +90,31 @@ void main(void) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (intensity > 0) {
|
||||||
|
sumOutlineDepth /= intensity;
|
||||||
|
} else {
|
||||||
|
sumOutlineDepth = FAR_Z;
|
||||||
|
}
|
||||||
|
|
||||||
intensity /= weight;
|
intensity /= weight;
|
||||||
if (intensity < OPACITY_EPSILON) {
|
if (intensity < OPACITY_EPSILON) {
|
||||||
discard;
|
discard;
|
||||||
}
|
}
|
||||||
|
|
||||||
intensity = min(1.0, intensity / params._threshold) * params._intensity;
|
intensity = min(1.0, intensity / params._threshold) * params._intensity;
|
||||||
|
|
||||||
|
// But we need to check the scene depth aginst the depth of the outline
|
||||||
|
float sceneDepth = texture(sceneDepthMap, texCoord0).x;
|
||||||
|
|
||||||
|
// Transform to linear depth for better precision
|
||||||
|
outlinedDepth = -evalZeyeFromZdb(sumOutlineDepth);
|
||||||
|
sceneDepth = -evalZeyeFromZdb(sceneDepth);
|
||||||
|
// Are we occluded?
|
||||||
|
if (sceneDepth < (outlinedDepth/*-LINEAR_DEPTH_BIAS*/)) {
|
||||||
|
isOccluded = 1.0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
outFragColor = vec4(params._color.rgb, intensity);
|
outFragColor = vec4(mix(params._color.rgb, vec3(0.1,1,0.1), isOccluded), intensity);
|
||||||
}
|
}
|
||||||
|
|
||||||
<@endfunc@>
|
<@endfunc@>
|
||||||
|
|
Loading…
Reference in a new issue