The HLSL11 passthrough shader is a shader I find myself needing a lot, and GameMaker does not automatically create it for us.

So here’s a working version for everyone to enjoy! Click the little clipboards at the top right of code blocks to copy it to your clipboard easily.

📜 HLSL11 Passthrough: Vertex📋
//// Simple passthrough vertex shader////Input from Verticesstruct VertexShaderInput{ float3 pos : POSITION;// float3 norm : NORMAL; float4 color : COLOR0; float2 uv : TEXCOORD0;};//Output Struct to Pixel Shaderstruct VertexShaderOutput{ float4 pos : SV_POSITION; float4 color : COLOR0; float2 uv : TEXCOORD0;};//Main ProgramVertexShaderOutput main(VertexShaderInput input){ VertexShaderOutput output; float4 pos = float4(input.pos, 1.0f); // Transform the vertex position into projected space. pos = mul(gm_Matrices[MATRIX_WORLD_VIEW_PROJECTION], pos); output.pos = pos; // Pass through the color output.color = input.color; // Pass through uv output.uv = input.uv; return output;}
📜 HLSL11 Passthrough: Fragment/Pixel📋
//// Simple passthrough fragment shader////Output From Vertex Shaderstruct PixelShaderInput{ float4 pos : SV_POSITION; float4 color : COLOR0; float2 uv : TEXCOORD0;};//Main Programfloat4 main(PixelShaderInput input) : SV_TARGET{ float4 vertColour = input.color; float4 texelColour = gm_BaseTextureObject.Sample(gm_BaseTexture, input.uv); float4 combinedColour = vertColour * texelColour; return combinedColour;}

The SV_POSITION semantic is basically equivalent to gl_Position, and the SV_TARGET semantic is basically equivalent to gl_FragColor


BONUS EXTRA INFO!!!