Beispiel #1
0
        private static void SetPointLightShaderGlobals(IRenderPass2D pass, CommandBuffer cmd, Light2D light)
        {
            // This is used for the lookup texture
            GetScaledLightInvMatrix(light, out var lightInverseMatrix);

            var innerRadius     = GetNormalizedInnerRadius(light);
            var innerAngle      = GetNormalizedAngle(light.pointLightInnerAngle);
            var outerAngle      = GetNormalizedAngle(light.pointLightOuterAngle);
            var innerRadiusMult = 1 / (1 - innerRadius);

            cmd.SetGlobalVector(k_LightPositionID, light.transform.position);
            cmd.SetGlobalMatrix(k_LightInvMatrixID, lightInverseMatrix);
            cmd.SetGlobalFloat(k_InnerRadiusMultID, innerRadiusMult);
            cmd.SetGlobalFloat(k_OuterAngleID, outerAngle);
            cmd.SetGlobalFloat(k_InnerAngleMultID, 1 / (outerAngle - innerAngle));
            cmd.SetGlobalTexture(k_LightLookupID, Light2DLookupTexture.GetLightLookupTexture());
            cmd.SetGlobalTexture(k_FalloffLookupID, pass.rendererData.fallOffLookup);
            cmd.SetGlobalFloat(k_FalloffIntensityID, light.falloffIntensity);
            cmd.SetGlobalFloat(k_IsFullSpotlightID, innerAngle == 1 ? 1.0f : 0.0f);

            cmd.SetGlobalFloat(k_LightZDistanceID, light.normalMapDistance);

            if (light.lightCookieSprite != null && light.lightCookieSprite.texture != null)
            {
                cmd.SetGlobalTexture(k_PointLightCookieTexID, light.lightCookieSprite.texture);
            }
        }
Beispiel #2
0
        static Texture GetFalloffLookupTexture()
        {
            if (s_FalloffLookupTexture == null)
            {
                s_FalloffLookupTexture = Light2DLookupTexture.CreateFalloffLookupTexture();
            }

            return(s_FalloffLookupTexture);
        }
Beispiel #3
0
        static Texture GetLightLookupTexture()
        {
            if (s_LightLookupTexture == null)
            {
                s_LightLookupTexture = Light2DLookupTexture.CreatePointLightLookupTexture();
            }

            return(s_LightLookupTexture);
        }