From 7e5e3fd4517263279b00a8fe66c89f29b21c7a54 Mon Sep 17 00:00:00 2001 From: sunag Date: Fri, 27 Sep 2019 14:54:07 -0300 Subject: [PATCH] fix backside material normalmap --- examples/jsm/nodes/misc/NormalMapNode.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/examples/jsm/nodes/misc/NormalMapNode.js b/examples/jsm/nodes/misc/NormalMapNode.js index 3578a373d4..d7c1ffd81d 100644 --- a/examples/jsm/nodes/misc/NormalMapNode.js +++ b/examples/jsm/nodes/misc/NormalMapNode.js @@ -2,6 +2,10 @@ * @author sunag / http://www.sunag.com.br/ */ +import { + BackSide +} from '../../../../build/three.module.js'; + import { TempNode } from '../core/TempNode.js'; import { Vector2Node } from '../inputs/Vector2Node.js'; import { FunctionNode } from '../core/FunctionNode.js'; @@ -81,11 +85,19 @@ NormalMapNode.prototype.generate = function ( builder, output ) { this.position = this.position || new PositionNode( PositionNode.VIEW ); this.uv = this.uv || new UVNode(); + var scale = this.scale.build( builder, 'v2' ); + + if ( builder.material.side === BackSide ) { + + scale = '-' + scale; + + } + return builder.format( perturbNormal2Arb + '( -' + this.position.build( builder, 'v3' ) + ', ' + this.normal.build( builder, 'v3' ) + ', ' + this.value.build( builder, 'v3' ) + ', ' + this.uv.build( builder, 'v2' ) + ', ' + - this.scale.build( builder, 'v2' ) + ' )', this.getType( builder ), output ); + scale + ' )', this.getType( builder ), output ); } else { -- GitLab