Jump to content
  • Advertisement
Sign in to follow this  
FGFS

OpenGL transparency OpenGL

This topic is 586 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

Hi

why do I get black regions foremost in the sky, less on the ground?

 

http://de.tinypic.com/r/2hrivza/9

 

 

    /// Tell Xplane what we are doing
    XPLMSetGraphicsState(0/*Fog*/, 1/*TexUnits*/, 0/*Lighting*/, 0/*AlphaTesting*/, 1/*AlphaBlending*/, 1/*DepthTesting*/, 1/*DepthWriting*/);
    /// Handle day/night
    glColor4f(Red, Green, Blue, AlphaR);

    //glColor4f(Red, Green, Blue, 1);
    glPushMatrix();
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    glEnable(GL_TEXTURE_2D);
    XPLMBindTexture2d(textures[RAIN_TEXTURE].texIMGID, 0);
    glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_MODULATE);
    glBegin(GL_QUADS);
                glTexCoord2f(1, 1.0f); glVertex2f(right, bottom);    // Bottom Right Of The Texture and Quad
                glTexCoord2f(0, 1.0f); glVertex2f(left, bottom);    // Bottom Left Of The Texture and Quad
                glTexCoord2f(0, 0.0f); glVertex2f(left, top);    // Top Left Of The Texture and Quad
                glTexCoord2f(1, 0.0f); glVertex2f(right, top);    // Top Right Of The Texture and Quad
    glEnd();

 

If I put AlphaR to 1 it's ok, but I want to fade in/out the raintexture.

Many thanks

 

Share this post


Link to post
Share on other sites
Advertisement

It's probably an issue with having depth writing on. Are you rendering the sky first or the rain? When rendering transparent objects there are a few steps you must take, I am a little rusty now but I believe the steps are:

 

Render non-transparent objects.

Disable depth writing.

Setup alpha blending

Sort transparent objects by depth

Render transparent objects starting with those furthest away.

Share this post


Link to post
Share on other sites

I do a X-Plane plugin. Disabling depth doesn't change anything. I nearly get the impressions that most of my stuff simply gets ignored. It worked in xp10 but in xp11 they added ambient shadows etc. Thanks

Edited by FGFS

Share this post


Link to post
Share on other sites

it looks like you first draw ?clouds" then skybox, so the source image (what are you trying to read from) is black in this places., so basically draw skyboxfirst then alphablended something.on the sky

 

edit

 

 

If I put AlphaR to 1 it's ok, but I want to fade in/out the raintexture.

Many thanks

 

 

without knowing from which renderstate you are trying to call your code, we cant help you. glClearColor and other things that involve alpha component like glColor4f need to be drawn to some kind of texture / framebuffer so you can eaisly set whole source image alpha channel to 1.0

Edited by WiredCat

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!