I’m trying to add very basic ambient lighting using custom HLSL but the final pixels don’t seem to take into account the object’s color.
float4 mainPS(float4 Color:COLOR0) : COLOR0
{
float4 objectColor = float4(1.0f, 0.5f, 0.31f, 1.0f);
float4 lightColor = float4(1.0f, 1.0f, 1.0f, 1.0f);
// ambient
float ambientStrength = 0.1;
float4 ambient = mul(ambientStrength,lightColor);
float4 pixel = mul(objectColor, ambient);
// return objectColor;
return pixel;
}
So if I just return the objectColor, the object will be rendered as orange but if I return the objectColor multiplied by the ambient light, it will come out black with white ambient light.
edit: thanks PumpkinPudding, all I had to do is: float4 pixel = objectColor + ambient;