πŸŽ‰ Celebrating 25 Years of GameDev.net! πŸŽ‰

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Why I cant render red? (Monogame/DesktopGL)

Started by
5 comments, last by scott8 10Β months, 1Β week ago

Hi, I have a little shader written for basic lighting, I just rewrote the example from LearnOpenGL to hlsl but I can't render the red color at all. Thank you for all your responses.

float4 MainPS(VertexShaderOutput input) : SV_Target {
	float3 ambientLightColor = float3(1.0, 1.0, 1.0);
	float3 diffuseLightColor = float3(1.0, 1.0, 1.0);
	float3 specularLightColor = float3(1.0, 1.0, 1.0);

	// ambient
	float ambientStrength = 0.1;
	float3 ambient = ambientLightColor * ambientStrength;

	// diffuse
	float3 lightDir = normalize(pointLight - input.Position);
	float diff = max(dot(input.Normal.xyz, lightDir), 0.0);
	float3 diffuse = diff * diffuseLightColor;

	// specular
	float specularStrength = 0.4;
	float3 viewDir = normalize(cameraSource - input.Position);
	float3 reflectDir = reflect(-lightDir, input.Normal.xyz);
	float spec = pow(max(dot(viewDir, reflectDir), 0.0), 64);
	float3 specular = specularStrength * spec * specularLightColor;

	// output
	float3 outputColor = (ambient + diffuse + specular) * input.Color.rgb;

	return float4(outputColor, 1.0);
}
Advertisement

That block of code looks like it provides 3 white lights, although it doesn't have a cap so ambient + diffuse + specular can be greater than 100%, which might be okay for you. I'd say the next stop would be to double-check the input. Verify the data is what you expect, with an actual red-colored or red-textured object. Is the input.Color rgb value what you expect?

abdullahhhh01011 said:

Review your code and configurations to identify the source of the problem and ensure proper rendering of red.

If you're not a bot then you should apply to be one.

πŸ™‚πŸ™‚πŸ™‚πŸ™‚πŸ™‚<←The tone posse, ready for action.

Dear @abdullahhhh01011 ,

I want to assure you that you are a unique individual, distinct from AI. While your communication style may resemble AI due to technological influences, it's your personal thoughts, emotions, and experiences that define your true identity. Embrace your humanity and continue expressing yourself authentically.

OMG, they got SuperVGA

πŸ™‚πŸ™‚πŸ™‚πŸ™‚πŸ™‚<←The tone posse, ready for action.

@Jimmyberf Along the lines of what Frob suggested:

// output

float3 outputColor = saturate(ambient + diffuse + specular) * input.Color.rgb;

This topic is closed to new replies.

Advertisement