hlsl

Hieroglyph3 HLSL Shader error X3004: undeclared identifier 'output'


I am trying to load this shader for a graphics programming project and keep getting this same errorError Message

The hlsl file is as follows

//---------------------------------

Texture2D DiffuseTexture : register(t0);
SamplerState TextureSampler : register(s0);

cbuffer Transforms
{
    matrix WorldMatrix;
    matrix ViewMatrix;
    matrix ProjMatrix;
};

//---------------------------------
struct VS_INPUT
{
    float4 position : POSITION;
    float4 color : COLOR;
    float2 tex : TEXCOORD0;
};


struct VS_OUTPUT
{
    float4 position : SV_POSITION;
    float4 color : COLOR;
    float2 tex : TEXCOORD0;
};



//----------------------------------
VS_OUTPUT VSMain(in VS_INPUT v)
{
    VS_OUTPUT o;

    float4 WorldSpace = mul(v.position, WorldMatrix);
    float4 ViewSpace = mul(WorldSpace, ViewMatrix);
    float4 ScreenSpace = mul(ViewSpace, ProjMatrix);

    o.position = ScreenSpace;
    o.color = v.color;

    output.tex = input.tex;

    return o;
}


//-----------------------------------
float4 PSMain(in VS_OUTPUT input) : SV_Target
{
    float4 sampledTextureColour = DiffuseTexture.Sample(TextureSampler, input.tex);
    return(sampledtexturecolour);
}

Does anyone know what exactly is causing this error?

Have been struggling to find any Heiroglyph3 resources online

Attempting to run heiroglpyh3 project to load a textured sphere using the above hlsl shader file but get error shown in picture


Solution

  • The problem is in VSMain():

    output.tex = input.tex;

    As the error message itself says, output is not declared anywhere. You probably meant o.tex.

    Another problem you'll encounter even if you fix that is the use of input on the same line since it isn't declared either. You only declared it in PSMain(). I suspect the correct way to use it is

    o.tex = v.tex;