public void ResolveShadows(LightArea Area, bool attenuateShadows, Texture mask = null) { var Result = Area.RenderTarget; var MaskTexture = mask == null ? Area.Mask.Texture : mask; var MaskProps = Vector4.Zero; var diffuseColor = Vector4.One; ExecuteTechnique(Area.RenderTarget, distancesRT, "ComputeDistances"); ExecuteTechnique(distancesRT, distortRT, "Distort"); // Working now ApplyHorizontalReduction(distortRT, shadowMap); //only DrawShadows needs these vars resolveShadowsEffectTechnique["DrawShadows"].SetUniform("AttenuateShadows", attenuateShadows ? 0 : 1); resolveShadowsEffectTechnique["DrawShadows"].SetUniform("MaskProps", MaskProps); resolveShadowsEffectTechnique["DrawShadows"].SetUniform("DiffuseColor", diffuseColor); var maskSize = MaskTexture.Size; var MaskTarget = new RenderImage("MaskTarget", maskSize.X, maskSize.Y); ExecuteTechnique(MaskTarget, Result, "DrawShadows", shadowMap); resolveShadowsEffectTechnique["DrawShadows"].ResetCurrentShader(); }
public void ResolveShadows(LightArea Area, bool attenuateShadows, Texture mask = null) { var Result = Area.RenderTarget; var MaskTexture = mask ?? Area.Mask.Texture; var MaskProps = Vector4.Zero; var diffuseColor = Vector4.One; ExecuteTechnique(Area.RenderTarget, distancesRT, "ComputeDistances"); ExecuteTechnique(distancesRT, distortRT, "Distort"); // Working now ApplyHorizontalReduction(distortRT, shadowMap); //only DrawShadows needs these vars resolveShadowsEffectTechnique["DrawShadows"].SetUniform("AttenuateShadows", attenuateShadows ? 0 : 1); resolveShadowsEffectTechnique["DrawShadows"].SetUniform("MaskProps", MaskProps); resolveShadowsEffectTechnique["DrawShadows"].SetUniform("DiffuseColor", diffuseColor); var maskSize = MaskTexture.Size; // I have TRIED to get this to work without this blank one. // I give the hell up. // I'll just cache them so they're not being recreated constantly. if (!BlankRenderImages.TryGetValue(maskSize, out var MaskTarget)) { MaskTarget = new RenderImage("MaskTarget", maskSize.X, maskSize.Y); BlankRenderImages[maskSize] = MaskTarget; } ExecuteTechnique(MaskTarget, Result, "DrawShadows", shadowMap); resolveShadowsEffectTechnique["DrawShadows"].ResetCurrentShader(); }