armory icon indicating copy to clipboard operation
armory copied to clipboard

Armory PBR issue material not compiling

Open onelsonic opened this issue 3 years ago • 2 comments

Blender 2.93.9 last github repo windows 10 Project example : https://github.com/onelsonic/armory_tests/raw/master/armoryPBRmat.7z

In Blender if we use a "Principled BSDF" material node everything works fine. But when using the "Armory PBR" material node when there is a need to move around the "Armory PBR" material node in a few effects the project will simply not compile. While the "Armory PBR" material node is required for proper normal mapping we cannot use it currently in more advanced material. When trying so the compilation will throw errors. Some variables corresponding to other material nodes present in the material in Blender (like : Seperate RGB or MIX RGB) in the GLSL code are used before their own declaration which throw some errors at the compilation.

Scene exported in 0.018s
Info: Publishing project, check console for details.

ERROR: C:\armoryPBRmat_mesh.frag.glsl:13: 'Mix_Color_res' : undeclared identifier
ERROR: C:\armoryPBRmat_mesh.frag.glsl:13: 'assign' :  cannot convert from ' temp float' to ' temp 3-component vector of float'
ERROR: C:\armoryPBRmat_mesh.frag.glsl:13: '' : compilation terminated
ERROR: 3 compilation errors.  No code generated.

if you look at the GLSL code : https://github.com/onelsonic/armory_tests/blob/master/armoryPBRmat/build_armoryPBRmat/compiled/Shaders/armoryPBRmat_mesh.frag.glsl

Mix_Color_res is first used at line 13 but only declared later at line 25 ??

It seems there are issues with the way materials are exported from Blender.

onelsonic avatar May 27 '22 19:05 onelsonic

I could run your file by setting the rendered to forward and un-setting the factor of the materials mix. By simply doing the second step and leaving the rendered to deferred, it would compile but crash instantly.

e2002e avatar Jul 09 '22 14:07 e2002e

The strange matter with that is there is not a single line that sets n to n = normalize(TBN * n); The line just above is the issue and should be written after the declaration of Mix_Color_res, or deleted since it looks absurd to set the normal to the color of the object unless you plugged color output to the normal of the shader node.

e2002e avatar Jul 30 '22 00:07 e2002e