• Advertisement
Sign in to follow this  

Direct3D + ActiveX

This topic is 1380 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 there.

 

I've made an application builded on common separate window with some transparent cubes. All looks good, transparent is transparent and so on.

Then I've moved all my code to ATL ActiveX Control, and now transparent figure became just textured white (texture has white background) cube.

 

Why there is so difference ? How can I manage it ?

Edited by fdialke

Share this post


Link to post
Share on other sites
Advertisement

Screenshots?

 

Without seeing the issue, I would guess that you try to load a texture from a path relative to the executable, and it fails. 

 

Based on the information so far, it is very difficult to assess the problem.

Share this post


Link to post
Share on other sites

https://imageshack.com/i/m94v69j

https://imageshack.com/i/gv46kij

md3dImmediateContext->OMSetBlendState(TransparentBS, blendFactor, 0xffffffff);
activeTech->GetPassByIndex(p)->Apply(0, md3dImmediateContext);

md3dImmediateContext->RSSetState(CCWcullMode);
md3dImmediateContext->DrawIndexed(mTransparentVICount, 0, 0);

md3dImmediateContext->RSSetState(CWcullMode);
md3dImmediateContext->DrawIndexed(mTransparentVICount, 0, 0);

md3dImmediateContext->OMSetBlendState(0, blendFactor, 0xffffffff);

Edited by fdialke

Share this post


Link to post
Share on other sites

I've made this PS shader now

float4 PS_TransparentCube(VertexOut pin, uniform int gLightCount) : SV_Target
{
// Interpolating normal can unnormalize it, so normalize it.
    pin.NormalW = normalize(pin.NormalW);


// The toEye vector is used in lighting.
float3 toEye = gEyePosW - pin.PosW;


// Cache the distance to the eye from this surface point.
float distToEye = length(toEye); 


// Normalize.
toEye /= distToEye;


    // Default to multiplicative identity.
    float4 texColor = float4(1, 1, 1, 1);


// Sample texture.
texColor = gTransparentMap.Sample( samAnisotropic, pin.Tex );


texColor.a = 0.1f;
return texColor;
}
 
so now cube has no lights, still window application has transparency and ActiveX shows white cube

Share this post


Link to post
Share on other sites

well, I've made it work, but don't know why that didn't 

I've included SetBlendState right into techinque:

technique11 Light2TexTransparent
{
    pass P0
    {
        SetVertexShader( CompileShader( vs_5_0, VS_TransparentCube() ) );
SetGeometryShader( NULL );
SetBlendState(EnableBlend, float4( 0.1f, 0.1f, 0.1f, 0.1f ), 0xFFFFFFFF);
        SetPixelShader( CompileShader( ps_5_0, PS_TransparentCube(2) ) );
    }
}
BlendState EnableBlend
{
BlendEnable[0] = TRUE;
SrcBlend[0] = 5;
DestBlend[0] = 6;
BlendOp[0] = 1;
SrcBlendAlpha[0] = 2;
DestBlendAlpha[0] = 1;
BlendOpAlpha[0] = 1;
RenderTargetWriteMask[0] = 15;
};
 
may somebody explain me why OMSetBlendState didn't work, but SetBlendState fixed it ?
 

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement