alb

Member
  • Content count

    6
  • Joined

  • Last visited

Community Reputation

107 Neutral

About alb

  • Rank
    Newbie
  1. [quote name='FXACE' timestamp='1341443376' post='4955793'] I believe it more looks syntax call error than frame buffer problem. Your code: [code] gl.glBindFramebufferEXT(GL.GL_FRAMEBUFFER_EXT, frameBufferID[0]); gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); gl.glPushAttrib(GL.GL_VIEWPORT_BIT); // <--- You saved viewport bits gl.glViewport(0, 0, floorWidth, floorHeight); gl.glBegin(GL.GL_QUADS); gl.glTexCoord2f(0.0f, 0.0f); gl.glVertex3d(-1, -1, 0); gl.glTexCoord2f(0.0f, 1.0f); gl.glVertex3d(-1, 1, 0); gl.glTexCoord2f(1.0f, 1.0f); gl.glVertex3d(1, 1, 0); gl.glTexCoord2f(1.0f, 0.0f); gl.glVertex3d(1, -1, 0); gl.glEnd(); gl.glPopAttrib(); // <-- You restored previous attribute values (viewport bits) gl.glBindFramebufferEXT(GL.GL_FRAMEBUFFER_EXT, 0); gl.glPopAttrib(); // <-- What it does restore??? gl.glBindFramebufferEXT(GL.GL_FRAMEBUFFER_EXT, 0); [/code] Best wishes, FXACE. [/quote] No the last two rows are a copy&paste error: [CODE] gl.glPopAttrib(); // <-- You restored previous attribute values (viewport bits) gl.glBindFramebufferEXT(GL.GL_FRAMEBUFFER_EXT, 0); [/CODE]
  2. I would like to implement the approach of the virtual texturing. I'm following the instructions of this thesis [url="http://www.graphics.rwth-aachen.de/uploads/media/neu_virtual_texturing_low_03.pdf"]http://www.graphics....ring_low_03.pdf[/url] I need what the author calls "Needbuffer" (pag 14). I'm more or less at this point: [media]http://www.youtube.com/watch?feature=player_embedded&v=ONYt4hbitFE[/media] and using the information about the level of detail I would like to load a texture composed with different level of details like in this video: [media]http://www.youtube.com/watch?feature=player_embedded&v=YCZl16JMF08[/media]
  3. Ok now I going to describe my situation: In the screenshot there is my running program. In this case I take what is rendered and I put all of it on a 2dtexture that I rendered on the left of the screen. But I would like to put in the 2dtexture only the quad (that is the output of the shader); as you can see the output is a grid that represents a level of details based on the distance of the camera. I would like to put that information on a texture in order to retrieve the level of details. This is the fragmentShader: [source lang="java"]#version 150out vec4 fragColor;varying vec4 clipPos;void main(){ vec2 tx=gl_TexCoord[0].xy;//vec2 tx = clipPos.xy / clipPos.w * 0.5 + vec2(0.5); // get the length of the texture derivatives float lambda_s = length(dFdx(tx)); float lambda_t = length(dFdy(tx)); // compute the sample level, based on the maximum derivative, and the interpolation factor between ceiled and floored level float level_s; float interp_s = modf(-log2(max(lambda_s, lambda_t)), level_s); // get the new texture coordinate by scaling the texture coordinate by the floored and ceiled level vec2 tx_down = tx * pow(2, level_s); vec2 tx_up = tx * pow(2, level_s + 1); // compute the color procedural vec2 highlight_down = clamp(cos(tx_down * 0.2) - 0.95, 0,1) * 10; vec2 highlight_up = clamp(cos(tx_up * 0.2) - 0.95, 0,1) * 10; // this might be faster, but it doesn't fade nicely... //float highlight_down = step(0.9, fract(tx_down * 0.04)) * 0.8; //float highlight_up = step(0.9, fract(tx_up * 0.04)) * 0.8; // lerp between the intensities fragColor = vec4(1 - clamp(mix( max(highlight_down.x, highlight_down.y), max(highlight_up.x, highlight_up.y), interp_s), 0,1));}[/source]
  4. I have a problem with this piece of code: [source lang="java"]gl.glGenTextures(4, textures, 0); gl.glBindTexture(GL.GL_TEXTURE_2D, textures[3]); gl.glTexImage2D(GL.GL_TEXTURE_2D, 0, GL.GL_RGB, floorWidth, floorHeight,0, GL.GL_RGB, GL.GL_FLOAT, null); gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_NEAREST); gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_S, GL.GL_CLAMP); gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_T, GL.GL_CLAMP); gl.glGenTextures(5, textures, 0); gl.glBindTexture(GL.GL_TEXTURE_2D, textures[4]); gl.glTexImage2D(GL.GL_TEXTURE_2D, 0, GL.GL_DEPTH_COMPONENT16, floorWidth, floorHeight,0, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, null); gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_LINEAR); gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_LINEAR); int tex1=textures[3]; int tex2=textures[4]; //GENERATE FRAMEBUFFER gl.glGenFramebuffersEXT(1, frameBufferID, 0); gl.glBindFramebufferEXT(GL.GL_FRAMEBUFFER_EXT, frameBufferID[0]); gl.glFramebufferTexture2DEXT(GL.GL_FRAMEBUFFER_EXT, GL.GL_COLOR_ATTACHMENT0_EXT,GL.GL_TEXTURE_2D, tex1, 0); gl.glFramebufferTexture2DEXT(GL.GL_FRAMEBUFFER_EXT, GL.GL_DEPTH_ATTACHMENT_EXT, GL.GL_TEXTURE_2D, tex2, 0); if(gl.glCheckFramebufferStatusEXT(GL.GL_FRAMEBUFFER_EXT) == GL.GL_FRAMEBUFFER_COMPLETE_EXT) { System.out.println("[Viewer] GL_FRAMEBUFFER_COMPLETE!!"); } else System.out.println("..error"); gl.glBindFramebufferEXT(GL.GL_FRAMEBUFFER_EXT, 0); [/source] At the end of this initialization code, I have an FBO (frame buffer object) with no errors; it prints "[Viewer] GL_FRAMEBUFFER_COMPLETE!!" But when I try to render something: [source lang="java"] GL gl = drawable.getGL(); gl.glBindFramebufferEXT(GL.GL_FRAMEBUFFER_EXT, frameBufferID[0]); gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); gl.glPushAttrib(GL.GL_VIEWPORT_BIT); gl.glViewport(0, 0, floorWidth, floorHeight); gl.glBegin(GL.GL_QUADS); gl.glTexCoord2f(0.0f, 0.0f); gl.glVertex3d(-1, -1, 0); gl.glTexCoord2f(0.0f, 1.0f); gl.glVertex3d(-1, 1, 0); gl.glTexCoord2f(1.0f, 1.0f); gl.glVertex3d(1, 1, 0); gl.glTexCoord2f(1.0f, 0.0f); gl.glVertex3d(1, -1, 0); gl.glEnd(); gl.glPopAttrib(); gl.glBindFramebufferEXT(GL.GL_FRAMEBUFFER_EXT, 0); gl.glPopAttrib(); gl.glBindFramebufferEXT(GL.GL_FRAMEBUFFER_EXT, 0); int errorCode = gl.glGetError(); if(errorCode!=0){ String errorStr = glu.gluErrorString( errorCode ); System.out.println("...error: "+ errorStr ); System.out.println("....errorCode: "+ errorCode ); } [/source] It return the following error: ....error: invalid framebuffer operation ....errorCode: 1286 Do you know why? Thanks. Alberto
  5. I mean Ok I have the output of the shader in the quad. But how can I use the information contained in that output? For example I would like to use that information in order to retrieve the level of details of each pixel. I would like to have a buffer and each element represents the level of detail of the corrensponding pixel. Is it clear?
  6. I have a question: If I want to use the information contained in the output of the shader, how can I do that? For example how can I convert the output of the shader in a texture? I tried using glFramebufferTexture2DEXT, glBindFramebufferEXT, etc.. but in this case I have a texture with all the scene renderized, not just the output of the shader of the quad.