0
\$\begingroup\$

Here is the fragment shader code (MyShaders/Shader1.frag):

void main(){
   gl_FragColor = vec4(1.0,1.0,1.0,1.0);
}

And the vertex shader code (MyShaders/Shader1.vert):

void main(void)
{

    gl_Position=vec4(1.0,1.0,1.0,0.0);

}

And the .j3md material code:

MaterialDef Shader1 {
    MaterialParameters {
    }

    Technique {
        VertexShader GLSL100 GLSL150:   MyShaders/Shader1.frag
        FragmentShader GLSL100 GLSL150: MyShaders/Shader1.vert
    }
}

The error stack trace is:

WARNING: Bad compile of:
1   #version 110
2   #define FRAGMENT_SHADER 1
3   void main(void)
4   {
5   
6       gl_Position=vec4(1.0,1.0,1.0,0.0);
7   
8   }

May 01, 2018 3:35:57 PM com.jme3.app.LegacyApplication handleError
SEVERE: Uncaught exception thrown in Thread[jME3 Main,5,main]
com.jme3.renderer.RendererException: compile error in: ShaderSource[name=MyShaders/Shader1.vert, defines, type=Fragment, language=GLSL100]
ERROR: 0:6: Use of undeclared identifier 'gl_Position'

And here is the code for instantiating the material:

Material mat=new Material(assetManager,"MyShaders/Shader1.j3md");

I think that the bug is somewhere in me not passing any gl_Position parameters into the shader, but how do I do that?

I am using JME3 and Java.

\$\endgroup\$
1
\$\begingroup\$

You switched your vertex and fragment shader filenames inside Technique{...}

Technique { 
  VertexShader GLSL100 GLSL150: MyShaders/Shader1.frag
  FragmentShader GLSL100 GLSL150: MyShaders/Shader1.vert 
}

should become

Technique { 
  VertexShader GLSL100 GLSL150: MyShaders/Shader1.vert
  FragmentShader GLSL100 GLSL150: MyShaders/Shader1.frag
}
\$\endgroup\$
  • \$\begingroup\$ :head-bash: Really. That was kind of stupid of me. \$\endgroup\$ – mackycheese21 May 3 '18 at 2:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.