|
@@ -53,6 +53,16 @@ bool CylinderImpostor(
|
|
bool topCap = (vCap > 0.9 && vCap < 1.1) || vCap >= 2.9;
|
|
bool topCap = (vCap > 0.9 && vCap < 1.1) || vCap >= 2.9;
|
|
bool bottomCap = (vCap > 1.9 && vCap < 2.1) || vCap >= 2.9;
|
|
bool bottomCap = (vCap > 1.9 && vCap < 2.1) || vCap >= 2.9;
|
|
|
|
|
|
|
|
+ #ifdef dSolidInterior
|
|
|
|
+ bool topInterior = !topCap;
|
|
|
|
+ bool bottomInterior = !bottomCap;
|
|
|
|
+ topCap = true;
|
|
|
|
+ bottomCap = true;
|
|
|
|
+ #else
|
|
|
|
+ bool topInterior = false;
|
|
|
|
+ bool bottomInterior = false;
|
|
|
|
+ #endif
|
|
|
|
+
|
|
// body outside
|
|
// body outside
|
|
h = sqrt(h);
|
|
h = sqrt(h);
|
|
float t = (-k1 - h) / k2;
|
|
float t = (-k1 - h) / k2;
|
|
@@ -73,18 +83,18 @@ bool CylinderImpostor(
|
|
// top cap
|
|
// top cap
|
|
t = -baoc / bard;
|
|
t = -baoc / bard;
|
|
if (abs(k1 + k2 * t) < h) {
|
|
if (abs(k1 + k2 * t) < h) {
|
|
- interior = false;
|
|
|
|
|
|
+ interior = topInterior;
|
|
cameraNormal = -ba / baba;
|
|
cameraNormal = -ba / baba;
|
|
modelPosition = rayOrigin + t * rayDir;
|
|
modelPosition = rayOrigin + t * rayDir;
|
|
viewPosition = (uView * vec4(modelPosition, 1.0)).xyz;
|
|
viewPosition = (uView * vec4(modelPosition, 1.0)).xyz;
|
|
fragmentDepth = calcDepth(viewPosition);
|
|
fragmentDepth = calcDepth(viewPosition);
|
|
if (fragmentDepth > 0.0) return true;
|
|
if (fragmentDepth > 0.0) return true;
|
|
}
|
|
}
|
|
- } else if(bottomCap && y >= 0.0) {
|
|
|
|
|
|
+ } else if (bottomCap && y >= 0.0) {
|
|
// bottom cap
|
|
// bottom cap
|
|
t = (baba - baoc) / bard;
|
|
t = (baba - baoc) / bard;
|
|
if (abs(k1 + k2 * t) < h) {
|
|
if (abs(k1 + k2 * t) < h) {
|
|
- interior = false;
|
|
|
|
|
|
+ interior = bottomInterior;
|
|
cameraNormal = ba / baba;
|
|
cameraNormal = ba / baba;
|
|
modelPosition = rayOrigin + t * rayDir;
|
|
modelPosition = rayOrigin + t * rayDir;
|
|
viewPosition = (uView * vec4(modelPosition, 1.0)).xyz;
|
|
viewPosition = (uView * vec4(modelPosition, 1.0)).xyz;
|
|
@@ -104,7 +114,13 @@ bool CylinderImpostor(
|
|
modelPosition = rayOrigin + t * rayDir;
|
|
modelPosition = rayOrigin + t * rayDir;
|
|
viewPosition = (uView * vec4(modelPosition, 1.0)).xyz;
|
|
viewPosition = (uView * vec4(modelPosition, 1.0)).xyz;
|
|
fragmentDepth = calcDepth(viewPosition);
|
|
fragmentDepth = calcDepth(viewPosition);
|
|
- return true;
|
|
|
|
|
|
+ if (fragmentDepth > 0.0) {
|
|
|
|
+ #ifdef dSolidInterior
|
|
|
|
+ fragmentDepth = 0.0 + (0.0000001 / vSize);
|
|
|
|
+ cameraNormal = -rayDir;
|
|
|
|
+ #endif
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
if (topCap && y < 0.0) {
|
|
if (topCap && y < 0.0) {
|
|
@@ -116,9 +132,15 @@ bool CylinderImpostor(
|
|
modelPosition = rayOrigin + t * rayDir;
|
|
modelPosition = rayOrigin + t * rayDir;
|
|
viewPosition = (uView * vec4(modelPosition, 1.0)).xyz;
|
|
viewPosition = (uView * vec4(modelPosition, 1.0)).xyz;
|
|
fragmentDepth = calcDepth(viewPosition);
|
|
fragmentDepth = calcDepth(viewPosition);
|
|
- if (fragmentDepth > 0.0) return true;
|
|
|
|
|
|
+ if (fragmentDepth > 0.0) {
|
|
|
|
+ #ifdef dSolidInterior
|
|
|
|
+ fragmentDepth = 0.0 + (0.0000001 / vSize);
|
|
|
|
+ cameraNormal = -rayDir;
|
|
|
|
+ #endif
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- } else if(bottomCap && y >= 0.0) {
|
|
|
|
|
|
+ } else if (bottomCap && y >= 0.0) {
|
|
// bottom cap
|
|
// bottom cap
|
|
t = (baba - baoc) / bard;
|
|
t = (baba - baoc) / bard;
|
|
if (abs(k1 + k2 * t) < -h) {
|
|
if (abs(k1 + k2 * t) < -h) {
|
|
@@ -127,7 +149,13 @@ bool CylinderImpostor(
|
|
modelPosition = rayOrigin + t * rayDir;
|
|
modelPosition = rayOrigin + t * rayDir;
|
|
viewPosition = (uView * vec4(modelPosition, 1.0)).xyz;
|
|
viewPosition = (uView * vec4(modelPosition, 1.0)).xyz;
|
|
fragmentDepth = calcDepth(viewPosition);
|
|
fragmentDepth = calcDepth(viewPosition);
|
|
- if (fragmentDepth > 0.0) return true;
|
|
|
|
|
|
+ if (fragmentDepth > 0.0) {
|
|
|
|
+ #ifdef dSolidInterior
|
|
|
|
+ fragmentDepth = 0.0 + (0.0000001 / vSize);
|
|
|
|
+ cameraNormal = -rayDir;
|
|
|
|
+ #endif
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|