Texture with float values

Hi,

I want to write float values to a texture with a shader using TextureRenderer. At the next step, I want to read out these values with another shader. The problem is, the stored values of the first step are clamped between 0 and 1. Is there a way to allow greater values than 1?



Best,

Andreas

we need to extend the render texture mode to include these types. i've done so locally for my own tests that needed it. i'll try to get something commited for it.

Being able to specify custom texture format for RTT would be very useful. E.g HDR

Hi MrCoder,

please tell me, when you updated jme with that and how to use it.



Best,

Andres

cool stuff…sorry that i didnt get to this, "things" sort of got in the way s

Hi,

I decided to extend RTT by myself. Here are my modifications of jme to add my wished feature.

RenderToTextureType of com.jme.image.Texture:


/**
     * When doing RenderToTexture operations with this texture, this value
     * indicates what content to render into this texture.
     */
    public enum RenderToTextureType {
        /**
         *Each element is an RGB triple. OpenGL converts it to fixed-point or floating-point and assembles it into an RGBA element by attaching 1 for alpha.
         *Each component is then clamped to the range [0,1].
         */
       RGB,
       /**
        * Each element contains all four components. OpenGL converts it to fixed-point or floating-point.
        * Each component is then clamped to the range [0,1].
        */
       RGBA,
       /**
        * Each element is a single depth component clamped to the range [0, 1].
        * Each component is then clamped to the range [0,1].
        */
       Depth,
       /**
        * Each element is a luminance/alpha pair. OpenGL converts it to fixed-point or floating point, then assembles it into an RGBA element by replicating the luminance value three times for red, green, and blue.
        * Each component is then clamped to the range [0,1].
        */
       Alpha,
       /**
        * Each element is a single luminance value. OpenGL converts it to fixed-point or floating-point, then assembles it into an RGBA element by replicating the luminance value three times for red, green, and blue and attaching 1 for alpha.
        * Each component is then clamped to the range [0,1].
        */
       Luminance,
       /**
        * Each element is a luminance/alpha pair. OpenGL converts it to fixed-point or floating point, then assembles it into an RGBA element by replicating the luminance value three times for red, green, and blue.
        * Each component is then clamped to the range [0,1].
        */
       LuminanceAlpha,
       /**
        * Each element has both luminance (grayness) and alpha (transparency) information, but the luminance and alpha values at every texel are the same.
        * Each component is then clamped to the range [0,1].
        */
       Intensity,
       Alpha4, Alpha8, Alpha12, Alpha16,
       Luminance4, Luminance8, Luminance12, Luminance16,
        Luminance4Alpha4,Luminance6Alpha2, Luminance8Alpha8,Luminance12Alpha4,
        Luminance12Alpha12, Luminance16Alpha16,
        Intensity4, Intensity8, Intensity12, Intensity16,
        R3_G3_B2, RGB4, RGB5, RGB8, RGB10, RGB12, RGB16,
        RGBA2, RGBA4, RGB5_A1, RGBA8, RGB10_A2, RGBA12, RGBA16,
        //floats
        RGBA32F, RGB32F, Alpha32F, Intensity32F, Luminance32F, LuminanceAlpha32F,
        RGBA16F, RGB16F, Alpha16F, Intensity16F, Luminance16F, LuminanceAlpha16F;
    }

setupTexture in com.jme.renderer.jogl.JOGLTextureRenderer



/**
     * <code>setupTexture</code> initializes a new Texture object for use with
     * TextureRenderer. Generates a valid OpenGL texture id for this texture and
     * initializes the data type for the texture.
     */
    public void setupTexture(Texture2D tex) {
        final GL gl = GLU.getCurrentGL();

        if (!isSupported) {
            return;
        }

        IntBuffer ibuf = BufferUtils.createIntBuffer(1);

        if (tex.getTextureId() != 0) {
            ibuf.put(tex.getTextureId());
            gl.glDeleteTextures(ibuf.limit(),ibuf); // TODO Check <size>
            ibuf.clear();
        }

        // Create the texture
        gl.glGenTextures(ibuf.limit(),ibuf); // TODO Check <size>
        tex.setTextureId(ibuf.get(0));
        TextureManager.registerForCleanup(tex.getTextureKey(), tex
                .getTextureId());

        JOGLTextureState.doTextureBind(tex.getTextureId(), 0, Texture.Type.TwoDimensional);
        int components = GL.GL_RGBA8;
        int format = GL.GL_RGBA;
        int dataType=GL.GL_UNSIGNED_BYTE;
        switch (tex.getRTTSource()) {
        case RGBA:
        case RGBA8:   
            break;
        case RGB:   
        case RGB8:
            format = GL.GL_RGB;
            components = GL.GL_RGB8;
            break;
        case Alpha:
        case Alpha8:   
            format = GL.GL_ALPHA;
            components = GL.GL_ALPHA8;
            break;
        case Depth:
            format = GL.GL_DEPTH_COMPONENT;
            components = GL.GL_DEPTH_COMPONENT;
            break;
        case Intensity:
        case Intensity8:   
            format = GL.GL_INTENSITY;
            components = GL.GL_INTENSITY8;
            break;
        case Luminance:
        case Luminance8:   
            format = GL.GL_LUMINANCE;
            components = GL.GL_LUMINANCE8;
            break;
        case LuminanceAlpha:
        case Luminance8Alpha8:   
            format = GL.GL_LUMINANCE_ALPHA;
            components = GL.GL_LUMINANCE8_ALPHA8;
            break;
        case Alpha4:
           format = GL.GL_ALPHA;
            components = GL.GL_ALPHA4;
            break;
        case Alpha12:
           format = GL.GL_ALPHA;
            components = GL.GL_ALPHA12;
            break;
        case Alpha16:
           format = GL.GL_ALPHA;
            components = GL.GL_ALPHA16;
            break;
        case Luminance4:
           format = GL.GL_LUMINANCE;
            components = GL.GL_LUMINANCE4;
            break;
        case Luminance12:
           format = GL.GL_LUMINANCE;
            components = GL.GL_LUMINANCE12;
            break;
        case Luminance16:
           format = GL.GL_LUMINANCE;
            components = GL.GL_LUMINANCE16;
            break;
        case Luminance4Alpha4:
           format = GL.GL_LUMINANCE_ALPHA;
            components = GL.GL_LUMINANCE4_ALPHA4;
            break;
        case Luminance6Alpha2:
           format = GL.GL_LUMINANCE_ALPHA;
            components = GL.GL_LUMINANCE6_ALPHA2;
            break;
        case Luminance12Alpha4:
           format = GL.GL_LUMINANCE_ALPHA;
            components = GL.GL_LUMINANCE12_ALPHA4;
            break;
        case Luminance12Alpha12:
           format = GL.GL_LUMINANCE_ALPHA;
            components = GL.GL_LUMINANCE12_ALPHA12;
            break;
        case Luminance16Alpha16:
           format = GL.GL_LUMINANCE_ALPHA;
            components = GL.GL_LUMINANCE16_ALPHA16;
            break;
        case Intensity4:
           format = GL.GL_INTENSITY;
            components = GL.GL_INTENSITY4;
            break;
        case Intensity12:   
           format = GL.GL_INTENSITY;
            components = GL.GL_INTENSITY12;
            break;
        case Intensity16:
           format = GL.GL_INTENSITY;
           components = GL.GL_INTENSITY4;
           break;
        case R3_G3_B2:
           format = GL.GL_RGB;
            components = GL.GL_R3_G3_B2;
            break;
        case RGB4:
           format = GL.GL_RGB;
            components = GL.GL_RGB4;
            break;
        case RGB5:
           format = GL.GL_RGB;
            components = GL.GL_RGB5;
            break;   
        case RGB10:
           format = GL.GL_RGB;
            components = GL.GL_RGB10;
            break;
        case RGB12:
           format = GL.GL_RGB;
            components = GL.GL_RGB12;
            break;   
        case RGB16:
           format = GL.GL_RGB;
            components = GL.GL_RGB16;
            break;   
        case RGBA2:
           format = GL.GL_RGBA;
            components = GL.GL_RGBA2;
            break;   
        case RGBA4:
           format = GL.GL_RGBA;
            components = GL.GL_RGBA4;
            break;      
        case RGB5_A1:
           format = GL.GL_RGBA;
            components = GL.GL_RGB5_A1;
            break;
        case RGB10_A2:
           format = GL.GL_RGBA;
            components = GL.GL_RGB10_A2;
            break;
        case RGBA12:
           format = GL.GL_RGBA;
            components = GL.GL_RGBA12;
            break;      
        case RGBA16:
           format = GL.GL_RGBA;
            components = GL.GL_RGBA16;
            break;      
        case RGBA32F:
           format = GL.GL_RGBA;
            components = GL.GL_RGBA32F_ARB;
            dataType=GL.GL_FLOAT;
            break;     
        case RGB32F:
           format = GL.GL_RGB;
            components = GL.GL_RGB32F_ARB;
            dataType=GL.GL_FLOAT;
            break;       
        case Alpha32F:   
            format = GL.GL_ALPHA;
            components = GL.GL_ALPHA32F_ARB;
            dataType=GL.GL_FLOAT;
            break;   
        case Intensity32F:
           format = GL.GL_INTENSITY;
            components = GL.GL_INTENSITY32F_ARB;
            dataType=GL.GL_FLOAT;
        case Luminance32F:
           format = GL.GL_LUMINANCE;
            components = GL.GL_LUMINANCE32F_ARB;
            dataType=GL.GL_FLOAT;
            break; 
        case LuminanceAlpha32F:
           format = GL.GL_LUMINANCE_ALPHA;
            components = GL.GL_LUMINANCE_ALPHA32F_ARB;
            dataType=GL.GL_FLOAT;
            break;     
        case RGBA16F:
           format = GL.GL_RGBA;
            components = GL.GL_RGBA16F_ARB;
            dataType=GL.GL_FLOAT;
            break;     
        case RGB16F:
           format = GL.GL_RGB;
            components = GL.GL_RGB16F_ARB;
            dataType=GL.GL_FLOAT;
            break;       
        case Alpha16F:   
            format = GL.GL_ALPHA;
            components = GL.GL_ALPHA16F_ARB;
            dataType=GL.GL_FLOAT;
            break;   
        case Intensity16F:
           format = GL.GL_INTENSITY;
            components = GL.GL_INTENSITY16F_ARB;
            dataType=GL.GL_FLOAT;
        case Luminance16F:
           format = GL.GL_LUMINANCE;
            components = GL.GL_LUMINANCE16F_ARB;
            dataType=GL.GL_FLOAT;
            break; 
        case LuminanceAlpha16F:
           format = GL.GL_LUMINANCE_ALPHA;
            components = GL.GL_LUMINANCE_ALPHA16F_ARB;
            dataType=GL.GL_FLOAT;
            break;    
    }


       
       

        // Initialize our texture with some default data.
        if(dataType==GL.GL_UNSIGNED_BYTE)
        gl.glTexImage2D(GL.GL_TEXTURE_2D, 0, components, width, height, 0,
                format, dataType, (ByteBuffer) null);
        else gl.glTexImage2D(GL.GL_TEXTURE_2D, 0, components, width, height, 0,
                format, dataType, (FloatBuffer) null);

        // Initialize mipmapping for this texture, if requested
        if (tex.getMinificationFilter().usesMipMapLevels()) {
            gl.glGenerateMipmapEXT(GL.GL_TEXTURE_2D);
        }

        // Setup filtering and wrap
        RenderContext<?> context = display.getCurrentContext();
        TextureStateRecord record = (TextureStateRecord) context
                .getStateRecord(RenderState.RS_TEXTURE);
        TextureRecord texRecord = record.getTextureRecord(tex.getTextureId(), tex.getType());

        JOGLTextureState.applyFilter(tex, texRecord, 0, record);
        JOGLTextureState.applyWrap(tex, texRecord, 0, record);

        logger.info("setup fbo tex with id " + tex.getTextureId() + ": " + width
                + "," + height);
    }

setupTexture of com.jme.renderer.lwjgl.LWJGLTextureRenderer



/**
     * <code>setupTexture</code> initializes a new Texture object for use with
     * TextureRenderer. Generates a valid OpenGL texture id for this texture and
     * initializes the data type for the texture.
     */
    public void setupTexture(Texture2D tex) {
        if (!isSupported) {
            return;
        }

        IntBuffer ibuf = BufferUtils.createIntBuffer(1);

        if (tex.getTextureId() != 0) {
            ibuf.put(tex.getTextureId());
            GL11.glDeleteTextures(ibuf);
            ibuf.clear();
        }

        // Create the texture
        GL11.glGenTextures(ibuf);
        tex.setTextureId(ibuf.get(0));
        TextureManager.registerForCleanup(tex.getTextureKey(), tex
                .getTextureId());

        LWJGLTextureState.doTextureBind(tex.getTextureId(), 0, Texture.Type.TwoDimensional);
        int format = GL11.GL_RGBA;
        int components = GL11.GL_RGBA8;
        int dataType=GL11.GL_UNSIGNED_BYTE;
        switch (tex.getRTTSource()) {
            case RGBA:
            case RGBA8:   
                break;
            case RGB:   
            case RGB8:
                format = GL11.GL_RGB;
                components = GL11.GL_RGB8;
                break;
            case Alpha:
            case Alpha8:   
                format = GL11.GL_ALPHA;
                components = GL11.GL_ALPHA8;
                break;
            case Depth:
                format = GL11.GL_DEPTH_COMPONENT;
                components = GL11.GL_DEPTH_COMPONENT;
                break;
            case Intensity:
            case Intensity8:   
                format = GL11.GL_INTENSITY;
                components = GL11.GL_INTENSITY8;
                break;
            case Luminance:
            case Luminance8:   
                format = GL11.GL_LUMINANCE;
                components = GL11.GL_LUMINANCE8;
                break;
            case LuminanceAlpha:
            case Luminance8Alpha8:   
                format = GL11.GL_LUMINANCE_ALPHA;
                components = GL11.GL_LUMINANCE8_ALPHA8;
                break;
            case Alpha4:
               format = GL11.GL_ALPHA;
                components = GL11.GL_ALPHA4;
                break;
            case Alpha12:
               format = GL11.GL_ALPHA;
                components = GL11.GL_ALPHA12;
                break;
            case Alpha16:
               format = GL11.GL_ALPHA;
                components = GL11.GL_ALPHA16;
                break;
            case Luminance4:
               format = GL11.GL_LUMINANCE;
                components = GL11.GL_LUMINANCE4;
                break;
            case Luminance12:
               format = GL11.GL_LUMINANCE;
                components = GL11.GL_LUMINANCE12;
                break;
            case Luminance16:
               format = GL11.GL_LUMINANCE;
                components = GL11.GL_LUMINANCE16;
                break;
            case Luminance4Alpha4:
               format = GL11.GL_LUMINANCE_ALPHA;
                components = GL11.GL_LUMINANCE4_ALPHA4;
                break;
            case Luminance6Alpha2:
               format = GL11.GL_LUMINANCE_ALPHA;
                components = GL11.GL_LUMINANCE6_ALPHA2;
                break;
            case Luminance12Alpha4:
               format = GL11.GL_LUMINANCE_ALPHA;
                components = GL11.GL_LUMINANCE12_ALPHA4;
                break;
            case Luminance12Alpha12:
               format = GL11.GL_LUMINANCE_ALPHA;
                components = GL11.GL_LUMINANCE12_ALPHA12;
                break;
            case Luminance16Alpha16:
               format = GL11.GL_LUMINANCE_ALPHA;
                components = GL11.GL_LUMINANCE16_ALPHA16;
                break;
            case Intensity4:
               format = GL11.GL_INTENSITY;
                components = GL11.GL_INTENSITY4;
                break;
            case Intensity12:   
               format = GL11.GL_INTENSITY;
                components = GL11.GL_INTENSITY12;
                break;
            case Intensity16:
               format = GL11.GL_INTENSITY;
               components = GL11.GL_INTENSITY4;
               break;
            case R3_G3_B2:
               format = GL11.GL_RGB;
                components = GL11.GL_R3_G3_B2;
                break;
            case RGB4:
               format = GL11.GL_RGB;
                components = GL11.GL_RGB4;
                break;
            case RGB5:
               format = GL11.GL_RGB;
                components = GL11.GL_RGB5;
                break;   
            case RGB10:
               format = GL11.GL_RGB;
                components = GL11.GL_RGB10;
                break;
            case RGB12:
               format = GL11.GL_RGB;
                components = GL11.GL_RGB12;
                break;   
            case RGB16:
               format = GL11.GL_RGB;
                components = GL11.GL_RGB16;
                break;   
            case RGBA2:
               format = GL11.GL_RGBA;
                components = GL11.GL_RGBA2;
                break;   
            case RGBA4:
               format = GL11.GL_RGBA;
                components = GL11.GL_RGBA4;
                break;      
            case RGB5_A1:
               format = GL11.GL_RGBA;
                components = GL11.GL_RGB5_A1;
                break;
            case RGB10_A2:
               format = GL11.GL_RGBA;
                components = GL11.GL_RGB10_A2;
                break;
            case RGBA12:
               format = GL11.GL_RGBA;
                components = GL11.GL_RGBA12;
                break;      
            case RGBA16:
               format = GL11.GL_RGBA;
                components = GL11.GL_RGBA16;
                break;      
            case RGBA32F:
               format = GL11.GL_RGBA;
                components = ARBTextureFloat.GL_RGBA32F_ARB;
                dataType=GL11.GL_FLOAT;
                break;     
            case RGB32F:
               format = GL11.GL_RGB;
                components = ARBTextureFloat.GL_RGB32F_ARB;
                dataType=GL11.GL_FLOAT;
                break;       
            case Alpha32F:   
                format = GL11.GL_ALPHA;
                components = ARBTextureFloat.GL_ALPHA32F_ARB;
                dataType=GL11.GL_FLOAT;
                break;   
            case Intensity32F:
               format = GL11.GL_INTENSITY;
                components = ARBTextureFloat.GL_INTENSITY32F_ARB;
                dataType=GL11.GL_FLOAT;
            case Luminance32F:
               format = GL11.GL_LUMINANCE;
                components = ARBTextureFloat.GL_LUMINANCE32F_ARB;
                dataType=GL11.GL_FLOAT;
                break; 
            case LuminanceAlpha32F:
               format = GL11.GL_LUMINANCE_ALPHA;
                components = ARBTextureFloat.GL_LUMINANCE_ALPHA32F_ARB;
                dataType=GL11.GL_FLOAT;
                break;     
            case RGBA16F:
               format = GL11.GL_RGBA;
                components = ARBTextureFloat.GL_RGBA16F_ARB;
                dataType=GL11.GL_FLOAT;
                break;     
            case RGB16F:
               format = GL11.GL_RGB;
                components = ARBTextureFloat.GL_RGB16F_ARB;
                dataType=GL11.GL_FLOAT;
                break;       
            case Alpha16F:   
                format = GL11.GL_ALPHA;
                components = ARBTextureFloat.GL_ALPHA16F_ARB;
                dataType=GL11.GL_FLOAT;
                break;   
            case Intensity16F:
               format = GL11.GL_INTENSITY;
                components = ARBTextureFloat.GL_INTENSITY16F_ARB;
                dataType=GL11.GL_FLOAT;
            case Luminance16F:
               format = GL11.GL_LUMINANCE;
                components = ARBTextureFloat.GL_LUMINANCE16F_ARB;
                dataType=GL11.GL_FLOAT;
                break; 
            case LuminanceAlpha16F:
               format = GL11.GL_LUMINANCE_ALPHA;
                components = ARBTextureFloat.GL_LUMINANCE_ALPHA16F_ARB;
                dataType=GL11.GL_FLOAT;
                break;    
        }

       
      

        // Initialize our texture with some default data.
        if(dataType==GL11.GL_UNSIGNED_BYTE)
           GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, components, width, height, 0,
                    format, dataType, (ByteBuffer)null);
        else GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, components, width, height, 0,
                format, dataType, (FloatBuffer)null);

        // Initialize mipmapping for this texture, if requested
        if (tex.getMinificationFilter().usesMipMapLevels()) {
            EXTFramebufferObject.glGenerateMipmapEXT(GL11.GL_TEXTURE_2D);
        }

        // Setup filtering and wrap
        RenderContext<?> context = display.getCurrentContext();
        TextureStateRecord record = (TextureStateRecord) context
                .getStateRecord(RenderState.RS_TEXTURE);
        TextureRecord texRecord = record.getTextureRecord(tex.getTextureId(), tex.getType());

        LWJGLTextureState.applyFilter(tex, texRecord, 0, record);
        LWJGLTextureState.applyWrap(tex, texRecord, 0, record);

        logger.info("setup fbo tex with id " + tex.getTextureId() + ": " + width
                + "," + height);
    }

I still did not test this code. But, I will test the float textures in the next days.

There is still a thing I don’t understand. Looking at http://opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/teximage2d.html, at glDrawPixels, GL_DEPTH_COMPONENT is allowed, but not at glTexImage2D. So, at my opinion, the RTT depth should be removed. What do you think?

Please tell me, if my additions will be added to jme2.



Best,

Andreas

If you can provide your changes as an eclipse patch against jme2.0 svn and include a test for the added functionality, it will be a lot easy to get it in. 



As for glTexImage2D, we use that only when loading a texture… It has nothing to do with RTT settings or rendering to a depth texture.



I spoke too soon, it is used to put some initial data in… but that is ok based on:



http://www.opengl.org/sdk/docs/man/xhtml/glTexImage2D.xml

Did you get my e-mails? Thx, for your answer. The changes I did, I also will do to the depth.



Best,

Andreas

Hi,

@ MrCoder: Congratulations! If I became father, my child would have top priority, too.



Here is a running example using textures whose values are not clamped between 0 and 1:


   public class MyImplementor extends SimpleCanvasImpl {
      AbsoluteMouse am;
      private GLSLShaderObjectsState so;
      BasicPassManager passManager;
      TextureRenderer oTextureRenderer;
      Texture2D oTexture, oTexture2,oTexture3;
      Quad oQuad, oQuad2, oQuad3;
      

      public MyImplementor(int width, int height) {
         super(width, height);

      }
      
      public void simpleSetup() {
         oTexture=new Texture2D();
         oTexture2=new Texture2D();
         oTexture2.setRenderToTextureType(RenderToTextureType.RGB32F);
         oTextureRenderer=DisplaySystem.getDisplaySystem().createTextureRenderer(width, height,TextureRenderer.Target.Texture2D);
         oTextureRenderer.setMultipleTargets(true);
         oTextureRenderer.setupTexture(oTexture);
         oTextureRenderer.setupTexture(oTexture2);
         
         TextureState oState=renderer.createTextureState();
         oState.setEnabled(true);
         oState.setTexture(oTexture,0);
         
         oQuad=new Quad("myQuad",width,height);
           oQuad.setLocalTranslation(new Vector3f(((float)width)/2,((float)height)/2,0.0f));
         oQuad.setRenderQueueMode(Renderer.QUEUE_ORTHO);
         oQuad.setRenderState(oState);
         oQuad.updateRenderState();
         
         so=renderer.createGLSLShaderObjectsState();
         so.load(getClass().getClassLoader().getResource(
            "vertex1.vert"),
            getClass().getClassLoader().getResource(
                    "fragment4.frag"));
         so.setEnabled(true);
         
                  
         oQuad2=new Quad("myQuad2",width,height);
         oQuad2.setLocalTranslation(new Vector3f(((float)width)/2,((float)height)/2,0.0f));
         oQuad2.setRenderQueueMode(Renderer.QUEUE_ORTHO);
         oQuad2.setRenderState(so);
         oQuad2.updateRenderState();
         oTextureRenderer.render(oQuad2, oTexture2, true);
         
         
         GLSLShaderObjectsState so2=renderer.createGLSLShaderObjectsState();
         so2.load(getClass().getClassLoader().getResource(
            "vertex3.vert"),
            getClass().getClassLoader().getResource(
                    "fragment5.frag"));
         so2.setEnabled(true);
         so2.setUniform("texSampler", 0);
                  
         TextureState oState2=DisplaySystem.getDisplaySystem().getRenderer().createTextureState();
         oState2.setEnabled(true);
         oState2.setTexture(oTexture2,0);
         oQuad3=new Quad("myQuad3",width,height);
         oQuad3.setLocalTranslation(new Vector3f(((float)width)/2,((float)height)/2,0));
         oQuad3.setRenderQueueMode(Renderer.QUEUE_ORTHO);
         oQuad3.setRenderState(oState2);
         oQuad3.setRenderState(so2);
         oQuad3.updateRenderState();
         rootNode.attachChild(oQuad);
         rootNode.updateRenderState();
         
         oTextureRenderer.render(oQuad3, oTexture, false);
      }
      
   }


vertex1.vert:


varying vec4 position;
void main()
{
   position = ftransform();
   gl_Position = position;
}


fragment4.frag:


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


vertex3.vert:


varying vec4 position;

void main()
{
   gl_Position = ftransform();
   position=gl_Position;
   gl_TexCoord[0]  = gl_MultiTexCoord0;
}


fragment5.frag:


uniform sampler2D texSampler;
varying vec4 position;
void main ()
{
   vec4 color=texture2D(texSampler, gl_TexCoord[0].xy);
   
   if(color.x>1.8)
      gl_FragColor=vec4(1.0,0.0,0.0,1.0);
   else gl_FragColor=vec4(0.0,1.0,0.0,1.0);
   
}


When the texture values were clamped, I got a green quad and now, I get red quad.

Thx @Josh 4 updating jme so quickly with my patch.

Best,
Andreas

Sure, and actually another user (Steve Vaughan, the guy behind the JOGL port) pointed out that we really could merge the (almost identical) enums Image.Format and RTTType, so look for some restructuring to come soon.

Hi,

I played a bit with RGBA32F textures. Writing to a single RGBA32F texture is working. Reading from different RGBA32F textures or reading from a rgba and a rgba32 texture in a single shader is working, too. Writing to different standard rgba textures in a single shader is working, too. But, writing to 2 rgba32f textures in a single shader or writing to a rgba32f and a rgba texture, don't work. I got the following exception:


08.08.2008 01:28:35 class com.jme.renderer.lwjgl.LWJGLTextureRenderer render(Spatial, Texture)
SCHWERWIEGEND: Exception
java.lang.RuntimeException: FrameBuffer: 1, has caused a GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT exception
at com.jme.renderer.lwjgl.LWJGLTextureRenderer.checkFBOComplete(LWJGLTextureRenderer.java:744)
at com.jme.renderer.lwjgl.LWJGLTextureRenderer.render(LWJGLTextureRenderer.java:626)
at com.jme.renderer.lwjgl.LWJGLTextureRenderer.render(LWJGLTextureRenderer.java:546)
at JMESwingTest5$MyImplementor.simpleSetup(JMESwingTest5.java:383)
at com.jme.system.canvas.SimpleCanvasImpl.doSetup(SimpleCanvasImpl.java:118)
at com.jmex.awt.lwjgl.LWJGLCanvas.initGL(LWJGLCanvas.java:101)
at org.lwjgl.opengl.AWTGLCanvas.paint(AWTGLCanvas.java:288)
at sun.awt.RepaintArea.paintComponent(Unknown Source)
at sun.awt.RepaintArea.paint(Unknown Source)
at sun.awt.windows.WComponentPeer.handleEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)


Do you know, what's wrong and how to fix it?

Best,
Andreas

incomplete formats… first time i have seen that one.  google give you anything?

Hi,

looking at http://developer.amd.com/media/gpu_assets/FramebufferObjects.pdf, the target textures must have the same format. That solved my problems. The cause, why writing to 2 rgba32f textures did not work at first, was, I overlooked something in my code.



Best,

Andreas

Cool