HGE BlendAlphaMultiply
  • gamecoder5gamecoder5 February 2008
    I know color multiply exists, but not blendalphamultiply. I was told in a previous post to accomplish this (since hge doesnt currently support this) you have to get a device to the d3d pointer directly with code like something simular to this.

    hge->Gfx_BeginScene(tar);
    dx->SetRenderState( D3DRS_SEPARATEALPHABLENDENABLE, TRUE );
    dx->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_SRCALPHA );
    dx->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA );
    dx->SetRenderState( D3DRS_SRCBLENDALPHA, D3DBLEND_ONE );
    dx->SetRenderState( D3DRS_DESTBLENDALPHA, D3DBLEND_INVSRCALPHA );
    hge->Gfx_Clear(ARGB(0, 0, 0, 0));

    // Render things

    hge->Gfx_EndScene();

    Assuming I gained access to the d3d pointer, does anyone know the exact render states you would set to achieve this effect?

    Sorry I dont understand dx code (hence why Im using hge) and especially not all the SetRenderStates.

    Thank you very much.

    Scott.
  • KalithKalith February 2008
    I think you should use SetTextureStageState() but I don't know how to use it very well.

    Maybe :
    1
    dx->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);


    Though I'm not sure what you mean by blendalphamultiply. Would it affect colors too ?
  • gamecoder5gamecoder5 February 2008
    I think it may use the d3drs_modulate SetRenderState. The overall effect I'm trying to do is cast a light map onto a non lit image so:

    pure black on the lightmap over the non-lit map = pure black
    pure white on the lightmap over the non-lit map = no change to non-lit
    anything in between on the lightmap over the non-lit map = a darkened image
  • KalithKalith February 2008
    Well, I looked into HGE's source code and just found that BLEND_COLORMUL does what you need. In fact, if you call SetColor() with this blend mode, it behaves just like you want. But it only works for SetColor...
    You could try this : (realy don't know if that's going to do anything)
    1
    2
    3
    4
    5
    6
    7
    8
    9
    hge->BeginScene(lightTarget)
    //Render your light map
    hge->EndScene()
     
    hge->BeginScene()
    // Render your background, etc
    dx->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
    lightTargetSpr->Render(0, 0);
    hge->EndScene();


    I don't know when texture stage states are applied.
    If they are applied when EndScene() is called (so only the last state you set is used), then you'll need to use an intermediate render target.
  • gamecoder5gamecoder5 February 2008
    BlendColor does a 1 color to all bitmap multiplication. I need each pixel of the lightmap multiplied (modulated) by the corresponding pixel of other bitmap. That example you gave may just do the trick, I'm unsure of the render states as well. If anyone knows exactly how to do this, please chime in.

    Thank you,

    Scott.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In Apply for Membership

In this Discussion

Who's Online (0)