sdk icon indicating copy to clipboard operation
sdk copied to clipboard

ShaderNodes: Connecting Attribute to TextureFetch

Open MeFisto94 opened this issue 5 years ago • 1 comments

So when I connect the Attribute to the Texture Fetch, I get the following:

Error On line 0 : texCoord = Attribute.inTexCoord
->Undeclared nodeAttribute. Make sure this node is declared before the current node

Four times. I don't know if this is relevant, but it seems like the order I add them to Nodes Editor or the order I connect those nodes.

Actually when saving the file and loading it again, I get an error:

Caused by: com.jme3.material.plugins.MatParseException: Error On line 26 : texCoord = Attribute.inTexCoord
->Undeclared nodeAttribute. Make sure this node is declared before the current node
	at com.jme3.material.plugins.ShaderNodeLoaderDelegate.readInputMapping(ShaderNodeLoaderDelegate.java:758)
	at com.jme3.material.plugins.ShaderNodeLoaderDelegate.readShaderNode(ShaderNodeLoaderDelegate.java:287)
	at com.jme3.material.plugins.ShaderNodeLoaderDelegate.readNodes(ShaderNodeLoaderDelegate.java:872)
	at com.jme3.material.plugins.ShaderNodeLoaderDelegate.readFragmentShaderNodes(ShaderNodeLoaderDelegate.java:387)
	at com.jme3.material.plugins.J3MLoader.readTechniqueStatement(J3MLoader.java:592)
	at com.jme3.material.plugins.J3MLoader.readTechnique(J3MLoader.java:637)
	at com.jme3.material.plugins.J3MLoader.loadFromRoot(J3MLoader.java:779)
	at com.jme3.material.plugins.J3MLoader.load(J3MLoader.java:800)
	at com.jme3.asset.DesktopAssetManager.loadLocatedAsset(DesktopAssetManager.java:260)
	... 55 more

Shader Node:

MaterialDef Simple {
    MaterialParameters {
        Color TeamColor
        Texture2D Mask
    }
    Technique {
        WorldParameters {
            WorldViewProjectionMatrix
        }
        VertexShaderNodes {
            ShaderNode CommonVert {
                Definition : CommonVert : Common/MatDefs/ShaderNodes/Common/CommonVert.j3sn
                InputMappings {
                    worldViewProjectionMatrix = WorldParam.WorldViewProjectionMatrix
                    modelPosition = Global.position.xyz
                }
                OutputMappings {
                    Global.position = projPosition
                }
            }
        }
        FragmentShaderNodes {
            ShaderNode TextureFetch {
                Definition : TextureFetch : Common/MatDefs/ShaderNodes/Basic/TextureFetch.j3sn
                InputMappings {
                    texCoord = Attribute.inTexCoord
                    textureMap = MatParam.Mask
                }
            }
            ShaderNode ColorMult {
                Definition : ColorMult : Common/MatDefs/ShaderNodes/Basic/ColorMult.j3sn
                InputMappings {
                    color1 = TextureFetch.outColor
                    color2 = MatParam.TeamColor
                }
                OutputMappings {
                    Global.color = outColor
                }
            }
        }
    }
}

Judging by https://github.com/jMonkeyEngine/jmonkeyengine/blob/master/jme3-core/src/main/resources/Common/MatDefs/Misc/UnshadedNodes.j3md, Attributes are now prefixed Attr not Attribute

Not so easy, I tried to change it, but then I get

Caused by: com.jme3.material.plugins.MatParseException: Error On line 26 : texCoord = Attr.inTexCoord
->Cannot have an attribute as input in a fragment shaderinTexCoord
	at com.jme3.material.plugins.ShaderNodeLoaderDelegate.readInputMapping(ShaderNodeLoaderDelegate.java:713)
	at com.jme3.material.plugins.ShaderNodeLoaderDelegate.readShaderNode(ShaderNodeLoaderDelegate.java:287)
	at com.jme3.material.plugins.ShaderNodeLoaderDelegate.readNodes(ShaderNodeLoaderDelegate.java:872)
	at com.jme3.material.plugins.ShaderNodeLoaderDelegate.readFragmentShaderNodes(ShaderNodeLoaderDelegate.java:387)

I'll ahve to look at it tomorrow.

MeFisto94 avatar Feb 08 '20 03:02 MeFisto94

I think this is fixed by #338 and #341

neph1 avatar May 23 '22 19:05 neph1