Sign in to follow this  
mickey123

render to texture and bloom.

Recommended Posts

mickey123    100
Hello All, When I am using the render to texture technique to paint a part of screen, I am getting bloom effects. How can I avoid it?
glGenTextures(1, &texture);
            glBindTexture(GL_TEXTURE_2D, texture);
            glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
            glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
            glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, 256, 256, 0, GL_RGB, GL_UNSIGNED_INT, NULL);
    //glGenerateMipmapEXT(GL_TEXTURE_2D);
   
            glGenFramebuffersEXT(1, &fbo);
            glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo);
           
            glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, texture, 0);
   
            if(glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT)!=GL_FRAMEBUFFER_COMPLETE_EXT)
            {
                    cout<<"The fbo is not complete";
                    cout<<"Error: "<<glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
            }

Share this post


Link to post
Share on other sites
mickey123    100
http://i.imgur.com/YTPSR.png


Code:

glBindTexture(GL_TEXTURE_2D,0);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo);
glClearColor(0.0f, 0.0f, 0.0f, 0.5f);
glClear(GL_COLOR_BUFFER_BIT);
glPushMatrix();
glPushAttrib(GL_VIEWPORT_BIT);

glViewport(0, 0, 256, 256);

glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
glLoadIdentity(); // Reset The Projection Matrix

// Calculate The Aspect Ratio Of The Window
gluPerspective(45.0f,1.0f,0.1f,100.0f);

glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
glLoadIdentity(); // Reset The Modelview Matrix

// glShadeModel(GL_SMOOTH); // Enable Smooth Shading
glClearDepth(1.0f); // Depth Buffer Setup
glEnable(GL_DEPTH_TEST); // Enables Depth Testing
glDepthFunc(GL_LEQUAL); // The Type Of Depth Testing To Do

glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Really Nice Perspective Calculations
glClear(GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer
glLoadIdentity(); // Reset The Current Modelview Matrix
gluPerspective(x,1,d1,d2);

glPopAttrib();
glPopMatrix();

glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
glDisable(GL_DEPTH_TEST);
glClearColor(1.0f, 0.0f, 0.0f, 0.5f);
glEnable(GL_SCISSOR_TEST);
glScissor(0, 0, 256, 256);

glViewport(0, 0, 256, 256);
glClear(GL_COLOR_BUFFER_BIT);
glEnable(GL_TEXTURE_2D);

glBindTexture(GL_TEXTURE_2D,texture);
glShadeModel(GL_SMOOTH); // Enable Smooth Shading
glClearDepth(1.0f); // Depth Buffer Setup
glDepthFunc(GL_LEQUAL); // The Type Of Depth Testing To Do

glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Really Nice Perspective Calculations
glClear(GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer
glLoadIdentity(); // Reset The Current Modelview Matrix
glTranslatef(0.0f,0.0f,-2.3f); // Move Left 1.5 Units And Into The Screen 6.0
glColor4f(1, 1, 1, 1);

glBegin(GL_QUADS);
glColor4f(1, 1, 1, 1);

// face v0-v1-v2-v3
glNormal3f(0,0,1);
glTexCoord2f(1, 1); glVertex3f(.8,.8,.8);
glTexCoord2f(0, 1); glVertex3f(-0.8,.8,.8);
glTexCoord2f(0, 0); glVertex3f(-0.8,-0.8,0.8);
glTexCoord2f(1, 0); glVertex3f(0.8,-0.8,0.8);

glEnd();
glDisable(GL_SCISSOR_TEST);
glEnable(GL_DEPTH_TEST);

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this