Fixed an issue with transparent materials and outlining. Fixed an issue with selecting objects and shadowmap. Added section planes update to the stencil and stencil mask passes

This commit is contained in:
AlexandruPopovici
2023-01-26 18:30:44 +02:00
parent cced51e2b8
commit ef7495a397
5 changed files with 34 additions and 4 deletions
+2 -2
View File
@@ -130,7 +130,7 @@ sandbox.makeBatchesUI()
await sandbox.loadUrl(
// 'https://speckle.xyz/streams/da9e320dad/commits/5388ef24b8?c=%5B-7.66134,10.82932,6.41935,-0.07739,-13.88552,1.8697,0,1%5D'
// Revit sample house (good for bim-like stuff with many display meshes)
'https://speckle.xyz/streams/da9e320dad/commits/5388ef24b8'
// 'https://speckle.xyz/streams/da9e320dad/commits/5388ef24b8'
// 'Super' heavy revit shit
// 'https://speckle.xyz/streams/e6f9156405/commits/0694d53bb5'
// IFC building (good for a tree based structure)
@@ -219,7 +219,7 @@ await sandbox.loadUrl(
// Filter issue
// 'https://speckle.xyz/streams/f95d8deb90/commits/30f31becb6'
// Transparent
// 'https://latest.speckle.dev/streams/b5cc4e967c/objects/20343e0e8d469613a9d407499a6c38b1'
'https://latest.speckle.dev/streams/b5cc4e967c/objects/20343e0e8d469613a9d407499a6c38b1'
// dark
// 'https://latest.speckle.dev/streams/b5cc4e967c/commits/efdf3e2728?c=%5B-59.16128,-41.76491,-4.77376,-4.08052,-12.63558,-4.77376,0,1%5D'
// 'https://latest.speckle.dev/streams/92b620fb17/commits/b4366a7086?filter=%7B%7D&c=%5B-31.02357,37.60008,96.58899,11.01564,7.40652,66.0411,0,1%5D)'
@@ -131,6 +131,13 @@ export default class Materials {
['USE_RTE']
)
this.meshTransparentHighlightMaterial.clipShadows = true
this.meshTransparentHighlightMaterial.stencilWrite = true
this.meshTransparentHighlightMaterial.stencilWriteMask = 0xff
this.meshTransparentHighlightMaterial.stencilRef = 0x00
this.meshTransparentHighlightMaterial.stencilFunc = AlwaysStencilFunc
this.meshTransparentHighlightMaterial.stencilZFail = ReplaceStencilOp
this.meshTransparentHighlightMaterial.stencilZPass = ReplaceStencilOp
this.meshTransparentHighlightMaterial.stencilFail = ReplaceStencilOp
this.meshGhostMaterial = new SpeckleGhostMaterial(
{
@@ -336,6 +336,8 @@ export class Pipeline {
public updateClippingPlanes(planes: Plane[]) {
this.depthPass.setClippingPlanes(planes)
this.stencilPass.setClippingPlanes(planes)
this.stencilMaskPass.setClippingPlanes(planes)
}
public reset() {
@@ -4,9 +4,11 @@ import {
DoubleSide,
EqualStencilFunc,
Material,
Plane,
Scene,
Texture,
Vector2
Vector2,
WebGLRenderer
} from 'three'
import SpeckleDisplaceMaterial from '../materials/SpeckleDisplaceMaterial'
import { BaseSpecklePass, SpecklePass } from './SpecklePass'
@@ -49,7 +51,15 @@ export class StencilMaskPass extends BaseSpecklePass implements SpecklePass {
this.scene = scene
}
render(renderer, writeBuffer, readBuffer /*, deltaTime, maskActive */) {
public setClippingPlanes(planes: Plane[]) {
this.overrideMaterial.clippingPlanes = planes
}
render(
renderer: WebGLRenderer,
writeBuffer,
readBuffer /*, deltaTime, maskActive */
) {
if (this.onBeforeRender) this.onBeforeRender()
const oldAutoClear = renderer.autoClear
renderer.autoClear = false
@@ -86,7 +96,10 @@ export class StencilMaskPass extends BaseSpecklePass implements SpecklePass {
)
renderer.getDrawingBufferSize(this.drawBufferSize)
this.overrideMaterial.userData.size.value.copy(this.drawBufferSize)
const shadowMapEnabled = renderer.shadowMap.enabled
renderer.shadowMap.enabled = false
renderer.render(this.scene, this.camera)
renderer.shadowMap.enabled = shadowMapEnabled
if (this.clearColor) {
renderer.setClearColor(this._oldClearColor, oldClearAlpha)
@@ -4,6 +4,7 @@ import {
Color,
DoubleSide,
Material,
Plane,
ReplaceStencilOp,
Scene,
Texture,
@@ -54,6 +55,10 @@ export class StencilPass extends BaseSpecklePass implements SpecklePass {
this.scene = scene
}
public setClippingPlanes(planes: Plane[]) {
this.overrideMaterial.clippingPlanes = planes
}
render(renderer, writeBuffer, readBuffer /*, deltaTime, maskActive */) {
if (this.onBeforeRender) this.onBeforeRender()
const oldAutoClear = renderer.autoClear
@@ -92,7 +97,10 @@ export class StencilPass extends BaseSpecklePass implements SpecklePass {
renderer.getDrawingBufferSize(this.drawBufferSize)
this.overrideMaterial.userData.size.value.copy(this.drawBufferSize)
renderer.clear(false, false, true)
const shadowMapEnabled = renderer.shadowMap.enabled
renderer.shadowMap.enabled = false
renderer.render(this.scene, this.camera)
renderer.shadowMap.enabled = shadowMapEnabled
if (this.clearColor) {
renderer.setClearColor(this._oldClearColor, oldClearAlpha)