Beispiel #1
0
        // pbr: create an irradiance cubemap.
        private Texture LoadIrradianceMap()
        {
            var dataProvider = new CubemapDataProvider(null, null, null, null, null, null);
            var storage      = new CubemapTexImage2D(GL.GL_RGB16F, 32, 32, GL.GL_RGB, GL.GL_FLOAT, dataProvider);
            var envCubeMap   = new Texture(storage,
                                           new TexParameteri(TexParameter.PropertyName.TextureWrapS, (int)GL.GL_CLAMP_TO_EDGE),
                                           new TexParameteri(TexParameter.PropertyName.TextureWrapT, (int)GL.GL_CLAMP_TO_EDGE),
                                           new TexParameteri(TexParameter.PropertyName.TextureWrapR, (int)GL.GL_CLAMP_TO_EDGE),
                                           new TexParameteri(TexParameter.PropertyName.TextureMinFilter, (int)GL.GL_LINEAR),
                                           new TexParameteri(TexParameter.PropertyName.TextureMagFilter, (int)GL.GL_LINEAR));

            envCubeMap.Initialize();
            return(envCubeMap);
        }
Beispiel #2
0
        private Texture LoadPrefliterMap()
        {
            var dataProvider = new CubemapDataProvider(null, null, null, null, null, null);
            var storage      = new CubemapTexImage2D(GL.GL_RGB16F, 128, 128, GL.GL_RGB, GL.GL_FLOAT, dataProvider, 6);
            var prefliterMap = new Texture(storage, new MipmapBuilder(),
                                           new TexParameteri(TexParameter.PropertyName.TextureWrapS, (int)GL.GL_CLAMP_TO_EDGE),
                                           new TexParameteri(TexParameter.PropertyName.TextureWrapT, (int)GL.GL_CLAMP_TO_EDGE),
                                           new TexParameteri(TexParameter.PropertyName.TextureWrapR, (int)GL.GL_CLAMP_TO_EDGE),
                                           new TexParameteri(TexParameter.PropertyName.TextureMinFilter, (int)GL.GL_LINEAR_MIPMAP_LINEAR),
                                           new TexParameteri(TexParameter.PropertyName.TextureMagFilter, (int)GL.GL_LINEAR));

            prefliterMap.Initialize();
            return(prefliterMap);
        }
Beispiel #3
0
        private Texture GetCubemapTexture(Bitmap totalBmp)
        {
            var            dataProvider = GetCubemapDataProvider(totalBmp);
            TexStorageBase storage      = new CubemapTexImage2D(GL.GL_RGBA, totalBmp.Width / 4, totalBmp.Height / 3, GL.GL_BGRA, GL.GL_UNSIGNED_BYTE, dataProvider);
            var            texture      = new Texture(storage,
                                                      new TexParameteri(TexParameter.PropertyName.TextureMagFilter, (int)GL.GL_LINEAR),
                                                      new TexParameteri(TexParameter.PropertyName.TextureMinFilter, (int)GL.GL_LINEAR),
                                                      new TexParameteri(TexParameter.PropertyName.TextureWrapS, (int)GL.GL_CLAMP_TO_EDGE),
                                                      new TexParameteri(TexParameter.PropertyName.TextureWrapT, (int)GL.GL_CLAMP_TO_EDGE),
                                                      new TexParameteri(TexParameter.PropertyName.TextureWrapR, (int)GL.GL_CLAMP_TO_EDGE));

            texture.Initialize();

            return(texture);
        }
Beispiel #4
0
        // pbr: setup cubemap to render to and attach to framebuffer
        private Texture LoadEnvCubeMap()
        {
            var dataProvider = new CubemapDataProvider(null, null, null, null, null, null);
            var storage      = new CubemapTexImage2D(GL.GL_RGB16F, 512, 512, GL.GL_RGB, GL.GL_FLOAT, dataProvider);
            var envCubeMap   = new Texture(storage,
                                           new MipmapBuilder(), // This is can also be done inside CubemapNode.DoInitialize().
                                           new TexParameteri(TexParameter.PropertyName.TextureWrapS, (int)GL.GL_CLAMP_TO_EDGE),
                                           new TexParameteri(TexParameter.PropertyName.TextureWrapT, (int)GL.GL_CLAMP_TO_EDGE),
                                           new TexParameteri(TexParameter.PropertyName.TextureWrapR, (int)GL.GL_CLAMP_TO_EDGE),
                                           new TexParameteri(TexParameter.PropertyName.TextureMinFilter, (int)GL.GL_LINEAR_MIPMAP_LINEAR),
                                           new TexParameteri(TexParameter.PropertyName.TextureMagFilter, (int)GL.GL_LINEAR));

            envCubeMap.Initialize();
            return(envCubeMap);
        }
Beispiel #5
0
        private Texture GetCubemapTexture(Bitmap[] bitmaps)
        {
            var dataProvider = new CubemapDataProvider(
                bitmaps[0], bitmaps[1], bitmaps[2], bitmaps[3], bitmaps[4], bitmaps[5]);
            var storage = new CubemapTexImage2D((int)GL.GL_RGBA, bitmaps[0].Width, bitmaps[0].Height, 0, GL.GL_BGRA, GL.GL_UNSIGNED_BYTE, dataProvider);
            var texture = new Texture(TextureTarget.TextureCubeMap, storage,
                                      new TexParameteri(TexParameter.PropertyName.TextureMagFilter, (int)GL.GL_LINEAR),
                                      new TexParameteri(TexParameter.PropertyName.TextureMinFilter, (int)GL.GL_LINEAR),
                                      new TexParameteri(TexParameter.PropertyName.TextureWrapS, (int)GL.GL_CLAMP_TO_EDGE),
                                      new TexParameteri(TexParameter.PropertyName.TextureWrapT, (int)GL.GL_CLAMP_TO_EDGE),
                                      new TexParameteri(TexParameter.PropertyName.TextureWrapR, (int)GL.GL_CLAMP_TO_EDGE));

            texture.Initialize();

            return(texture);
        }
Beispiel #6
0
        // pbr: create a pre-filter cubemap.
        private Texture LoadPrefilterMap()
        {
            var dataProvider = new CubemapDataProvider(null, null, null, null, null, null);
            var storage      = new CubemapTexImage2D(GL.GL_RGB16F, 128, 128, GL.GL_RGB, GL.GL_FLOAT, dataProvider);
            var envCubeMap   = new Texture(storage,
                                           // generate mipmaps for the cubemap so OpenGL automatically allocates the required memory.
                                           new MipmapBuilder(),
                                           new TexParameteri(TexParameter.PropertyName.TextureWrapS, (int)GL.GL_CLAMP_TO_EDGE),
                                           new TexParameteri(TexParameter.PropertyName.TextureWrapT, (int)GL.GL_CLAMP_TO_EDGE),
                                           new TexParameteri(TexParameter.PropertyName.TextureWrapR, (int)GL.GL_CLAMP_TO_EDGE),
                                           // be sure to set minifcation filter to mip_linear
                                           new TexParameteri(TexParameter.PropertyName.TextureMinFilter, (int)GL.GL_LINEAR_MIPMAP_LINEAR),
                                           new TexParameteri(TexParameter.PropertyName.TextureMagFilter, (int)GL.GL_LINEAR));

            envCubeMap.Initialize();
            return(envCubeMap);
        }