Shader nodes : input params trimmed off when using condition

Hello,

Some input variables seem to be trimmed off by the compiler as I used conditions
probably a bug, but is there a workaround ?

here is the shader node definition:

VertexShaderNodes {
            ShaderNode PhongVert {
                Definition : PhongVert : Shaders/Phong/PhongVert.j3sn
                Condition : !NormalsMap
                InputMappings {
                    lightPosition = MatParam.LightPosition           ---- here they get generated
                    normal = Attr.inNormal                           ---- ...
                    modelPosition = Global.position.xyz
                    normalMatrix = WorldParam.NormalMatrix
                    viewMatrix= WorldParam.ViewMatrix
                    worldViewMatrix = WorldParam.WorldViewMatrix
                    worldMatrix=WorldParam.WorldMatrix
                    cameraPosition=WorldParam.CameraPosition  
                }
                OutputMappings {
                    // normal, lightDir, eyeVec
                }
            }
            ShaderNode NormalsMapVert {
                Definition : NormalsMapVert : Shaders/NormalsMap/NormalsMapVert.j3sn
                Condition : NormalsMap
                InputMappings {
                    lightPosition = MatParam.LightPosition          ---- this one is missing
                    normal = Attr.inNormal                          ---- this one's type is missing
                    tangent = Attr.inTangent
                    modelPosition = Global.position.xyz
                    normalMatrix = WorldParam.NormalMatrix
                    viewMatrix= WorldParam.ViewMatrix
                    worldViewMatrix = WorldParam.WorldViewMatrix
                    worldMatrix=WorldParam.WorldMatrix
                    cameraPosition=WorldParam.CameraPosition  
                }
                OutputMappings {
                    // normal, lightDir, eyeVec
                }
            }

here is the generated code :

//NormalsMapVert : Begin
89        #if defined(NORMALSMAP)
90            NormalsMapVert_normal = inNormal;        <<<<<<<<< compile exception here of course
91            vec3 NormalsMapVert_tangent = inTangent;
92            vec3 NormalsMapVert_modelPosition = Global_position.xyz;
93            vec4 NormalsMapVert_lightDir;
94            vec4 NormalsMapVert_v;
95            vec3 NormalsMapVert_eyeVec;

wich lead to an error

com.jme3.renderer.RendererException: compile error in:ShaderSource[name=Default.vert, defines, type=Vertex, 
language=GLSL150] error:0(90) : error C1008: undefined variable "NormalsMapVert_normal"

let me know if you need the whole file, I can provide it…

regards

[edit : I managed to pass this issue, and I have no idea how, restarted ide, clean/build, removing code, re adding it

now I get another oddity

inNormal is present in both nodes, but defined in only one , not in the other one, it does not make any sens

generated code :

#if !defined(NORMALSMAP)
    in vec3 inNormal;
#endif
#if defined(NORMALSMAP)
    in vec3 inTangent;
#endif

mhh yep I’ll be interested in all the files so I can test.

I created a test project, pasting some of my files in it (http:://robot.isp.imath.be/ShaderNodesTest.zip )

it seems that when defining 2 different shader nodes using the same definition, it creates some conflicts between them

I try to have one phong with normal maps
and another phong without

I noticed also I cant define nodes with same name and different conditions and parameters

wich leads to a complete forking of all subsequent nodes since they must be implemented with different argument values
just hell

you can change the name and still use the same definition.

well check the archive I posted, it complains about “normalsMap” not being part of PrePhongFrag, but it is

and once I add the same variable to another node wich uses another version of PrePhongFrag (in another directory), then the error goes away

also when I tried to define 2 shader nodes with the same name I get :
material.plugins.MatParseException “ShaderNode ‘SomeNodeName’ is already defined”

Ok, actually you have 2 definitions with the same name pointing to 2 different files.
So it gets confused, you need to have unique names for your definitions in the j3sn files.

I managed to have it load in the shader node editor. But there are still other issues.
I’m investigating and i’ll tell you

ok I found a bug in the generator, if you put a comment at the beginning of a shader node, and that node has a condition, the end if is append àt the end of the line, and is commented, resulting in a compilation error.
Not sure it’s your issue though, but try to remove all the ‘//’ comments you have and use ‘/* */’ instead to see if it helps

ok I’ll check it out (just saw your comment now)

yes becos your system does not allow conditional parameter binding
the way I tried to define it is to have one node having conditional input from a node that has 2 different definitions with the same name (depending on a condition)

anyway I’ll use defines as per your recomendation, still had no time to do this yet

It does actually
you can do

variable = inputVariable1 : Condition
variable = inputVariable2 : !Condition

for example

hoooooo, ok

the “//” comments issue is fixe din master and will be in 3.1