• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Shaders [Solved] MRTs in HLSL 11

Xor

@XorDev
Hello!
I'm trying to write a Multiple Render Target shader for our game, Xodusse, and I'm having trouble figuring out the HLSL 11 syntax. I am currently using HLSL 9, but I want to rewrite the shader for GameMaker Studio 2.
I can't find any information on the syntax so I'm kind of just guessing and I might be a bit off. Here's the vertex shader I'm attempting to use:
Code:
struct VertexShaderInput
{
    float4 vPosition : POSITION;
    float4 vColor    : COLOR0;
    float2 vTexcoord : TEXCOORD0;
};

struct VertexShaderOutput
{
    float4 vPosition : SV_POSITION;
    float4 vColor    : COLOR0;
    float2 vTexcoord : TEXCOORD0;
};

VertexShaderOutput main(VertexShaderInput INPUT)
{
    VertexShaderOutput OUTPUT;

    float4 matrixWVP = mul(gm_Matrices[MATRIX_WORLD_VIEW_PROJECTION], INPUT.vPosition);

    OUTPUT.vPosition = matrixWVP;
    OUTPUT.vColor    = INPUT.vColor;
    OUTPUT.vTexcoord = INPUT.vTexcoord;

    return OUTPUT;
}
And here's the fragment shader that doesn't work:
Code:
struct PixelShaderInput{
   float4 vPosition : SV_POSITION;
    float4 vColor    : COLOR0;
    float2 vTexcoord : TEXCOORD0;
};
struct PixelShaderOutput
{
    float4 vColor    : COLOR0;
 float4 vNorml    : COLOR1;
};
PixelShaderOutput main(PixelShaderInput INPUT)
{
 PixelShaderOutput OUTPUT;
    float4 diffuseTexture = gm_BaseTextureObject.Sample(gm_BaseTexture, INPUT.vTexcoord);
    OUTPUT.vColor = INPUT.vColor * diffuseTexture;
 OUTPUT.vNorml = float4(1,0,0,1); //Just pass a red texture for this test.
 
 return OUTPUT;
}



This code does not compile and the compile message doesn't help much:​
FAILED: Run Program Complete
Any help is appreciated! Thanks!
 
Last edited:

Xor

@XorDev
Thanks a ton xygthop3! I've been looking for this for a while now and that's just what I wanted.
For anyone interested, the only change I need to do was change COLOR0/COLOR1 to SV_TARGET0/SV_TARGET1.
 
Last edited:
Top