コード例 #1
0
ファイル: Scene.cs プロジェクト: Caerostris/SimProvider
        public Scene(int wdh, int hgt)
        {
            width  = wdh;
            height = hgt;

            initGL();

            load();
            initObjects();

            //init matrices
            view       = Matrix4.LookAt(new Vector3(0, 1.75f, 1.75f), new Vector3(0, 1.5f, 0), Vector3.UnitY);
            projection = Matrix4.CreatePerspectiveFieldOfView(MathHelper.DegreesToRadians(75), wdh / hgt, 0.1f, 300.0f);

            depthProjection = Matrix4.CreateOrthographicOffCenter(-30, 30, -30, 30, -30, 100);
            depthView       = Matrix4.LookAt(sunLightSrc, sunLightSrc + sunLightDir, Vector3.UnitY);

            psvp = Matrix4.CreateOrthographic(1, 1, -5, 5);

            //load shader
            sp = BasicShader.create("Data/Shader/basic.v", "Data/Shader/basic.f");
            sp.addUniform("modelTexture");
            sp.addUniform("shadowmap");
            sp.addUniform("lightdir");
            sp.addUniform("lightstr");
            sp.addUniform("ambient");
            sp.addUniform("modelViewProjection");
            sp.addUniform("model");
            //sp.addUniform("view");
            sp.addUniform("bias");
            //sp.addUniform("projection");
            sp.addUniform("shadowMat0");
            sp.addUniform("shadowMat1");
            sp.addUniform("shadowMat2");
            sp.addUniform("slices");

            sp.use();
            GL.UniformMatrix4(sp.Uniforms["bias"], false, ref bias);
            GL.UseProgram(0);

            depthShader = BasicShader.create("Data/Shader/depthShader.v", "Data/Shader/depthShader.f");
            depthShader.addUniform("model");
            depthShader.addUniform("view");
            depthShader.addUniform("projection");
            depthShader.addUniform("modelTexture");

            ps = BasicShader.create("Data/Shader/ps.v", "Data/Shader/ps.f");
            ps.addUniform("tex");
            ps.addUniform("texZ");

            bs = BasicShader.create("Data/Shader/basicShader.v", "Data/Shader/basicShader.f");
            bs.addUniform("mvp");
        }
コード例 #2
0
ファイル: Scene.cs プロジェクト: Caerostris/SimProvider
        public Scene(int wdh, int hgt)
        {
            width = wdh;
            height = hgt;

            initGL();

            load();
            initObjects();

            //init matrices
            view = Matrix4.LookAt(new Vector3(0, 1.75f, 1.75f), new Vector3(0, 1.5f, 0), Vector3.UnitY);
            projection = Matrix4.CreatePerspectiveFieldOfView(MathHelper.DegreesToRadians(75), wdh / hgt, 0.1f, 300.0f);

            depthProjection = Matrix4.CreateOrthographicOffCenter(-30, 30, -30, 30, -30, 100);
            depthView = Matrix4.LookAt(sunLightSrc, sunLightSrc + sunLightDir, Vector3.UnitY);

            psvp = Matrix4.CreateOrthographic(1, 1, -5, 5);

            //load shader
            sp = BasicShader.create("Data/Shader/basic.v", "Data/Shader/basic.f");
            sp.addUniform("modelTexture");
            sp.addUniform("shadowmap");
            sp.addUniform("lightdir");
            sp.addUniform("lightstr");
            sp.addUniform("ambient");
            sp.addUniform("modelViewProjection");
            sp.addUniform("model");
            //sp.addUniform("view");
            sp.addUniform("bias");
            //sp.addUniform("projection");
            sp.addUniform("shadowMat0");
            sp.addUniform("shadowMat1");
            sp.addUniform("shadowMat2");
            sp.addUniform("slices");

            sp.use();
            GL.UniformMatrix4(sp.Uniforms["bias"], false, ref bias);
            GL.UseProgram(0);

            depthShader = BasicShader.create("Data/Shader/depthShader.v", "Data/Shader/depthShader.f");
            depthShader.addUniform("model");
            depthShader.addUniform("view");
            depthShader.addUniform("projection");
            depthShader.addUniform("modelTexture");

            ps = BasicShader.create("Data/Shader/ps.v", "Data/Shader/ps.f");
            ps.addUniform("tex");
            ps.addUniform("texZ");

            bs = BasicShader.create("Data/Shader/basicShader.v", "Data/Shader/basicShader.f");
            bs.addUniform("mvp");
        }