Exemple #1
0
 public static void MapSimpleLightsToShader(ShaderProgram sp)
 {
     sp.SetUniform("SimpleLightsCount", SimpleLights.Count);
     sp.SetUniformArray("SimpleLightsPos", SimpleLights.Select<SimplePointLight, Vector3>(a => a.Transformation.GetPosition()).ToArray());
     sp.SetUniformArray("SimpleLightsColors", SimpleLights.Select<SimplePointLight, Vector4>(a =>
         new Vector4(a.Color.R / 255.0f, a.Color.G / 255.0f, a.Color.B / 255.0f, a.Color.A / 255.0f)).ToArray());
 }
Exemple #2
0
 private void SetLightingUniforms(ShaderProgram shader)
 {
     shader.SetUniformArray("LightsPs", LightPool.GetPMatrices());
     shader.SetUniformArray("LightsVs", LightPool.GetVMatrices());
     shader.SetUniformArray("LightsPos", LightPool.GetPositions());
     shader.SetUniformArray("LightsFarPlane", LightPool.GetFarPlanes());
     shader.SetUniformArray("LightsColors", LightPool.GetColors());
     shader.SetUniformArray("LightsRanges", LightPool.GetRanges());
     shader.SetUniformArray("LightsMixModes", LightPool.GetMixModes());
     shader.SetUniform("LightsCount", LightPool.GetPositions().Length);
 }
Exemple #3
0
        public void SetLightingUniforms(ShaderProgram shader)
        {
            // MEMORY LEAK
            pmats = new List<Matrix4>();
            shadowmaplayers = new List<int>();
            vmats = new List<Matrix4>();
            poss = new List<Vector3>();
            fplanes = new List<float>();
            colors = new List<Vector4>();
            mmodes = new List<int>();
            ipointer = 0;

            foreach(var e in Lights)
                if(e is IShadowMapableLight)
                {
                    var l = e as IShadowMapableLight;
                    var p = e as ILight;
                    pmats.Add(l.GetPMatrix());
                    vmats.Add(l.GetVMatrix());
                    shadowmaplayers.Add((l as ProjectionLight).ShadowMapArrayIndex);
                    poss.Add(p.GetPosition());
                    colors.Add(new Vector4(p.GetColor()));
                    ipointer++;
                }
            Game.ShadowMaps.Bind(0);
            shader.SetUniformArray("LightsPs", pmats.ToArray());
            shader.SetUniformArray("LightsVs", vmats.ToArray());
            shader.SetUniformArray("LightsShadowMapsLayer", shadowmaplayers.ToArray());
            shader.SetUniformArray("LightsPos", poss.ToArray());
            shader.SetUniformArray("LightsFarPlane", fplanes.ToArray());
            shader.SetUniformArray("LightsColors", colors.ToArray());
            shader.SetUniform("LightsCount", pmats.Count);
            pmats = new List<Matrix4>();
            vmats = new List<Matrix4>();
            poss = new List<Vector3>();
            fplanes = new List<float>();
            colors = new List<Vector4>();
            mmodes = new List<int>();
        }