Jump to content

  • Log In with Google      Sign In   
  • Create Account

14 years ago on June 15th Gamedev.net was first launched! We want to thank all of you for being part of our community and hope the best years are ahead of us. Happy birthday Gamedev.net!

#Actualmolehill mountaineer

Posted 19 November 2012 - 05:40 AM

Could you post your pixel shader as well?


Sure thing, code is copy-pasted from online source (I wanted to postpone writing pixel shaders for a bit).
In the drawstring() method above I switch shader resources in a for-loop (e.g. 4 quads with letters, 1 with a number, 4 with letters). Only after the loop has finished do I call Draw(). I think this may be what I'm doing wrong - am I supposed to hold two textures in the pixelshader?

/*
    Beginning DirectX 11 Game Programming
    By Allen Sherrod and Wendy Jones
    Texture Mapping Shader
*/

Texture2D colorMap_ : register( t0 );
SamplerState colorSampler_ : register( s0 );

struct VS_Input
{
    float4 pos  : POSITION;
    float2 tex0 : TEXCOORD0;
};
struct PS_Input
{
    float4 pos  : SV_POSITION;
    float2 tex0 : TEXCOORD0;
};

PS_Input VS_Main( VS_Input vertex )
{
    PS_Input vsOut = ( PS_Input )0;
    vsOut.pos = vertex.pos;
    vsOut.tex0 = vertex.tex0;
    return vsOut;
}

float4 PS_Main( PS_Input frag ) : SV_TARGET
{
    return colorMap_.Sample( colorSampler_, frag.tex0 );
}

#2molehill mountaineer

Posted 19 November 2012 - 05:40 AM

Could you post your pixel shader as well?


Sure thing, code is copy-pasted from online source (I wanted to postpone writing pixel shaders for a bit).
In the drawstring() method above I switch shader resources in a for-loop (e.g. 4 quads with letters, 1 with a number, 4 with letters). Only after the loop has finished do I call Draw(). I think this may be what I'm doing wrong - am I supposed to hold two textures in the pixelshader?

/*
    Beginning DirectX 11 Game Programming
    By Allen Sherrod and Wendy Jones
    Texture Mapping Shader
*/

Texture2D colorMap_ : register( t0 );
SamplerState colorSampler_ : register( s0 );

struct VS_Input
{
    float4 pos  : POSITION;
    float2 tex0 : TEXCOORD0;
};
struct PS_Input
{
    float4 pos  : SV_POSITION;
    float2 tex0 : TEXCOORD0;
};

PS_Input VS_Main( VS_Input vertex )
{
    PS_Input vsOut = ( PS_Input )0;
    vsOut.pos = vertex.pos;
    vsOut.tex0 = vertex.tex0;
    return vsOut;
}

float4 PS_Main( PS_Input frag ) : SV_TARGET
{
    return colorMap_.Sample( colorSampler_, frag.tex0 );
}

#1molehill mountaineer

Posted 19 November 2012 - 05:31 AM

Could you post your pixel shader as well?


Sure thing, code is copy-pasted from online source since I'm still getting the hang of things so I wanted to postpone writing pixel shaders for a bit. Am I supposed to take the texture swtich into account in the pixel shader itself?

/*
    Beginning DirectX 11 Game Programming
    By Allen Sherrod and Wendy Jones
    Texture Mapping Shader
*/

Texture2D colorMap_ : register( t0 );
SamplerState colorSampler_ : register( s0 );

struct VS_Input
{
    float4 pos  : POSITION;
    float2 tex0 : TEXCOORD0;
};
struct PS_Input
{
    float4 pos  : SV_POSITION;
    float2 tex0 : TEXCOORD0;
};

PS_Input VS_Main( VS_Input vertex )
{
    PS_Input vsOut = ( PS_Input )0;
    vsOut.pos = vertex.pos;
    vsOut.tex0 = vertex.tex0;
    return vsOut;
}

float4 PS_Main( PS_Input frag ) : SV_TARGET
{
    return colorMap_.Sample( colorSampler_, frag.tex0 );
}

PARTNERS