Questions about the shader version

  • Question 1
Uncaught exception thrown in Thread[jME3 Main,5,main]
RendererException: compile error in: ShaderSource[name=Shaders/Effect/EffectShader.frag, defines, type=Fragment, language=GLSL120]
0(11) : error C5060: out can't be used with non-varying texCoord1

Why can’t I define the shader keyword “out” but I have to use “varying”?(I guess it’s a version problem)

  • Question 2
严重: Uncaught exception thrown in Thread[jME3 Main,5,main]
java.lang.UnsupportedOperationException: No technique 'Default' on material 'Simple' is supported by the video hardware. The capabilities [GLSL430] are required.

What does this error mean? What is the highest version of GLSL supported by jme?

  • Question 3
严重: Uncaught exception thrown in Thread[jME3 Main,5,main]
com.jme3.renderer.RendererException: compile error in: ShaderSource[name=Shaders/Effect/EffectShader.frag, defines, type=Fragment, language=GLSL130]
0(82) : error C7533: global variable gl_FragColor is deprecated after version 120

”global variable gl_FragColor is deprecated after version 120“So what’s the correct usage?

Note that each question comes from a different GLSL version,

To answer all of these properly, I’d need to see your j3md, but jme’s GLSL is a weird mix of older and newer versions of GLSL, duct taped together by a single include file (GLSLCompat.glsllib). I’ll try to answer with the information provided nevertheless.

In versions pre GLSL 330, the varying/attribute syntax is used and in newer versions the in/out syntax is used. If you want to mix both of them in the same file, you’re going to need the above mentioned GLSLCompat.glsllib included in your shader. The cause of the error is the fact that the compiler is trying to compile the shader as a GLSL120 shader, which it clearly isn’t.

Either you accidentially named your render passes in j3md (I’d need to see your j3md for more info) or your GPU doesn’t support GLSL430. JME doesn’t have an upper GLSL version limit built in, it will use whatever the GPU driver is capable of using.

In vanilla GLSL, you’d use a vec4 variable market as out in the fragment shader instead of the gl_FragColor. In JME I’ve only ever used gl_FragColor (except when I tried using MRT, but that’s a different story) and had no problems. Though do note that the GLSLCompat.glsllib is probably required.

I can’t comment on that without seeing your j3md.

j3md

MaterialDef Simple {
    //This is the complete list of user defined uniforms to be used in the
    //shaders
    MaterialParameters {
        Vector4 Color
        Float Time
    }
    Technique {
        //This is where the vertex and fragment shader files are
        //specified
        VertexShader GLSL330:   Shaders/Effect/EffectVertexShader.vert
        FragmentShader GLSL330: Shaders/Effect/EffectShader.frag
        //This is where you specify which global uniform you need for your
        //shaders
        WorldParameters {
            WorldViewProjectionMatrix
            Resolution
            Time
        }
    }
    Technique FixedFunc {
    }
}

vert

//the global uniform World view projection matrix
//(more on global uniforms below)
uniform mat4 g_WorldViewProjectionMatrix;
//The attribute inPosition is the Object space position of the vertex
in vec3 inPosition;

in vec2 inTexCoord;

out vec2 texCoord1;
void main(){
    
    texCoord1=inTexCoord;
    //Transformation of the object space coordinate to projection space
    //coordinates.
    //- gl_Position is the standard GLSL variable holding projection space
    //position. It must be filled in the vertex shader
    //- To convert position we multiply the worldViewProjectionMatrix by
    //by the position vector.
    //The multiplication must be done in this order.
    
    gl_Position = g_WorldViewProjectionMatrix * vec4(inPosition, 1);
}

frag

#ifdef GL_ES
precision mediump float;
#endif

uniform vec2 g_Resolution;
uniform vec2 g_Mouse;
uniform float g_Time;
out vec2 texCoord1;
out vec4 fragColor;
float random (in vec2 _st) {
    return fract(sin(dot(_st.xy,
                         vec2(12.9898,78.233)))*
        43758.5453123);
}

// Based on Morgan McGuire @morgan3d
// https://www.shadertoy.com/view/4dS3Wd
float noise (in vec2 _st) {
    vec2 i = floor(_st);
    vec2 f = fract(_st);

    // Four corners in 2D of a tile
    float a = random(i);
    float b = random(i + vec2(1.0, 0.0));
    float c = random(i + vec2(0.0, 1.0));
    float d = random(i + vec2(1.0, 1.0));

    vec2 u = f * f * (3.0 - 2.0 * f);

    return mix(a, b, u.x) +
            (c - a)* u.y * (1.0 - u.x) +
            (d - b) * u.x * u.y;
}

#define NUM_OCTAVES 5

float fbm ( in vec2 _st) {
    float v = 0.0;
    float a = 0.5;
    vec2 shift = vec2(100.0);
    // Rotate to reduce axial bias
    mat2 rot = mat2(cos(0.5), sin(0.5),
                    -sin(0.5), cos(0.50));
    for (int i = 0; i < NUM_OCTAVES; ++i) {
        v += a * noise(_st);
        _st = rot * _st * 2.0 + shift;
        a *= 0.5;
    }
    return v;
}

void main() {
    vec2 st = texCoord1;
// st += st * abs(sin(g_Time*0.1)*3.0);g_Resolution.xy*3. 
    vec3 color = vec3(0.0);

    vec2 q = vec2(0.);
    q.x = fbm( st + 0.00*g_Time);
    q.y = fbm( st + vec2(1.0));

    vec2 r = vec2(0.);
    r.x = fbm( st + 1.0*q + vec2(1.7,9.2)+ 0.15*g_Time );
    r.y = fbm( st + 1.0*q + vec2(8.3,2.8)+ 0.126*g_Time);

    float f = fbm(st+r);

    color = mix(vec3(0.101961,0.619608,0.666667),
                vec3(0.666667,0.666667,0.498039),
                clamp((f*f)*4.0,0.0,1.0));

    color = mix(color,
                vec3(0,0,0.164706),
                clamp(length(q),0.0,1.0));

    color = mix(color,
                vec3(0.666667,1,1),
                clamp(length(r.x),0.0,1.0));

    fragColor = vec4((f*f*f+.6*f*f+.5*f)*color,1.);
}

I currently want to use version 330 but there is an error

严重: Uncaught exception thrown in Thread[jME3 Main,5,main]
java.lang.UnsupportedOperationException: No technique 'Default' on material 'Simple' is supported by the video hardware. The capabilities [GLSL330] are required.

I would like to know which glsl version is currently supported by jme and I would like to try the latest version.

Are these the shaders that showed the errors or the shaders after you fixed stuff?

Because with this:

You shouldn’t be getting errors related GLSL120.

The GLSL120 error occurred because I tried a different version of the shader

In order to help debug shader errors we will need to see the shaders AND the errors that belong to those shaders.

Otherwise we are left to give random answers until one happens to hit.

That’s what I want to ask right now

All of them.

All versions are supported. Whatever the latest version that comes out 6 months from now is also supported.

That’s not going to be helpful, though.

1 Like

This looks like it should be trying to use GLSL330. Which is also what the error seems to be showing.

Whatever your GPU driver supports. If you’re on linux you can check that using glxinfo | grep OpenGL and look for the shader language line. No idea about other OSes.

1 Like

Regarding this one, I think the fact that it is trying to force you to use GLSL430 means this was a shader that is trying to force GLSL430 or you have configured JME so that it is forcing that version.

Your problems are much easier to solve than the way you are trying to solve them but it will be difficult for us to help you with the real problems without more information.

1 Like

Thank you for your quick reply,

No technique 'Default' on material 'Simple' is supported by the video hardware. The capabilities [GLSL330] are required.

How should I fix this mistake?

This is my current code

When JME starts up, it prints out a bunch of information about driver versions and stuff. Can you please post that?

Can you also show the code where you setup your AppSettings?

public class Testglsl extends SimpleApplication{

    @Override
    public void simpleInitApp() {
//    Box box= new Box(Vector3f.ZERO, 1f,1f,1f);
//   // Geometry cube = new Geometry("box", box);
//    Geometry cube = new Geometry("球体", new Sphere(10, 16, 2));
//    Material mat = new Material(assetManager,"Models/Syana/Syana.j3md");
//    cube.setMaterial(mat);
//    cube.setMaterial(assetManager.loadMaterial("Models/Syana/Syana.j3m"));



    Box box1= new Box(new Vector3f(2,2,2), 1f,1f,1f);
    Geometry cube1 = new Geometry("box", box1);
    Material mat1 = new Material(assetManager,"Shaders/Effect/EffectMatDef.j3md");
   // mat1.setFloat("Time", 0.1f);
    cube1.setMaterial(mat1);
    
   // rootNode.attachChild(cube);
    rootNode.attachChild(cube1);
    }
    
        public static void main(String[] arguments) {
        Testglsl application = new Testglsl();
        application.start();
    }
        
}
5月 23, 2023 11:11:22 下午 com.jme3.system.JmeDesktopSystem initialize
信息: Running on jMonkeyEngine 3.6.0-stable
 * Branch: HEAD
 * Git Hash: 53f2a49
 * Build Date: 2023-03-20
5月 23, 2023 11:11:22 下午 com.jme3.system.lwjgl.LwjglContext printContextInitInfo
信息: LWJGL 3.3.1 build 7 context running on thread jME3 Main
 * Graphics Adapter: GLFW 3.4.0 Win32 WGL Null EGL OSMesa VisualC DLL
5月 23, 2023 11:11:22 下午 com.jme3.renderer.opengl.GLRenderer loadCapabilitiesCommon
信息: OpenGL Renderer Information
 * Vendor: NVIDIA Corporation
 * Renderer: NVIDIA GeForce RTX 3070 Ti/PCIe/SSE2
 * OpenGL Version: 3.2.0 NVIDIA 531.61
 * GLSL Version: 1.50 NVIDIA via Cg compiler
 * Profile: Core
5月 23, 2023 11:11:22 下午 com.jme3.audio.openal.ALAudioRenderer initOpenAL
信息: Audio Renderer Information
 * Device: OpenAL Soft
 * Vendor: OpenAL Community
 * Renderer: OpenAL Soft
 * Version: 1.1 ALSOFT 1.21.1
 * Supported channels: 64
 * ALC extensions: ALC_ENUMERATE_ALL_EXT ALC_ENUMERATION_EXT ALC_EXT_CAPTURE ALC_EXT_DEDICATED ALC_EXT_disconnect ALC_EXT_EFX ALC_EXT_thread_local_context ALC_SOFT_device_clock ALC_SOFT_HRTF ALC_SOFT_loopback ALC_SOFT_loopback_bformat ALC_SOFT_output_limiter ALC_SOFT_pause_device
 * AL extensions: AL_EXT_ALAW AL_EXT_BFORMAT AL_EXT_DOUBLE AL_EXT_EXPONENT_DISTANCE AL_EXT_FLOAT32 AL_EXT_IMA4 AL_EXT_LINEAR_DISTANCE AL_EXT_MCFORMATS AL_EXT_MULAW AL_EXT_MULAW_BFORMAT AL_EXT_MULAW_MCFORMATS AL_EXT_OFFSET AL_EXT_source_distance_model AL_EXT_SOURCE_RADIUS AL_EXT_STEREO_ANGLES AL_LOKI_quadriphonic AL_SOFT_bformat_ex AL_SOFTX_bformat_hoa AL_SOFT_block_alignment AL_SOFTX_callback_buffer AL_SOFTX_convolution_reverb AL_SOFT_deferred_updates AL_SOFT_direct_channels AL_SOFT_direct_channels_remix AL_SOFT_effect_target AL_SOFT_events AL_SOFTX_filter_gain_ex AL_SOFT_gain_clamp_ex AL_SOFT_loop_points AL_SOFTX_map_buffer AL_SOFT_MSADPCM AL_SOFT_source_latency AL_SOFT_source_length AL_SOFT_source_resampler AL_SOFT_source_spatialize
5月 23, 2023 11:11:22 下午 com.jme3.audio.openal.ALAudioRenderer initOpenAL
信息: Audio effect extension version: 1.0
5月 23, 2023 11:11:22 下午 com.jme3.audio.openal.ALAudioRenderer initOpenAL
信息: Audio max auxiliary sends: 2
5月 23, 2023 11:11:22 下午 com.jme3.material.plugins.J3MLoader readTechnique
警告: Fixed function technique was ignored
5月 23, 2023 11:11:22 下午 com.jme3.material.plugins.J3MLoader readTechnique
警告: Fixed function technique 'FixedFunc' was ignored for material Shaders/Effect/EffectMatDef.j3md
5月 23, 2023 11:11:22 下午 com.jme3.app.LegacyApplication handleError
严重: Uncaught exception thrown in Thread[jME3 Main,5,main]
java.lang.UnsupportedOperationException: No technique 'Default' on material 'Simple' is supported by the video hardware. The capabilities [GLSL330] are required.
	at com.jme3.material.Material.selectTechnique(Material.java:779)
	at com.jme3.material.Material.render(Material.java:1019)
	at com.jme3.renderer.RenderManager.renderGeometry(RenderManager.java:682)
	at com.jme3.renderer.queue.RenderQueue.renderGeometryList(RenderQueue.java:273)
	at com.jme3.renderer.queue.RenderQueue.renderQueue(RenderQueue.java:312)
	at com.jme3.renderer.RenderManager.renderViewPortQueues(RenderManager.java:961)
	at com.jme3.renderer.RenderManager.flushQueue(RenderManager.java:855)
	at com.jme3.renderer.RenderManager.renderViewPort(RenderManager.java:1223)
	at com.jme3.renderer.RenderManager.render(RenderManager.java:1287)
	at com.jme3.app.SimpleApplication.update(SimpleApplication.java:278)
	at com.jme3.system.lwjgl.LwjglWindow.runLoop(LwjglWindow.java:622)
	at com.jme3.system.lwjgl.LwjglWindow.run(LwjglWindow.java:711)
	at java.base/java.lang.Thread.run(Thread.java:833)

According to that output, GLSL150 is the highest version you can use in your shaders.

Thank you for your help

Something is seriously weird with your drivers though, a 3070ti should support more than that.

1 Like

I agree. Something is odd with the graphics driver/OS setup.

I reinstalled the driver, but it shows the same thing

5月 24, 2023 1:32:30 上午 com.jme3.system.JmeDesktopSystem initialize
信息: Running on jMonkeyEngine 3.6.0-stable
 * Branch: HEAD
 * Git Hash: 53f2a49
 * Build Date: 2023-03-20
5月 24, 2023 1:32:31 上午 com.jme3.system.lwjgl.LwjglContext printContextInitInfo
信息: LWJGL 3.3.1 build 7 context running on thread jME3 Main
 * Graphics Adapter: GLFW 3.4.0 Win32 WGL Null EGL OSMesa VisualC DLL
5月 24, 2023 1:32:31 上午 com.jme3.renderer.opengl.GLRenderer loadCapabilitiesCommon
信息: OpenGL Renderer Information
 * Vendor: NVIDIA Corporation
 * Renderer: NVIDIA GeForce RTX 3070 Ti/PCIe/SSE2
 * OpenGL Version: 3.2.0 NVIDIA 531.79
 * GLSL Version: 1.50 NVIDIA via Cg compiler
 * Profile: Core
5月 24, 2023 1:32:31 上午 com.jme3.audio.openal.ALAudioRenderer initOpenAL
信息: Audio Renderer Information
 * Device: OpenAL Soft
 * Vendor: OpenAL Community
 * Renderer: OpenAL Soft
 * Version: 1.1 ALSOFT 1.21.1
 * Supported channels: 64
 * ALC extensions: ALC_ENUMERATE_ALL_EXT ALC_ENUMERATION_EXT ALC_EXT_CAPTURE ALC_EXT_DEDICATED ALC_EXT_disconnect ALC_EXT_EFX ALC_EXT_thread_local_context ALC_SOFT_device_clock ALC_SOFT_HRTF ALC_SOFT_loopback ALC_SOFT_loopback_bformat ALC_SOFT_output_limiter ALC_SOFT_pause_device
 * AL extensions: AL_EXT_ALAW AL_EXT_BFORMAT AL_EXT_DOUBLE AL_EXT_EXPONENT_DISTANCE AL_EXT_FLOAT32 AL_EXT_IMA4 AL_EXT_LINEAR_DISTANCE AL_EXT_MCFORMATS AL_EXT_MULAW AL_EXT_MULAW_BFORMAT AL_EXT_MULAW_MCFORMATS AL_EXT_OFFSET AL_EXT_source_distance_model AL_EXT_SOURCE_RADIUS AL_EXT_STEREO_ANGLES AL_LOKI_quadriphonic AL_SOFT_bformat_ex AL_SOFTX_bformat_hoa AL_SOFT_block_alignment AL_SOFTX_callback_buffer AL_SOFTX_convolution_reverb AL_SOFT_deferred_updates AL_SOFT_direct_channels AL_SOFT_direct_channels_remix AL_SOFT_effect_target AL_SOFT_events AL_SOFTX_filter_gain_ex AL_SOFT_gain_clamp_ex AL_SOFT_loop_points AL_SOFTX_map_buffer AL_SOFT_MSADPCM AL_SOFT_source_latency AL_SOFT_source_length AL_SOFT_source_resampler AL_SOFT_source_spatialize

For reference, this is what my Windows 7 computer with a several months old driver is saying:

12:07:45,611 INFO  [JmeSystem] Running on jMonkeyEngine 3.6.0-SNAPSHOT
 * Branch: master
 * Git Hash: b543418
 * Build Date: 2022-11-13
12:07:45,958 INFO  [LwjglContext] LWJGL 2.9.3 context running on thread jME3 Main
 * Graphics Adapter: nvd3dumx,nvwgf2umx,nvwgf2umx
 * Driver Version: 30.0.14.7381
 * Scaling Factor: 1
12:07:45,979 INFO  [GLRenderer] OpenGL Renderer Information
 * Vendor: NVIDIA Corporation
 * Renderer: NVIDIA GeForce GTX 1050/PCIe/SSE2
 * OpenGL Version: 4.6.0 NVIDIA 473.81
 * GLSL Version: 4.60 NVIDIA
 * Profile: Compatibility
12:07:46,046 INFO  [DefaultControllerEnvironment] Loading: net.java.games.input.DirectAndRawInputEnvironmentPlugin
12:07:46,203 INFO  [ALAudioRenderer] Audio Renderer Information
 * Device: OpenAL Soft
 * Vendor: OpenAL Community
 * Renderer: OpenAL Soft
 * Version: 1.1 ALSOFT 1.15.1
 * Supported channels: 64
 * ALC extensions: ALC_ENUMERATE_ALL_EXT ALC_ENUMERATION_EXT ALC_EXT_CAPTURE ALC_EXT_DEDICATED ALC_EXT_disconnect ALC_EXT_EFX ALC_EXT_thread_local_context ALC_SOFT_loopback
 * AL extensions: AL_EXT_ALAW AL_EXT_DOUBLE AL_EXT_EXPONENT_DISTANCE AL_EXT_FLOAT32 AL_EXT_IMA4 AL_EXT_LINEAR_DISTANCE AL_EXT_MCFORMATS AL_EXT_MULAW AL_EXT_MULAW_MCFORMATS AL_EXT_OFFSET AL_EXT_source_distance_model AL_LOKI_quadriphonic AL_SOFT_buffer_samples AL_SOFT_buffer_sub_data AL_SOFTX_deferred_updates AL_SOFT_direct_channels AL_SOFT_loop_points AL_SOFT_source_latency

And I noticed something rather strange

#ifdef GL_ES
precision mediump float;
#endif

uniform vec2 g_Resolution;
uniform vec2 g_Mouse;
uniform float g_Time;
varying vec2 texCoord1;
//out vec4 gl_FragCoord;
//out vec4 fragColor;
float random (in vec2 _st) {
    return fract(sin(dot(_st.xy,
                         vec2(12.9898,78.233)))*
        43758.5453123);
}

// Based on Morgan McGuire @morgan3d
// https://www.shadertoy.com/view/4dS3Wd
float noise (in vec2 _st) {
    vec2 i = floor(_st);
    vec2 f = fract(_st);

    // Four corners in 2D of a tile
    float a = random(i);
    float b = random(i + vec2(1.0, 0.0));
    float c = random(i + vec2(0.0, 1.0));
    float d = random(i + vec2(1.0, 1.0));

    vec2 u = f * f * (3.0 - 2.0 * f);

    return mix(a, b, u.x) +
            (c - a)* u.y * (1.0 - u.x) +
            (d - b) * u.x * u.y;
}

#define NUM_OCTAVES 5

float fbm ( in vec2 _st) {
    float v = 0.0;
    float a = 0.5;
    vec2 shift = vec2(100.0);
    // Rotate to reduce axial bias
    mat2 rot = mat2(cos(0.5), sin(0.5),
                    -sin(0.5), cos(0.50));
    for (int i = 0; i < NUM_OCTAVES; ++i) {
        v += a * noise(_st);
        _st = rot * _st * 2.0 + shift;
        a *= 0.5;
    }
    return v;
}

void main() {
    vec2 st = texCoord1;
// st += st * abs(sin(g_Time*0.1)*3.0);g_Resolution.xy*3.  texCoord1
    vec3 color = vec3(0.0);

    vec2 q = vec2(0.);
    q.x = fbm( st + 0.00*g_Time);
    q.y = fbm( st + vec2(1.0));

    vec2 r = vec2(0.);
    r.x = fbm( st + 1.0*q + vec2(1.7,9.2)+ 0.15*g_Time );
    r.y = fbm( st + 1.0*q + vec2(8.3,2.8)+ 0.126*g_Time);

    float f = fbm(st+r);

    color = mix(vec3(0.101961,0.619608,0.666667),
                vec3(0.666667,0.666667,0.498039),
                clamp((f*f)*4.0,0.0,1.0));

    color = mix(color,
                vec3(0,0,0.164706),
                clamp(length(q),0.0,1.0));

    color = mix(color,
                vec3(0.666667,1,1),
                clamp(length(r.x),0.0,1.0));

    gl_FragColor = vec4((f*f*f+.6*f*f+.5*f)*color,1.);
}
#ifdef GL_ES
precision mediump float;
#endif

uniform vec2 g_Resolution;
uniform vec2 g_Mouse;
uniform float g_Time;
out vec2 texCoord1;
//out vec4 gl_FragCoord;
out vec4 fragColor;
float random (in vec2 _st) {
    return fract(sin(dot(_st.xy,
                         vec2(12.9898,78.233)))*
        43758.5453123);
}

// Based on Morgan McGuire @morgan3d
// https://www.shadertoy.com/view/4dS3Wd
float noise (in vec2 _st) {
    vec2 i = floor(_st);
    vec2 f = fract(_st);

    // Four corners in 2D of a tile
    float a = random(i);
    float b = random(i + vec2(1.0, 0.0));
    float c = random(i + vec2(0.0, 1.0));
    float d = random(i + vec2(1.0, 1.0));

    vec2 u = f * f * (3.0 - 2.0 * f);

    return mix(a, b, u.x) +
            (c - a)* u.y * (1.0 - u.x) +
            (d - b) * u.x * u.y;
}

#define NUM_OCTAVES 5

float fbm ( in vec2 _st) {
    float v = 0.0;
    float a = 0.5;
    vec2 shift = vec2(100.0);
    // Rotate to reduce axial bias
    mat2 rot = mat2(cos(0.5), sin(0.5),
                    -sin(0.5), cos(0.50));
    for (int i = 0; i < NUM_OCTAVES; ++i) {
        v += a * noise(_st);
        _st = rot * _st * 2.0 + shift;
        a *= 0.5;
    }
    return v;
}

void main() {
    vec2 st = texCoord1;
// st += st * abs(sin(g_Time*0.1)*3.0);g_Resolution.xy*3.  texCoord1
    vec3 color = vec3(0.0);

    vec2 q = vec2(0.);
    q.x = fbm( st + 0.00*g_Time);
    q.y = fbm( st + vec2(1.0));

    vec2 r = vec2(0.);
    r.x = fbm( st + 1.0*q + vec2(1.7,9.2)+ 0.15*g_Time );
    r.y = fbm( st + 1.0*q + vec2(8.3,2.8)+ 0.126*g_Time);

    float f = fbm(st+r);

    color = mix(vec3(0.101961,0.619608,0.666667),
                vec3(0.666667,0.666667,0.498039),
                clamp((f*f)*4.0,0.0,1.0));

    color = mix(color,
                vec3(0,0,0.164706),
                clamp(length(q),0.0,1.0));

    color = mix(color,
                vec3(0.666667,1,1),
                clamp(length(r.x),0.0,1.0));

    fragColor = vec4((f*f*f+.6*f*f+.5*f)*color,1.);
}

GLSL100 shows the expected content, while GLSL150 shows the unintended content in solid color only