Porting DX11 to stride

I thought I’d try and port some shaders, so I can learn the syntax changes, so I’m trying GS_PointSprites from dx11

I’m refering to https://github.com/vvvv/VL.Stride/blob/preview/gamma-2021.4/packages/VL.Stride.Runtime/src/Effects/InstancedMeshStreamOut_DrawFX.sdsl#L15 to try and get the GS code syntax for stride and hack the dx11 code in, but as soon as I add the streamOutput section I get an exception. Any clues to why?
VL Shaders.zip (3.7 KB)

[maxvertexcount(4)]
void GSMain(point Input input[1], inout TriangleStream gsout)
{

for(int i=0; i<4; i++)
{
    //Get position from quad array
    float3 position = streams.g_positions[i]*spritesize;//*(input[0].ii ==offset);
    
    //Make sure quad will face camera
    position = mul( position, (float3x3)tIV ).xyz +   streams.ShadingPosition;
    
    //Project vertex
    streams.ShadingPosition = mul( float4(position,1.0), ViewProjection );
    streams.uv = g_texcoords[i];
    gsout.Append(output);
}
gsout.RestartStrip();

}

Now trying to just alter the dx11 code, but how do I get a tIV in sdsl?
Its InverseView, but I think the (float3x3) stops it with truncation error

VL Shaders.zip (3.8 KB)
Ok this is error free, but I loose all inputs to the shader again, and black renderer…

VL Shaders.zip (4.8 KB)
image
Close, but not close enough

1 Like

Things learned so far, you need to declare streams = input[0]; to get the streams. IV is ViewInverse, there is some useful stuff in the Utils shader and some examples of syntax in this repo https://github.com/vvvv/VL.Stride/tree/preview/gamma-2021.4/packages/VL.Stride.Runtime/src/Effects

the only problem seems to be that you cannot use ShadingPosition, which is SV_Position in the pipeline as a reference point for the sprites. it gets projected after the vertex shader stage.

if you use another stream variable, for example PositionWS, and use that in the geometry shader, it works:

VL Geometry Shader.zip (5.4 KB)

1 Like

PointSprites.zip (5.3 KB)

Renamed to Point Sprites

1 Like

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