Fixed an issue with RTL and world matrix. We were concatenating the mul incorrectly with the world matrix on the CPU in the update loop. The shadow matrix has a transformation which rescales the range from -1,1 to 0,1 and this transformation was messing the world transform. Added the world transform multiplication inside the shader before multiplying with the shadow view matrix
This commit is contained in:
@@ -9,8 +9,6 @@ export default class Sandbox {
|
||||
private pane: Pane
|
||||
private tabs
|
||||
private filterControls
|
||||
private steamsFolder
|
||||
private viewsControls = []
|
||||
private viewsFolder
|
||||
private streams: { [url: string]: Array<unknown> } = {}
|
||||
|
||||
@@ -110,8 +108,6 @@ export default class Sandbox {
|
||||
private removeStreamControls(url: string) {
|
||||
this.viewer.unloadObject(url)
|
||||
;(this.streams[url][0] as { dispose: () => void }).dispose()
|
||||
;(this.streams[url][1] as { dispose: () => void }).dispose()
|
||||
;(this.streams[url][2] as { dispose: () => void }).dispose()
|
||||
delete this.streams[url]
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ import {
|
||||
} from '../IViewer'
|
||||
|
||||
export default class SpeckleRenderer {
|
||||
private readonly SHOW_HELPERS = false
|
||||
private readonly SHOW_HELPERS = true
|
||||
private _renderer: WebGLRenderer
|
||||
public scene: Scene
|
||||
private rootGroup: Group
|
||||
@@ -181,11 +181,12 @@ export default class SpeckleRenderer {
|
||||
rteModelView.multiply(meshBatch.matrixWorld)
|
||||
const depthMaterial: SpeckleDepthMaterial =
|
||||
meshBatch.customDepthMaterial as SpeckleDepthMaterial
|
||||
|
||||
depthMaterial.userData.uViewer_low.value.copy(viewerLow)
|
||||
depthMaterial.userData.uViewer_high.value.copy(viewerHigh)
|
||||
depthMaterial.userData.rteModelViewMatrix.value.copy(rteModelView)
|
||||
depthMaterial.needsUpdate = true
|
||||
if (depthMaterial) {
|
||||
depthMaterial.userData.uViewer_low.value.copy(viewerLow)
|
||||
depthMaterial.userData.uViewer_high.value.copy(viewerHigh)
|
||||
depthMaterial.userData.rteModelViewMatrix.value.copy(rteModelView)
|
||||
depthMaterial.needsUpdate = true
|
||||
}
|
||||
|
||||
const shadowMatrix = new Matrix4()
|
||||
shadowMatrix.set(
|
||||
@@ -209,7 +210,6 @@ export default class SpeckleRenderer {
|
||||
|
||||
shadowMatrix.multiply(this.sun.shadow.camera.projectionMatrix)
|
||||
shadowMatrix.multiply(rteView)
|
||||
shadowMatrix.multiply(meshBatch.matrixWorld)
|
||||
let material: SpeckleStandardMaterial | SpeckleStandardMaterial[] =
|
||||
meshBatch.material as SpeckleStandardMaterial | SpeckleStandardMaterial[]
|
||||
material = Array.isArray(material) ? material : [material]
|
||||
@@ -420,6 +420,7 @@ export default class SpeckleRenderer {
|
||||
public updateHelpers() {
|
||||
if (this.SHOW_HELPERS) {
|
||||
;(this.scene.getObjectByName('CamHelper') as CameraHelper).update()
|
||||
// Thank you prettier, this looks so much better
|
||||
;(this.scene.getObjectByName('SceneBoxHelper') as Box3Helper).box.copy(
|
||||
this.sceneBox
|
||||
)
|
||||
|
||||
@@ -97,7 +97,7 @@ void main() {
|
||||
for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
|
||||
#ifdef USE_RTE
|
||||
vec4 shadowPosition = computeRelativePosition(position_low.xyz, position.xyz, uShadowViewer_low, uShadowViewer_high);
|
||||
shadowWorldPosition = shadowPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
|
||||
shadowWorldPosition = modelMatrix * shadowPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
|
||||
vDirectionalShadowCoord[ i ] = rteShadowMatrix * shadowWorldPosition;
|
||||
#else
|
||||
shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
|
||||
|
||||
Reference in New Issue
Block a user