Sunday, March 15, 2026

Vertex Shade Interpolation and Alpha Mixing


I’m at the moment working with Monogame and making an attempt to attract a easy crimson triangle with a gradient with interpolated transparency. Backside two vertices must be totally clear and high vertex must be totally opaque. If I perceive mixing appropriately this could work out of the field as a result of mixing works on fragments not on vertices.
It doesn’t work as anticipated:
Vertex Shade Interpolation and Alpha Mixing

HLSL code seems as follows:

#if OPENGL
    #outline SV_POSITION POSITION
    #outline VS_SHADERMODEL vs_3_0
    #outline PS_SHADERMODEL ps_3_0
#else
    #outline VS_SHADERMODEL vs_4_0_level_9_1
    #outline PS_SHADERMODEL ps_4_0_level_9_1
#endif

matrix ViewProjection;

struct VertexShaderInput
{
    float4 Place : POSITION0;
    float4 Shade : COLOR0;
};

struct VertexShaderOutput
{
    float4 Place : SV_POSITION;
    float4 Shade : COLOR0;
};

VertexShaderOutput MainVS(in VertexShaderInput enter)
{
    VertexShaderOutput output = (VertexShaderOutput)0;

    output.Place = mul(enter.Place, ViewProjection);
    output.Shade = enter.Shade;

    return output;
}

float4 MainPS(VertexShaderOutput enter) : COLOR
{
    return enter.Shade;
}

approach BasicColorDrawing
{
    cross P0
    {
        VertexShader = compile VS_SHADERMODEL MainVS();
        PixelShader = compile PS_SHADERMODEL MainPS();
    }
};

I’m enabling mixing by setting

GraphicsDevice.BlendState = BlendState.AlphaBlend;

Is there one thing i bought conceptually incorrect or is one thing incorrect with my code? How would i obtain such impact?

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisement -spot_img

Latest Articles