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 279141
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T05:00:26+00:00 2026-05-12T05:00:26+00:00

In the process of trying to port my 2D shadow rendering technique from Directx

  • 0

In the process of trying to port my 2D shadow rendering technique from Directx to Opengl, I’ve run across a problem where I can’t seem to get fine enough access to the opengl blender.

But first, so that the following makes sense, my algorithm:

I sort and render all sprites from back to front without using a depth buffer. Shadow sprites are drawn just before the objects that cast them and use the second blendstate below, gShadowBlendState. That makes them draw only their alpha values to the alpha channel on the framebuffer.

Sprites for regular objects use gBlendState specified first below, which is just a regular alpha blend to the backbuffer. However, they also remove alpha from the backbuffer alpha channel to the extent that they are opaque; this makes sure that shadows don’t show through opaque objects that are in front of them.

The third thing that is drawn, and which is drawn after everything else, is a fullscreen quad that renders using the shadow colour and the final blend state below. It uses the backbuffer’s alpha channel for opacity, effectively bringing out all the shadow information inscribed earlier.

The whole point of this exercise is to get shadows that don’t get darker where they overlap.

    gBlendState.SrcBlend       = D3DBLEND_SRCALPHA;
    gBlendState.BlendOp        = D3DBLENDOP_ADD;
    gBlendState.DestBlend      = D3DBLEND_INVSRCALPHA;
    gBlendState.SrcBlendAlpha  = D3DBLEND_ZERO;
    gBlendState.BlendOpAlpha   = D3DBLENDOP_ADD;
    gBlendState.DestBlendAlpha = D3DBLEND_INVSRCALPHA;

    gShadowBlendState.SrcBlend       = D3DBLEND_ZERO;
    gShadowBlendState.BlendOp        = D3DBLENDOP_ADD;
    gShadowBlendState.DestBlend      = D3DBLEND_ONE;
    gShadowBlendState.SrcBlendAlpha  = D3DBLEND_ONE;
    gShadowBlendState.BlendOpAlpha   = D3DBLENDOP_MAX;
    gShadowBlendState.DestBlendAlpha = D3DBLEND_ONE;

    gShadowFillBlendState.SrcBlend       = D3DBLEND_DESTALPHA;
    gShadowFillBlendState.BlendOp        = D3DBLENDOP_ADD;
    gShadowFillBlendState.DestBlend      = D3DBLEND_INVDESTALPHA;
    gShadowFillBlendState.SrcBlendAlpha  = D3DBLEND_ONE;
    gShadowFillBlendState.BlendOpAlpha   = D3DBLENDOP_MAX;
    gShadowFillBlendState.DestBlendAlpha = D3DBLEND_ONE;

Anyway. I’m trying to do this now in Opengl. Currently I have alpha blending enabled with

    glEnable(GL_BLEND);
    glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

but I’m not sure how to give it separate instructions for how to calculate the colour and alpha components. So my question is this: Is there a way to get finer control over the blender in OpenGL than just glBlendFunc() ?

  • 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-05-12T05:00:27+00:00Added an answer on May 12, 2026 at 5:00 am

    http://www.opengl.org/registry/specs/EXT/blend_func_separate.txt

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

Sidebar

Related Questions

I'm trying to process data obtained from a run of diff to an instance
Im in the process of trying to get my head round a dvcs such
I'm in the process of trying to get the jQuery plugin, Uploadify , to
I am in the process of trying to get my head properly around CSS3
I am trying to process 114,000 rows in a dataset (populated from an oracle
Hi I'm trying to build/deploy war to websphere process server 7.0. and I run
I am trying to port a C++ program from Linux to Windows using cygwin.
I am trying to port a project (from linux) that uses Semaphores to Mac
I'm trying to port some scripts from a modern version of Intersystems Cache back
I am trying to run a java process and enable remote connections using jconsole.

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.