MaterialExtension basics

i just tried to implement a Stride MaterialExtension for the first time, however I struggle with a very basic thing - a Vector3 input I create on the shader is not taken into account at all for calculation and I don’t get what i might do wrong here.

the code just adds some offset to a position before WVP transforms. however, changing the value from the patch has no effect:

shader VertexManipulatorExt_ShaderFX : MaterialExtension
{
    cbuffer PerDraw
    {
        stage float3 offset;
    }
    
    
    stage override void PostTransformPosition()
    {
        base.PostTransformPosition();

        float4 mypos = streams.Position + float4(offset,0);
        streams.PositionWS = mul(mypos, World);
        streams.ShadingPosition = mul(streams.PositionWS, ViewProjection);
    }
};

any hints?

shaderExtTest.7z (3.6 KB)

You need:

cbuffer PerMaterial

2 Likes

wonderful, i wasn’t aware of this one.
thanks!

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.