im starting learning some Shader manipulation witg C++ and HLSL, im using D3DXCompileShaderFromFile to do some tests while am learning
i was able to compile and run some VertexShader and PixelShader, send some Attributes, like float, float2, float3, float4 , float4x4 , to set worldMatrix ,Color information ,etc, here is some example:
void CShader::SetVector4(char name[], Vect4f vect)
{
D3DXVECTOR4 v(vect.x,vect.y,vect.z,vect.w);
D3DXHANDLE h = m_pConstantTable->GetConstantByName(NULL, name);
m_pConstantTable->SetVector(m_pDevice, h, &v);
}
almost the same thing with SetMatrix and SetFloat, ex:
myShader->SetVector4("Diffuse",Vect4f(1.0f,0.0f,0.0f,1.0f) );
but i ran to a problem doing so Basic Light shader
how can i send a texture to my "pixelShader"? in my ps is declared as "sampler2d" type, so im not sure what to use to send this information
float4 Diffuse;
float4 Ambient;
sampler2D baseMap;
float4 Main(float3 L: TEXCOORD0, float3 N: TEXCOORD1,float2 texCoord: TEXCOORD2 ) : COLOR
{
float facingRatio = dot(L, N);
float4 tex = tex2D( baseMap, texCoord );
return tex * Diffuse * facingRatio + Ambient * tex;
}