Bindless Textures

I’m trying to convert some shadertoy stuff into jme for a bit of fun - primarily for a background in a menu. I found one I liked and converted it over, but I don’t really understand the error message, and googling around seems to result in me just not understanding what I’m doing…

This is the error message, which I can suppress by adding line: #extension GL_ARB_bindless_texture : enable in the frag shader

Uncaught exception thrown in Thread[jME3 Main,5,main]
RendererException: compile error in: ShaderSource[name=Shaders/Ethereal.frag, defines, type=Fragment, language=GLSL150]
Fragment shader failed to compile with the following errors:
ERROR: 0:43: error(#438) Extension GL_ARB_bindless_texture is requried' by use image/sampler as output parameters'.
ERROR: error(#273) 1 compilation errors.  No code generated

Here is the toy: Shader - Shadertoy BETA

And here is the material, vert and frag shader.

MaterialDef Ethereal {

    MaterialParameters {

        Vector2 Resolution
        Vector2 MousePosition

        Texture2D Channel0


    Technique {
        VertexShader GLSL150:   Shaders/Ethereal.vert
        FragmentShader GLSL150: Shaders/Ethereal.frag

        WorldParameters {

#import "Common/ShaderLib/GLSLCompat.glsllib"
#import "Common/ShaderLib/Skinning.glsllib"
#import "Common/ShaderLib/Instancing.glsllib"

attribute vec3 inPosition;
attribute vec2 inTexCoord;

uniform float g_Time;

varying float t;
varying vec2 tex;

void main() {

    t = g_Time * 0.3;
    tex = inTexCoord;

    vec4 modelSpacePos = vec4(inPosition, 1.0);
    gl_Position = TransformWorldViewProjection(modelSpacePos);

// #extension GL_ARB_bindless_texture : enable
#import "Common/ShaderLib/GLSLCompat.glsllib"

varying vec2 m_Resolution;
varying vec2 m_MousePosition;
varying sampler2D m_Channel0;

// uniform float g_Time;
varying float t;
varying vec2 tex;

float sphere(vec3 p, vec3 rd, float r){
    float b = dot( -p, rd ),
        inner = b*b - dot(p,p) + r*r;
    return inner < 0. ?  -1. : b - sqrt(inner);

vec3 kset(vec3 p) {

	float m=1000., mi=0., l;
	for (float i=0.; i<20.; i++) {
        p = abs(p)/dot(p,p) - 1.;
        if (l < m) m=l, mi=i;

	return normalize( 3. + texture2D(m_Channel0,vec2(mi*.218954)).xyz )
           * pow( max(0.,1.-m), 2.5+.3*sin(l*25.+t*50.) );

void mainImage( out vec4 o, vec2 uv ) {

    vec2 R = m_Resolution.xy,
        mo = m_MousePosition.xy / R - .5;
    uv = (uv-.5*R)/ R.y;

    vec3 ro = -vec3(mo, 2.5-.7*sin(t*3.7535)),
	     rd = normalize(vec3(uv,3.)),
	     v = vec3(0), p;
    float tt,c=cos(t),s=sin(t);
	mat2 rot = mat2(c,-s,s,c);

	for (float i=20.; i<50.; i++) {
		tt = sphere(ro, rd, i*.03);
		p = ro+rd*tt;
		p.xy *= rot;
		p.xz *= rot;
		v = .9*v + .5*kset(p+p)*step(0.,tt);
	} = v*v *vec3(1.2,1.05,.9);

void main() {
    vec4 color = vec4(0.0);
    // vec2 uv = vec2(1.0);
    mainImage(color, tex);

    vec4 colOut = vec4(color.rgb, 1.0);

    gl_FragColor = colOut;


I had to add this line:

#extension GL_ARB_bindless_texture : enable

I don’t understand this line, and I’m not entirely sure why it’s needed.

The result is a black texture that seems to completely block the application (just like locking the main loop would).

I realise a lot of the problem is due to lack of knowledge, so would appreciate any ideas on why this behaviour is occuring…

Just for the sake of transparency, this is how I initialize the material:

package com.jayfella.emu.background;

import com.jme3.material.Material;
import com.jme3.math.Vector2f;
import com.jme3.scene.Geometry;
import com.jme3.scene.shape.Quad;
import com.jme3.texture.Texture;

 * Created by James on 18/02/2017.
public class TestBackground {

    public TestBackground(SimpleApplication app) {

        // uniform vec3      iResolution;           // viewport resolution (in pixels)
        // uniform float     iGlobalTime;           // shader playback time (in seconds)
        // uniform float     iTimeDelta;            // render time (in seconds)
        // uniform int       iFrame;                // shader playback frame
        // uniform float     iChannelTime[4];       // channel playback time (in seconds)
        // uniform vec3      iChannelResolution[4]; // channel resolution (in pixels)
        // uniform vec4      iMouse;                // mouse pixel coords. xy: current (if MLB down), zw: click
        // uniform samplerXX iChannel0..3;          // input channel. XX = 2D/Cube
        // uniform vec4      iDate;                 // (year, month, day, time in seconds)
        // uniform float     iSampleRate;           // sound sample rate (i.e., 44100)

        Vector2f resolution  = new Vector2f(128, 72);
        Vector2f mousePosition = app.getInputManager().getCursorPosition();

        // Material material = app.getAssetManager().loadMaterial("MatDefs/Ethereal.j3md");
        Material material = new Material(app.getAssetManager(), "MatDefs/Ethereal.j3md");
        material.setVector2("Resolution", resolution);
        material.setVector2("MousePosition", mousePosition);

        Texture texture = app.getAssetManager().loadTexture("Textures/tex16.png");

        material.setTexture("Channel0", texture);

        Quad quad = new Quad(1280, 720);

        Geometry geom = new Geometry("Background", quad);

        // app.getGuiNode().attachChild(geom);



So above all of that would be been a fully expanded version of your shader dumped… what was line 43 in that output?

But even without knowing what line 43 is I might guess it is the above. Using a varying for a texture seems strange to me.

Yep. Line 43 was the declaration of the varying sampler2D. And changing it to uniform stopped the application flat-lining.

Amazing. Thank you.

And an obligatory screenshot to show it works. Thanks again :slight_smile: