diff --git a/src/viewer/scene/model/dtx/triangles/renderers/DTXTrianglesColorRenderer.js b/src/viewer/scene/model/dtx/triangles/renderers/DTXTrianglesColorRenderer.js index d250bb40f..80abe18fa 100644 --- a/src/viewer/scene/model/dtx/triangles/renderers/DTXTrianglesColorRenderer.js +++ b/src/viewer/scene/model/dtx/triangles/renderers/DTXTrianglesColorRenderer.js @@ -110,6 +110,10 @@ export class DTXTrianglesColorRenderer { const sectionPlanes = scene._sectionPlanesState.sectionPlanes; const baseIndex = dataTextureLayer.layerIndex * numSectionPlanes; const renderFlags = model.renderFlags; + if (scene.crossSections) { + gl.uniform4fv(this._uSliceColor, scene.crossSections.sliceColor); + gl.uniform1f(this._uSliceThickness, scene.crossSections.sliceThickness); + } for (let sectionPlaneIndex = 0; sectionPlaneIndex < numAllocatedSectionPlanes; sectionPlaneIndex++) { const sectionPlaneUniforms = this._uSectionPlanes[sectionPlaneIndex]; if (sectionPlaneUniforms) { @@ -247,6 +251,11 @@ export class DTXTrianglesColorRenderer { this._uTexturePerPolygonIdPortionIds = "uTexturePerPolygonIdPortionIds"; this._uTexturePerObjectMatrix= "uTexturePerObjectMatrix"; this._uCameraEyeRtc = program.getLocation("uCameraEyeRtc"); + + if (scene.crossSections) { + this._uSliceColor = program.getLocation("sliceColor"); + this._uSliceThickness = program.getLocation("sliceThickness"); + } } _bindProgram(frameCtx) { @@ -563,11 +572,14 @@ export class DTXTrianglesColorRenderer { src.push("uniform vec3 sectionPlanePos" + i + ";"); src.push("uniform vec3 sectionPlaneDir" + i + ";"); } + src.push("uniform float sliceThickness;"); + src.push("uniform vec4 sliceColor;"); } src.push("in vec4 vColor;"); src.push("out vec4 outColor;"); src.push("void main(void) {"); - + src.push(" vec4 newColor;"); + src.push(" newColor = vColor;"); if (clipping) { src.push(" bool clippable = vFlags2 > 0u;"); src.push(" if (clippable) {"); @@ -577,9 +589,12 @@ export class DTXTrianglesColorRenderer { src.push(" dist += clamp(dot(-sectionPlaneDir" + i + ".xyz, vWorldPosition.xyz - sectionPlanePos" + i + ".xyz), 0.0, 1000.0);"); src.push("}"); } - src.push(" if (dist > 0.0) { "); + src.push(" if (dist > sliceThickness) { "); src.push(" discard;") src.push(" }"); + src.push(" if (dist > 0.0) { "); + src.push(" newColor = sliceColor;"); + src.push(" }"); src.push("}"); } @@ -597,9 +612,9 @@ export class DTXTrianglesColorRenderer { src.push(" float blendFactor = uSAOParams[3];"); src.push(" vec2 uv = vec2(gl_FragCoord.x / viewportWidth, gl_FragCoord.y / viewportHeight);"); src.push(" float ambient = smoothstep(blendCutoff, 1.0, unpackRGBToFloat(texture(uOcclusionTexture, uv))) * blendFactor;"); - src.push(" outColor = vec4(vColor.rgb * ambient, 1.0);"); + src.push(" outColor = vec4(newColor.rgb * ambient, 1.0);"); } else { - src.push(" outColor = vColor;"); + src.push(" outColor = newColor;"); } src.push("}"); diff --git a/src/viewer/scene/model/dtx/triangles/renderers/DTXTrianglesEdgesColorRenderer.js b/src/viewer/scene/model/dtx/triangles/renderers/DTXTrianglesEdgesColorRenderer.js index b7b63354f..9d921bcbe 100644 --- a/src/viewer/scene/model/dtx/triangles/renderers/DTXTrianglesEdgesColorRenderer.js +++ b/src/viewer/scene/model/dtx/triangles/renderers/DTXTrianglesEdgesColorRenderer.js @@ -377,10 +377,14 @@ export class DTXTrianglesEdgesColorRenderer { src.push("uniform vec3 sectionPlanePos" + i + ";"); src.push("uniform vec3 sectionPlaneDir" + i + ";"); } + src.push("uniform float sliceThickness;"); + src.push("uniform vec4 sliceColor;"); } src.push("in vec4 vColor;"); src.push("out vec4 outColor;"); src.push("void main(void) {"); + src.push(" vec4 newColor;"); + src.push(" newColor = vColor;"); if (clipping) { src.push(" bool clippable = vFlags2 > 0u;"); src.push(" if (clippable) {"); @@ -390,13 +394,18 @@ export class DTXTrianglesEdgesColorRenderer { src.push(" dist += clamp(dot(-sectionPlaneDir" + i + ".xyz, vWorldPosition.xyz - sectionPlanePos" + i + ".xyz), 0.0, 1000.0);"); src.push("}"); } - src.push(" if (dist > 0.0) { discard; }"); + src.push(" if (dist > sliceThickness) { "); + src.push(" discard;") + src.push(" }"); + src.push(" if (dist > 0.0) { "); + src.push(" newColor = sliceColor;"); + src.push(" }"); src.push("}"); } if (scene.logarithmicDepthBufferEnabled) { src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;"); } - src.push(" outColor = vColor;"); + src.push(" outColor = newColor;"); src.push("}"); return src; } diff --git a/src/viewer/scene/model/dtx/triangles/renderers/DTXTrianglesEdgesRenderer.js b/src/viewer/scene/model/dtx/triangles/renderers/DTXTrianglesEdgesRenderer.js index 05bd9857b..0ef830e27 100644 --- a/src/viewer/scene/model/dtx/triangles/renderers/DTXTrianglesEdgesRenderer.js +++ b/src/viewer/scene/model/dtx/triangles/renderers/DTXTrianglesEdgesRenderer.js @@ -385,10 +385,14 @@ export class DTXTrianglesEdgesRenderer { src.push("uniform vec3 sectionPlanePos" + i + ";"); src.push("uniform vec3 sectionPlaneDir" + i + ";"); } + src.push("uniform float sliceThickness;"); + src.push("uniform vec4 sliceColor;"); } src.push("in vec4 vColor;"); src.push("out vec4 outColor;"); src.push("void main(void) {"); + src.push(" vec4 newColor;"); + src.push(" newColor = vColor;"); if (clipping) { src.push(" bool clippable = vFlags2 > 0u;"); src.push(" if (clippable) {"); @@ -398,13 +402,18 @@ export class DTXTrianglesEdgesRenderer { src.push(" dist += clamp(dot(-sectionPlaneDir" + i + ".xyz, vWorldPosition.xyz - sectionPlanePos" + i + ".xyz), 0.0, 1000.0);"); src.push("}"); } - src.push(" if (dist > 0.0) { discard; }"); + src.push(" if (dist > sliceThickness) { "); + src.push(" discard;") + src.push(" }"); + src.push(" if (dist > 0.0) { "); + src.push(" newColor = sliceColor;"); + src.push(" }"); src.push("}"); } if (scene.logarithmicDepthBufferEnabled) { src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;"); } - src.push(" outColor = vColor;"); + src.push(" outColor = newColor;"); src.push("}"); return src; } diff --git a/src/viewer/scene/model/dtx/triangles/renderers/DTXTrianglesSilhouetteRenderer.js b/src/viewer/scene/model/dtx/triangles/renderers/DTXTrianglesSilhouetteRenderer.js index 5b0a180c4..4a62fdef9 100644 --- a/src/viewer/scene/model/dtx/triangles/renderers/DTXTrianglesSilhouetteRenderer.js +++ b/src/viewer/scene/model/dtx/triangles/renderers/DTXTrianglesSilhouetteRenderer.js @@ -426,10 +426,14 @@ export class DTXTrianglesSilhouetteRenderer { src.push("uniform vec3 sectionPlanePos" + i + ";"); src.push("uniform vec3 sectionPlaneDir" + i + ";"); } + src.push("uniform float sliceThickness;"); + src.push("uniform vec4 sliceColor;"); } src.push("uniform vec4 color;"); src.push("out vec4 outColor;"); src.push("void main(void) {"); + src.push(" vec4 newColor;"); + src.push(" newColor = color;"); if (clipping) { src.push(" bool clippable = vFlags2 > 0u;"); src.push(" if (clippable) {"); @@ -439,15 +443,18 @@ export class DTXTrianglesSilhouetteRenderer { src.push(" dist += clamp(dot(-sectionPlaneDir" + i + ".xyz, vWorldPosition.xyz - sectionPlanePos" + i + ".xyz), 0.0, 1000.0);"); src.push("}"); } - src.push(" if (dist > 0.0) { "); + src.push(" if (dist > sliceThickness) { "); src.push(" discard;") src.push(" }"); + src.push(" if (dist > 0.0) { "); + src.push(" newColor = sliceColor;"); + src.push(" }"); src.push("}"); } if (scene.logarithmicDepthBufferEnabled) { src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;"); } - src.push(" outColor = color;"); + src.push(" outColor = newColor;"); src.push("}"); return src; }