How to show colors with alpha channel in the material?

Started by
3 comments, last by BornToCode 8 years, 10 months ago

I have added this line into the state machine of the fixed pipeline, but still didn't work. Any ideas why?

m_pDevice->SetRenderState(D3DRS_DIFFUSEMATERIALSOURCE, D3DMCS_MATERIAL);

https://msdn.microsoft.com/en-us/library/windows/desktop/bb147177%28v=vs.85%29.aspx

Advertisement
Enable alpha blending.


L. Spiro

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid


m_pDevice->SetRenderState(D3DRS_DIFFUSEMATERIALSOURCE, D3DMCS_MATERIAL);

That bit of code says that the fixed-function shader will use the "material" diffuse colour when shading.

How does this relate to the question? What does the rest of your fixed-function shader configuration look like? Are you even using fixed-function shading? What does the question even mean? What do you want the "colors with alpha channel" to do?

I got a model in which some parts I want to be able to see through. Actually I l already had the alpha render state attribute enabled

like

bool CMyApp::RestoreGameState()
{
    m_pFont->RestoreDeviceObjects();

    // restore device states    
    m_pDevice->SetTransform(D3DTS_PROJECTION, m_Cam.GetProjMatrix());
    
    m_pDevice->SetRenderState(D3DRS_LIGHTING, true);
    m_pDevice->SetRenderState(D3DRS_AMBIENT, D3DCOLOR_COLORVALUE(0.5, 0.5, 0.5, 0.0));    

    m_pDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, true);
    m_pDevice->SetRenderState(D3DRS_DIFFUSEMATERIALSOURCE, D3DMCS_MATERIAL);

    
    
    // normalize since objects are being scaled therefore normals aren't correct anymore
    m_pDevice->SetRenderState(D3DRS_NORMALIZENORMALS, true);

    m_pDevice->SetSamplerState( 0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR );
    m_pDevice->SetSamplerState( 0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR );
    m_pDevice->SetSamplerState( 0, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR );

    m_pDevice->LightEnable(DIRECTIONAL, true);
    m_pDevice->LightEnable(POINT, true);        
    SetClearColor(175, 175, 175);

    return true;
}

The material samples I took from the debugger did have the alpha values of less than 1.0.

But the colors of the materials are solid. I didn't set up the textures for those objects.

The restoregamestate looks alright I think, doesn't it?

I got lights setup. What did I miss out?

Thanks

Jack

You need to have Alpha Blending enable otherwise your alpha value will not affect anything. You might also want to set SrcBlend to SrcAlpha and DestBlend to InvSrcAlpha.

This topic is closed to new replies.

Advertisement