molstar
molstar copied to clipboard
Unused variables in postprocessing fragment
It seems there are unused variables and uniforms inside getOutline
funciton in postprocessing.frag
.
I tested outlines behavior with the commented out lines and everything seems to work fine (on opaque and transparent objects).
//uniform sampler2D tDepthTransparent;
...
...
...
/* float getDepthTransparent(const in vec2 coords) {
#ifdef dTransparentOutline
return unpackRGBAToDepth(texture2D(tDepthTransparent, coords));
#else
return 1.0;
#endif
}*/
bool isBackground(const in float depth) {
return depth == 1.0;
}
float getOutline(const in vec2 coords, const in float opaqueDepth, out float closestTexel) {
float backgroundViewZ = 2.0 * uFar;
vec2 invTexSize = 1.0 / uTexSize;
//float transparentDepth = getDepthTransparent(coords);
//float opaqueSelfViewZ = isBackground(opaqueDepth) ? backgroundViewZ : getViewZ(opaqueDepth);
//float transparentSelfViewZ = isBackground(transparentDepth) ? backgroundViewZ : getViewZ(transparentDepth);
//float selfDepth = min(opaqueDepth, transparentDepth);
float outline = 1.0;
closestTexel = 1.0;
for (int y = -dOutlineScale; y <= dOutlineScale; y++) {
for (int x = -dOutlineScale; x <= dOutlineScale; x++) {
if (x * x + y * y > dOutlineScale * dOutlineScale) {
continue;
}
vec2 sampleCoords = coords + vec2(float(x), float(y)) * invTexSize;
vec4 sampleOutlineCombined = texture2D(tOutlines, sampleCoords);
float sampleOutline = sampleOutlineCombined.r;
float sampleOutlineDepth = unpackRGToUnitInterval(sampleOutlineCombined.gb);
//float sampleOutlineViewZ = isBackground(sampleOutlineDepth) ? backgroundViewZ : getViewZ(sampleOutlineDepth);
//float selfViewZ = sampleOutlineCombined.a == 0.0 ? opaqueSelfViewZ : transparentSelfViewZ;
if (sampleOutline == 0.0 && sampleOutlineDepth < closestTexel) {
outline = 0.0;
closestTexel = sampleOutlineDepth;
}
}
}
return closestTexel < opaqueDepth ? outline : 1.0;
}