Quantcast
Channel: Community | MonoGame - Latest topics
Viewing all articles
Browse latest Browse all 6822

Can't get this instanced shader to work right.

$
0
0

@willmotil wrote:

I was working on instancing a few days ago and decided id like to just pass in a world orientation matrix per instance. This seemed straightforward at first but no matter what i do, i can't get proper transformation to occur i honestly can't even see what is really going wrong the results are weird.

So i pulled out my camera class and added that and a second game class.
I changed the Instanced Vertex structure to take a full wvp 4x4 matrix and passed it in for just a single instanced quad. At this point im starting to think that the data is not being passed in properly or it is being optimized out or something weird.

Both tests are here if anyone wants to take a look.

https://drive.google.com/open?id=15XqxQsAnp7invMe1ouiaiXPql7DovX5J

It should be working there is nothing left to it i was playing around with the w value thinking that was the problem but now im thinking that the actual values are not being passed in correctly.

    VSOutputInstanced MainVsInstanced(in VSVertexInputInstanced vertexInput, VSInstanceInputInstanced instanceInput)
    {
        VSOutputInstanced output;
        //float instanceTimeOrId = instanceInput.InstanceTimeOrId;
        float4x4 wvp;
        wvp[0] = instanceInput.InstanceLeft;
        wvp[1] = instanceInput.InstanceUp;
        wvp[2] = instanceInput.InstanceForward;
        wvp[3] = instanceInput.InstancePosition;
        float4 posVert = float4(vertexInput.Position, 1.0f); // 0.0f i give up lol.
        float4 pos = mul(posVert, wvp);
        // passthru
        output.Position = pos;
        output.TexCoord = vertexInput.TexCoord;
        output.Color = float4(1.0f, 0.0f, 0.0f, .99f);
        return output;
    }

    float4 MainPsInstanced(VSOutputInstanced input) : COLOR0
    {
        float4 col = tex2D(TexSamplerA, input.TexCoord) *  input.Color;
        // straight clip alpha draws
        clip(col.a - .05f);
        return col;
    }

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 6822

Trending Articles