flat sprite lighting in deferred pipeline
parent
3338bf3b06
commit
d537993530
|
@ -18,8 +18,6 @@ namespace Kav
|
|||
|
||||
EffectParameter farPlaneParam;
|
||||
|
||||
EffectParameter worldParam;
|
||||
EffectParameter worldInverseParam;
|
||||
EffectParameter worldViewProjectionParam;
|
||||
|
||||
public Texture2D GPosition { get; set; }
|
||||
|
@ -47,7 +45,7 @@ namespace Kav
|
|||
set
|
||||
{
|
||||
world = value;
|
||||
dirtyFlags |= EffectDirtyFlags.WorldViewProj | EffectDirtyFlags.World;
|
||||
dirtyFlags |= EffectDirtyFlags.WorldViewProj;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -114,14 +112,6 @@ namespace Kav
|
|||
|
||||
farPlaneParam.SetValue(FarPlane);
|
||||
|
||||
if ((dirtyFlags & EffectDirtyFlags.World) != 0)
|
||||
{
|
||||
worldParam.SetValue(world);
|
||||
worldInverseParam.SetValue(Matrix.Invert(world));
|
||||
|
||||
dirtyFlags &= ~EffectDirtyFlags.World;
|
||||
}
|
||||
|
||||
if ((dirtyFlags & EffectDirtyFlags.WorldViewProj) != 0)
|
||||
{
|
||||
worldViewProjectionParam.SetValue(world * view * projection);
|
||||
|
@ -145,8 +135,6 @@ namespace Kav
|
|||
|
||||
farPlaneParam = Parameters["FarPlane"];
|
||||
|
||||
worldParam = Parameters["World"];
|
||||
worldInverseParam = Parameters["WorldInverse"];
|
||||
worldViewProjectionParam = Parameters["WorldViewProjection"];
|
||||
}
|
||||
}
|
||||
|
|
BIN
Effects/FXB/DeferredPBR_PointLightEffect.fxb (Stored with Git LFS)
BIN
Effects/FXB/DeferredPBR_PointLightEffect.fxb (Stored with Git LFS)
Binary file not shown.
|
@ -21,8 +21,6 @@ BEGIN_CONSTANTS
|
|||
|
||||
MATRIX_CONSTANTS
|
||||
|
||||
float4x4 WorldInverse _ps(c4) _cb(c8);
|
||||
float4x4 World _ps(c8) _cb(c12);
|
||||
float4x4 WorldViewProjection _vs(c0) _cb(c4);
|
||||
|
||||
END_CONSTANTS
|
||||
|
@ -88,17 +86,26 @@ float4 main_ps(PixelInput input) : SV_TARGET0
|
|||
float3 albedo = SAMPLE_TEXTURE(gAlbedo, texCoord).rgb;
|
||||
float2 metallicRoughness = SAMPLE_TEXTURE(gMetallicRoughness, texCoord).rg;
|
||||
|
||||
float3 objectZNormal = mul(normal, WorldInverse);
|
||||
objectZNormal.xz *= -1;
|
||||
float3 invertedZNormalWorld = mul(objectZNormal, World);
|
||||
if (isSprite == 1.0)
|
||||
{
|
||||
float3 lightDir = PointLightPosition - worldPosition;
|
||||
float3 L = normalize(lightDir);
|
||||
float distance = length(lightDir);
|
||||
float attenuation = 1.0 / (distance * distance);
|
||||
float3 radiance = PointLightColor * attenuation;
|
||||
|
||||
return ComputeColor(
|
||||
worldPosition,
|
||||
normal,
|
||||
albedo,
|
||||
metallicRoughness.r,
|
||||
metallicRoughness.g
|
||||
) + (isSprite * ComputeColor(worldPosition, invertedZNormalWorld, albedo, metallicRoughness.r, metallicRoughness.g));
|
||||
return float4(albedo * radiance * 0.1, 1.0);
|
||||
}
|
||||
else
|
||||
{
|
||||
return ComputeColor(
|
||||
worldPosition,
|
||||
normal,
|
||||
albedo,
|
||||
metallicRoughness.r,
|
||||
metallicRoughness.g
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Technique DeferredPBR_Point
|
||||
|
|
Loading…
Reference in New Issue