Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8051329
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T07:16:42+00:00 2026-06-05T07:16:42+00:00

I am attempting to create a hole in the fog effect. I have a

  • 0

I am attempting to create a “hole in the fog” effect. I have a background grid image, overlapped onto that I have a “fog” texture that I use to show that certain areas are not in view. I am attempting to cut a chunk out of “fog” that will show the area that is currently in view. I am trying to “mask” a part of the fog off the screen.

I made some images to help explain what I am after:
Background:

BG

“Mask Image” (The full transparency has to be on the inside and not the outer rim for what I am going to use it for):

Mask

Fog (Sorry, hard to see.. Mostly Transparent):

Fog

What I want as a final Product:

Final Product

I have tried:

  • Stencil-Buffer: I got this fully working except for one fact… I wasn’t able to figure out how to retain the fading transparency of the “mask” image.
  • glBlendFunc: I have tried many different version of the parameters and many other methods with it (glColorMask, glBlendEquation, glBlendFuncSeparate) I started by using some parameter that I found on this website: here. I used the “glBlendFunc(GL_ZERO, GL_ONE_MINUS_SRC_ALPHA);” as this seemed to be what I was looking for but… This is what ended up happening as a result: (Its hard to tell what is happening here but… There is fog covering the grid in the background. Though, the mask is just ending up as an fully opaque black blob when its supposed to be a transparent part in the fog.
    Result of glBlendFunc

Some previous code:

glEnable(GL_BLEND); // This is not really called here... It is called on the init function of the program as it is needed all the way through the rendering cycle.
renderFogTexture(delta, 0.55f); // This renders the fog texture over the background the 0.55f is the transparency of the image. 
glBlendFunc(GL_ZERO, GL11.GL_ONE_MINUS_SRC_ALPHA); // This is the one I tried from one of the many website I have been to today.
renderFogCircles(delta); // This just draws one (or more) of the mask images to remove the fog in key places.

(I would have posted more code but after I tried many things I started removing some old code as it was getting very cluttered (I “backed them up” in block comments))

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T07:16:43+00:00Added an answer on June 5, 2026 at 7:16 am

    This is doable, provided that you’re not doing anything with the alpha of the framebuffer currently.

    Step 1: Make sure that the alpha of the framebuffer is cleared to zero. So your glClearColor call needs to set the alpha to zero. Then call glClear as normal.

    Step 2: Draw the mask image before you draw the “fog”. As Tim said, once you blend with your fog, you can’t undo that. So you need the mask data there first.

    However, you also need to render the mask specially. You only want the mask to modify the framebuffer’s alpha. You don’t want it to mess with the RGB color. To do that, use this function: glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_TRUE). This turns off writes to the RGB part of the color; thus, only the alpha will be modified.

    Your mask texture seems to have zero where it is visible and one where it isn’t. However, the algorithm needs the opposite, so you should either fix your texture or use a glTexEnv mode that will effectively flip the alpha.

    After this step, your framebuffer should have an alpha of 0 where we want to see the fog, and an alpha of 1 where we don’t.

    Also, don’t forget to undo the glColorMask call after rendering the mask. You need to get those colors back.

    Step 3: Render the fog. That’s easy enough; to make the masking work, you need a special blend mode. Like this one:

    glEnable(GL_BLEND);
    glBlendEquation(GL_FUNC_ADD);
    glBlendFuncSeparate(GL_ONE_MINUS_DST_ALPHA, GL_DST_ALPHA, GL_ZERO, GL_ONE);
    

    The separation between the RGB and A blend portions is important. You don’t want to change the framebuffer’s alpha (just in case you want to render more than one layer of fog).

    And you’re done.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm attempting to create a bar chart that needs to use specific series colors
I am attempting to create a report, utilizing a matrix, that only displays columns
I'm attempting to create a CustomControl which will have various properties affected by an
I'm attempting to create a single Controller class to handle all foreseeable surveys that
I'm attempting to create a modal on a form that calls a CFC to
I'm attempting to create a column in css that is 100% height of the
Attempting to create an itemgroup for use in a target where the file types
I'm attempting to create an array of strings that represent the directories stored in
I'm attempting to create an ASP.NET/C# page that runs a PowerShell script that will
I am attempting to create a report that contains a list nested within another

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.