ShaderNodes input mapping

hello,

I try to map a 2d texcoord output to a 3D texcoord input (for noise function), doing this:

InputMappings 
                {
                    texCoord=vec3(WaterVert.texCoord.x,0,WaterVert.texCoord.z)

but I get a npe

java.lang.NullPointerException
    at com.jme3.material.plugins.ShaderNodeLoaderDelegate.readInputMapping(ShaderNodeLoaderDelegate.java:685)
    at com.jme3.material.plugins.ShaderNodeLoaderDelegate.readShaderNode(ShaderNodeLoaderDelegate.java:324)
    at com.jme3.material.plugins.ShaderNodeLoaderDelegate.readNodes(ShaderNodeLoaderDelegate.java:818)

I am not sure if this is supported by shader nodes at all
what would be the alternative ?

thanks

This is not supported.
However you can use swizzle. So unless you absolutely need the second component to be 0 you can write

texCoord = WaterVert.texCoord.xxy

would be the equivalent of

texCoord = vec3(WaterVert.texCoord.x, WaterVert.texCoord.x, WaterVert.texCoord.y)

If you really need the second component to be 0 I suggest you explicitly set it in the shader node code.

ok good idea
thanks
still, would be neat to be able to do it

ugh, not working in the end

Caused by: com.jme3.material.plugins.MatParseException: Error On line 41 : texCoord=WaterVert.texCoord.xxy
->Type mismatch, cannot convertvec3 to vec2.xxy

the other solution is to define 2 nodes
one with vec2 and the otherone with vec3

erf weird, gonna check that too :wink:

That’s also fixed on master.

you can now use

texCoord = WaterVert.texCoord.xxy

will generate

vec3 YourNode_texCoord = WaterVert.texCoord.xxy;

which is valid glsl syntax.

You can also now use

texCoord.xz = WaterVert.texCoord

Which is better IMO in your case because it generates this :

vec3 YourNode_texCoord = vec3(0.0);
YourNode_texCoord .xz = WaterVert.texCoord;

this way you’re sure the y component is 0.