Jump to content
  • Advertisement
Sign in to follow this  
mickey123

render to texture and bloom.

This topic is 3005 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
Advertisement
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
That didnt help much. Screenshot needed. Your only drawing part of the screen? Are you scaling this texture up/down to a viewport bigger than 256?

Share this post


Link to post
Share on other sites
Nope, 256 is subview of main view. I guess abigger shot will not make any difference, I am worried abt the shiny bloom .

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!