public MainVisual(IRenderState renderState, IContentLoader contentLoader)
        {
            renderState.Set(new ClearColorState(1, 1, 1, 1));
            renderState.Set(new DepthTest(true));
            renderState.Set(new FaceCullingModeState(FaceCullingMode.BACK_SIDE));

            var envMap = contentLoader.Load <ITexture2D>("beach");

            envMap.WrapFunction = TextureWrapFunction.MirroredRepeat;
            envMap.Filter       = TextureFilterMode.Linear;
            var textureBinding = new TextureBinding[] { new TextureBinding(nameof(envMap), envMap) };

            var sphere = Meshes.CreateSphere(1f, 4);

            var skySphere        = sphere.Transform(Transformation.Scale(200f)).SwitchTriangleMeshWinding();
            var shaderBackground = contentLoader.Load <IShaderProgram>("background.*");

            visuals.Add(new MeshVisual(skySphere, shaderBackground, textureBinding));

#if SOLUTION
            var shaderEnvMap = contentLoader.Load <IShaderProgram>("envMapping.*");
            var visSphere    = new MeshVisual(sphere, shaderEnvMap, textureBinding);
            visSphere.SetUniform("reflective", 1f);
            visuals.Add(visSphere);
            var suzanne    = contentLoader.Load <DefaultMesh>("suzanne");
            var visSuzanne = new MeshVisual(suzanne.Transform(Transformation.Translation(0, -1.5f, 0)), shaderEnvMap, textureBinding);
            visSuzanne.SetUniform("reflective", 0.4f);
            visuals.Add(visSuzanne);
#endif
        }
Beispiel #2
0
        public void Resize(int width, int height)
        {
            var texNormalMaterial = Texture2dGL.Create(width, height, 4, true);
            var texPosition       = Texture2dGL.Create(width, height, 4, true);

            mrtSurface = new FBOwithDepth(texNormalMaterial);
            mrtSurface.Attach(texPosition);
            var bindings = new List <TextureBinding>()
            {
                new TextureBinding(nameof(texNormalMaterial), texNormalMaterial),
                new TextureBinding(nameof(texPosition), texPosition),
            };

            lightsVisual = new MeshVisual(lightsVisual.Drawable, lightsVisual.ShaderProgram, bindings);
            lightsVisual.SetUniform(new FloatUniform("lightIntensity", LightIntensity));
            lightsVisual.SetUniform(new FloatUniform("lightRange", LightRange));
        }