コード例 #1
0
        public void Update(int pipeline, int width, int height, int widthTex, int heightTex)
        {
            // This function is executed every frame at the beginning of a pass.
            view = Matrix4.CreateTranslation(-pos[0], -pos[1], -pos[2])
                   * Matrix4.CreateRotationY(-rot[1] * rad2deg)
                   * Matrix4.CreateRotationX(-rot[0] * rad2deg);
            float   aspect = (float)width / height;
            Matrix4 proj   = Matrix4.CreatePerspectiveFieldOfView(fov * rad2deg, aspect, near, far);

            // GET OR CREATE CAMERA UNIFORMS FOR program
            UniformBlock <Names> unif;

            if (uniform.TryGetValue(pipeline, out unif) == false)
            {
                uniform.Add(pipeline, unif = new UniformBlock <Names>(pipeline, name));
            }

            // SET UNIFORM VALUES
            if (unif.Has(Names.view))
            {
                unif.Set(Names.view, view.AsInt32());
            }

            if (unif.Has(Names.proj))
            {
                unif.Set(Names.proj, proj.AsInt32());
            }

            if (unif.Has(Names.viewProj))
            {
                unif.Set(Names.viewProj, (view * proj).AsInt32());
            }

            if (unif.Has(Names.camera))
            {
                unif.Set(Names.camera, new[] { fov *rad2deg, aspect, near, far }.AsInt32());
            }

            if (unif.Has(Names.position))
            {
                unif.Set(Names.position, pos.AsInt32());
            }

            if (unif.Has(Names.rotation))
            {
                unif.Set(Names.rotation, rot.AsInt32());
            }

            // UPDATE UNIFORM BUFFER
            unif.Update();
            unif.Bind();
        }
コード例 #2
0
        public void Update(int pipeline, int width, int height, int widthTex, int heightTex)
        {
            var view = Matrix4.CreateTranslation(-pos[0], -pos[1], -pos[2])
                       * Matrix4.CreateRotationY(-rot[1] * rad2deg)
                       * Matrix4.CreateRotationX(-rot[0] * rad2deg);
            var aspect = (float)width / height;
            var proj   = Matrix4.CreatePerspectiveFieldOfView(fov * rad2deg, aspect, near, far);

            // GET OR CREATE CAMERA UNIFORMS FOR program
            UniformBlock <Names> unif;

            if (uniform.TryGetValue(pipeline, out unif) == false)
            {
                uniform.Add(pipeline, unif = new UniformBlock <Names>(pipeline, name));
            }

            // SET UNIFORM VALUES
            unif.Set(Names.view, view.AsInt32());

            unif.Set(Names.proj, proj.AsInt32());

            if (unif.Has(Names.viewProj))
            {
                unif.Set(Names.viewProj, (view * proj).AsInt32());
            }

            if (unif.Has(Names.camera))
            {
                unif.Set(Names.camera, new[] { fov *rad2deg, aspect, near, far }.AsInt32());
            }

            if (unif.Has(Names.color))
            {
                unif.Set(Names.color, new[] { color[0], color[1], color[2], intensity }.AsInt32());
            }

            if (unif.Has(Names.light))
            {
                var x = near * (float)Math.Tan(fov * rad2deg);
                var y = x / aspect;
                unif.Set(Names.light, new[] { innerCone *rad2deg, radius, x, y }.AsInt32());
            }

            // UPDATE UNIFORM BUFFER
            unif.Update();
            unif.Bind();
        }
コード例 #3
0
ファイル: PoissonDisc.cs プロジェクト: h3tch/ProtoFX
        public void Update(int pipeline, int width, int height, int widthTex, int heightTex)
        {
            // GET OR CREATE POISSON DISC UNIFORMS FOR program
            UniformBlock <Names> unif;

            if (uniform.TryGetValue(pipeline, out unif) == false)
            {
                uniform.Add(pipeline, unif = new UniformBlock <Names>(pipeline, name));
                // SET UNIFORM VALUES
                unif.Set(Names.numPoints, new[] { points.GetLength(0) });
                unif.Set(Names.points, points);
                // UPDATE UNIFORM BUFFER
                unif.Update();
            }

            unif.Bind();
        }
コード例 #4
0
ファイル: ArtifactQuest.cs プロジェクト: h3tch/ProtoFX
        public void Update(int pipeline, int widthScreen, int heightScreen, int widthTex, int heightTex)
        {
            var sub     = quests[activeQuest];
            var size    = artifactSize[sub.artifactId];
            var angle   = lineAngles[sub.lineId];
            var samples = poissonDisc[sub.poissonId] != null
                ? poissonDisc[sub.poissonId].points.GetLength(0) : 0;

            var line = new[] { (float)Math.Sin(angle), (float)Math.Cos(angle), 0 };

            line[2] = line[0] * widthTex / 2 + line[1] * heightTex / 2;

            // GET OR CREATE CAMERA UNIFORMS FOR program
            UniformBlock <Names> unif;
            UniformBlock <Disc>  unifDisc;

            if (uniform.TryGetValue(pipeline, out unif) == false)
            {
                uniform.Add(pipeline, unif = new UniformBlock <Names>(pipeline, name));
            }
            if (uniformDisc.TryGetValue(pipeline, out unifDisc) == false)
            {
                uniformDisc.Add(pipeline, unifDisc = new UniformBlock <Disc>(pipeline, name + "Disc"));
            }

            // SET UNIFORM VALUES
            unif.Set(Names.rendertargetSize, new[] {
                widthTex, heightTex, widthScreen, heightScreen,
            });
            unif.Set(Names.lineAngle, new[] {
                (float)angle, randomAngle, size, sub.radius
            });

            unifDisc.Set(Disc.nPoints, new[] { samples });
            if (samples > 0)
            {
                unifDisc.Set(Disc.points, poissonDisc[sub.poissonId].points);
            }

            // UPDATE UNIFORM BUFFER
            unif.Update();
            unif.Bind();
            unifDisc.Update();
            unifDisc.Bind();
        }