<Vertex Shader>

 

float4x4 gWorldMatrix;
float4x4 gViewMatrix;
float4x4 gProjectionMatrix;

struct VS_INPUT
{
      float4 mPosition : POSITION; //Vertex 좌표 //
      float2 mTexCoord : TEXCOORD0; //UV 좌표 //
};

struct VS_OUTPUT
{
      float4 mPosition : POSITION;
      float2 mTexCoord : TEXCOORD0;
};

VS_OUTPUT vs_main(VS_INPUT Input)
{
   VS_OUTPUT Output;
  
   Output.mPosition = mul( Input.mPosition, gWorldMatrix );
   Output.mPosition = mul( Output.mPosition, gViewMatrix );
   Output.mPosition = mul( Output.mPosition, gProjectionMatrix );
     
   Output.mTexCoord = Input.mTexCoord; // UV좌표 넣기 //
     
   return Output;
}

 

 

<Pixel Shader>

 

sampler2D DiffuseSampler; //2D 텍스처의 텍셀(텍스처 픽셀)하나

struct PS_INPUT
{
      float2 mTexCoord : TEXCOORD0; // : 상속 받는 것 //
};

float4 ps_main(PS_INPUT Input) : COLOR
{
      float4 albedo = tex2D(DiffuseSampler, Input.mTexCoord); // UV좌표에 해당하는 텍셀 얻기 //
      return albedo.rgba;
     
}

 

'Shader > HLSH Shader 공부' 카테고리의 다른 글

Lighting - Specular  (0) 2014.05.28
Lighting  (0) 2014.05.22
Color  (0) 2014.05.15
Posted by Hwanggoon
,