Exemple #1
0
        public Graphics.LightmapResource ConvertToLightmap(string name, float exposure)
        {
            Graphics.OpenGl.OpenGLRenderer renderer = (Graphics.OpenGl.OpenGLRenderer)Graphics.RendererManager.CurrentRenderer;
            Graphics.LightmapResource      lightmap = new Graphics.LightmapResource(name, _maps.Length);

            for (int i = 0; i < _maps.Length; i++)
            {
                Graphics.BitmapSurface surface = Radiosity.ConvertColorMapToLightmap(_maps[i].Width, _maps[i].Height, exposure, _maps[i].Map);

                // go back and look for any unused texels
                for (int j = 0; j < _maps[i].Width * _maps[i].Height; j++)
                {
                    if (_maps[i].Map[j * 3] < 0)
                    {
                        surface.Pixels[j * 4 + 0] = 0;
                        surface.Pixels[j * 4 + 1] = 255;
                        surface.Pixels[j * 4 + 2] = 0;
                    }
                }

                lightmap.Maps[i] = surface;
            }

            lightmap.GenTextureAtlas();

            return(lightmap);
        }
Exemple #2
0
        public static Graphics.TextureResource GenerateMemoryTexture(int width, int height, float red, float green, float blue)
        {
            Graphics.OpenGl.OpenGLRenderer renderer = Graphics.RendererManager.CurrentRenderer as Graphics.OpenGl.OpenGLRenderer;

            if (renderer != null)
            {
                LightmapSurface surface = rad_GenerateMemoryTexture(width, height, red, green, blue);

                Graphics.OpenGl.GlTexture tex = new Graphics.OpenGl.GlTexture(renderer, "memtex", (int)surface.glTex, width, height, true);

                return(tex);
            }

            return(null);
        }