Browse Source

[shgraph] Fix preview crash when input.normal was used in ShaderNodeHXSL

Clément Espeute 10 months ago
parent
commit
6f762a966b
1 changed files with 5 additions and 0 deletions
  1. 5 0
      hrt/shgraph/NodeGenContext.hx

+ 5 - 0
hrt/shgraph/NodeGenContext.hx

@@ -123,6 +123,11 @@ class NodeGenContext {
 
 	function getOrAllocateFromTVar(tvar: TVar) : TVar {
 		var fullName = AstTools.getFullName(tvar);
+
+		// special case handling for normal because it gets replaced in the preview shader
+		if (fullName == "input.normal")
+			return getOrAllocateGlobal(Normal);
+
 		var def = globalVars.get(fullName);
 		if (def != null) {
 			return def.v;