diff --git a/packages/dev/core/src/Materials/Node/Blocks/Vertex/morphTargetsBlock.ts b/packages/dev/core/src/Materials/Node/Blocks/Vertex/morphTargetsBlock.ts index 6eaacbb88e9..da06fa13cba 100644 --- a/packages/dev/core/src/Materials/Node/Blocks/Vertex/morphTargetsBlock.ts +++ b/packages/dev/core/src/Materials/Node/Blocks/Vertex/morphTargetsBlock.ts @@ -35,7 +35,7 @@ export class MorphTargetsBlock extends NodeMaterialBlock { this.registerInput("uv", NodeMaterialBlockConnectionPointTypes.Vector2); this.registerOutput("positionOutput", NodeMaterialBlockConnectionPointTypes.Vector3); this.registerOutput("normalOutput", NodeMaterialBlockConnectionPointTypes.Vector3); - this.registerOutput("tangentOutput", NodeMaterialBlockConnectionPointTypes.Vector3); + this.registerOutput("tangentOutput", NodeMaterialBlockConnectionPointTypes.Vector4); this.registerOutput("uvOutput", NodeMaterialBlockConnectionPointTypes.Vector2); } @@ -230,10 +230,16 @@ export class MorphTargetsBlock extends NodeMaterialBlock { if (hasTangents) { injectionCode += `#ifdef MORPHTARGETS_TANGENT\r\n`; if (manager?.isUsingTextureForTargets) { - injectionCode += `${tangentOutput.associatedVariableName} += (readVector3FromRawSampler(${index}, vertexID) - ${tangent.associatedVariableName}) * morphTargetInfluences[${index}];\r\n`; + injectionCode += `${tangentOutput.associatedVariableName}.xyz += (readVector3FromRawSampler(${index}, vertexID) - ${tangent.associatedVariableName}.xyz) * morphTargetInfluences[${index}];\r\n`; } else { injectionCode += `${tangentOutput.associatedVariableName}.xyz += (tangent${index} - ${tangent.associatedVariableName}.xyz) * morphTargetInfluences[${index}];\r\n`; } + + if (tangent.type === NodeMaterialBlockConnectionPointTypes.Vector4) { + injectionCode += `${tangentOutput.associatedVariableName}.w = ${tangent.associatedVariableName}.w;\r\n`; + } else { + injectionCode += `${tangentOutput.associatedVariableName}.w = 1.;\r\n`; + } injectionCode += `#endif\r\n`; } @@ -303,7 +309,7 @@ export class MorphTargetsBlock extends NodeMaterialBlock { state.compilationString += `#ifdef TANGENT\r\n`; state.compilationString += `${this._declareOutput(tangentOutput, state)} = ${tangent.associatedVariableName};\r\n`; state.compilationString += `#else\r\n`; - state.compilationString += `${this._declareOutput(tangentOutput, state)} = vec3(0., 0., 0.);\r\n`; + state.compilationString += `${this._declareOutput(tangentOutput, state)} = vec4(0., 0., 0., 0.);\r\n`; state.compilationString += `#endif\r\n`; state.compilationString += `#ifdef UV1\r\n`; state.compilationString += `${this._declareOutput(uvOutput, state)} = ${uv.associatedVariableName};\r\n`; diff --git a/packages/dev/core/src/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.ts b/packages/dev/core/src/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.ts index 93a5275c565..195f8312069 100644 --- a/packages/dev/core/src/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.ts +++ b/packages/dev/core/src/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.ts @@ -543,6 +543,10 @@ export class SSAO2RenderingPipeline extends PostProcessRenderPipeline { effect.setTexture("randomSampler", this._randomTexture); }; this._ssaoPostProcess.samples = this.textureSamples; + + if (!this._forceGeometryBuffer) { + this._ssaoPostProcess._prePassEffectConfiguration = new SSAO2Configuration(); + } } private _createSSAOCombinePostProcess(ratio: number, textureType: number): void { @@ -566,10 +570,6 @@ export class SSAO2RenderingPipeline extends PostProcessRenderPipeline { effect.setTextureFromPostProcessOutput("originalColor", this._originalColorPostProcess); }; this._ssaoCombinePostProcess.samples = this.textureSamples; - - if (!this._forceGeometryBuffer) { - this._ssaoCombinePostProcess._prePassEffectConfiguration = new SSAO2Configuration(); - } } private _createRandomTexture(): void {