merge avec Sprite
en espérant que ça a rien kapout pt kc
This commit is contained in:
@@ -10,6 +10,7 @@ Texture2D shaderTexture : register(t0);
|
||||
SamplerState SampleType : register(s0);
|
||||
cbuffer LightBuffer
|
||||
{
|
||||
float4 ambientColor;
|
||||
float4 diffuseColor;
|
||||
float3 lightDirection;
|
||||
float padding;
|
||||
@@ -41,14 +42,23 @@ float4 LightPixelShader(PixelInputType input) : SV_TARGET
|
||||
// Sample the pixel color from the texture using the sampler at this texture coordinate location.
|
||||
textureColor = shaderTexture.Sample(SampleType, input.tex);
|
||||
|
||||
// Invert the light direction for calculations.
|
||||
// Set the default output color to the ambient light value for all pixels.
|
||||
color = ambientColor;
|
||||
|
||||
// Invert the light direction for calculations.
|
||||
lightDir = -lightDirection;
|
||||
|
||||
// Calculate the amount of light on this pixel.
|
||||
lightIntensity = saturate(dot(input.normal, lightDir));
|
||||
|
||||
// Determine the final amount of diffuse color based on the diffuse color combined with the light intensity.
|
||||
color = saturate(diffuseColor * lightIntensity);
|
||||
if(lightIntensity > 0.0f)
|
||||
{
|
||||
// Determine the final diffuse color based on the diffuse color and the amount of light intensity.
|
||||
color += (diffuseColor * lightIntensity);
|
||||
}
|
||||
|
||||
// Saturate the final light color.
|
||||
color = saturate(color);
|
||||
|
||||
// Multiply the texture pixel and the final diffuse color to get the final pixel color result.
|
||||
color = color * textureColor;
|
||||
|
||||
Reference in New Issue
Block a user