using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; namespace Kav { public class DeferredPBR_SpotLightEffect : Effect { EffectParameter gPositionParam; EffectParameter gAlbedoParam; EffectParameter gNormalParam; EffectParameter gMetallicRoughnessParam; EffectParameter shadowMapParam; EffectParameter eyePositionParam; EffectParameter lightPositionParam; EffectParameter lightDirectionParam; EffectParameter lightColorParam; EffectParameter lightCutoffParam; EffectParameter farPlaneParam; public Texture2D GPosition { get; set; } public Texture2D GAlbedo { get; set; } public Texture2D GNormal { get; set; } public Texture2D GMetallicRoughness { get; set; } public TextureCube ShadowMap { get; set; } public Vector3 EyePosition { get; set; } public Vector3 LightPosition { get; set; } public Vector3 LightDirection { get; set; } public Vector3 LightColor { get; set; } public float LightCutoff { get; set; } //could be named lightangle? public float FarPlane { get; set; } public DeferredPBR_SpotLightEffect(GraphicsDevice graphicsDevice) : base(graphicsDevice, Resources.DeferredPBR_SpotLightEffect) { CacheEffectParameters(); } protected override void OnApply() { gPositionParam.SetValue(GPosition); gAlbedoParam.SetValue(GAlbedo); gNormalParam.SetValue(GNormal); gMetallicRoughnessParam.SetValue(GMetallicRoughness); shadowMapParam.SetValue(ShadowMap); eyePositionParam.SetValue(EyePosition); lightPositionParam.SetValue(LightPosition); lightDirectionParam.SetValue(LightDirection); lightColorParam.SetValue(LightColor); lightCutoffParam.SetValue(LightCutoff); farPlaneParam.SetValue(FarPlane); } private void CacheEffectParameters() { gPositionParam = Parameters["gPosition"]; gAlbedoParam = Parameters["gAlbedo"]; gNormalParam = Parameters["gNormal"]; gMetallicRoughnessParam = Parameters["gMetallicRoughness"]; shadowMapParam = Parameters["shadowMap"]; eyePositionParam = Parameters["EyePosition"]; lightPositionParam = Parameters["LightPosition"]; lightDirectionParam = Parameters["LightDirection"]; lightColorParam = Parameters["LightColor"]; lightCutoffParam = Parameters["LightCutoff"]; farPlaneParam = Parameters["FarPlane"]; } } }