Esempio n. 1
0
 public ActionResult Edit(Uniform Update, int id)
 {
     if (Session["Username"] == null && Session["Password"] == null)
     {
         return(RedirectToAction("Index", "Admin", new { area = "" }));
     }
     else
     {
         if (ModelState.IsValid)
         {
             Uniforms UpdateUniform = new Uniforms();
             UpdateUniform.Name         = Update.Name;
             UpdateUniform.Class_lvl_id = Update.Class_lvl_id;
             HttpPostedFileBase imgFile = Request.Files["Picture"];
             if (imgFile.ContentLength > 0)
             {
                 string ext     = imgFile.FileName.Substring(imgFile.FileName.LastIndexOf("."));
                 string imgName = DateTime.Now.Ticks + ext;
                 string webpath = "~/Uniforms/" + imgName;
                 imgFile.SaveAs(Request.MapPath(webpath));
                 UpdateUniform.Picture = imgName;
                 new Cateloge().UpdateUniform_img(UpdateUniform, id);
             }
             else
             {
                 new Cateloge().UpdateUniform(UpdateUniform, id);
             }
             TempData["Msg"] = "Uniform Have Updated Successfully";
             return(RedirectToAction("Index"));
         }
         return(View(Update));
     }
 }
Esempio n. 2
0
        public async Task <IActionResult> Edit(int id, [Bind("UniformsId,UniformsName,UniformsColor,TeamsId")] Uniforms uniforms)
        {
            if (id != uniforms.UniformsId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(uniforms);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!UniformsExists(uniforms.UniformsId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["TeamsId"] = new SelectList(_context.Teams, "TeamsId", "TeamsId", uniforms.TeamsId);
            return(View(uniforms));
        }
Esempio n. 3
0
        public void checkNameOfNonWrittenUniformsColor()
        {
            Uniforms uniforms = new Uniforms();
            String   result   = uniforms.UniformsColor;

            Assert.AreEqual("White", result);
        }
Esempio n. 4
0
        protected override void Start()
        {
            base.Start();

            if (OrthoCpuProducerGameObject != null)
            {
                OrthoCPUProducer = OrthoCpuProducerGameObject.GetComponent <OrthoCPUProducer>();
            }

            int tileSize = Cache.GetStorage(0).TileSize;

            if (OrthoCPUProducer != null && OrthoCPUProducer.GetTileSize(0) != tileSize)
            {
                throw new InvalidParameterException("ortho CPU tile size must match ortho tile size");
            }

            if (!(Cache.GetStorage(0) is GPUTileStorage))
            {
                throw new InvalidStorageException("Storage must be a GPUTileStorage");
            }

            uniforms = new Uniforms();

            Noise = new PerlinNoise(Seed);

            ResidualTexture            = new Texture2D(tileSize, tileSize, TextureFormat.ARGB32, false);
            ResidualTexture.wrapMode   = TextureWrapMode.Clamp;
            ResidualTexture.filterMode = FilterMode.Point;

            CreateOrthoNoise();
        }
Esempio n. 5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="control"></param>
        public override void Load(Control control)
        {
            base.Load(control);

            camera = new Camera();
            this.camera.Position.Z = 1;

            scene = new Scene();

            var geometry = new PlaneGeometry(2, 2);

            uniforms = new Uniforms
            {
                { "time", new Uniform()
                  {
                      { "type", "f" }, { "value", 1.0f }
                  } },
                { "resolution", new Uniform()
                  {
                      { "type", "v2" }, { "value", new Vector2() }
                  } }
            };

            var material = new ShaderMaterial(null)
            {
                Uniforms       = uniforms,
                VertexShader   = VertexShader,
                FragmentShader = FragmentShader,
            };

            mesh = new Mesh(geometry, material);
            scene.Add(mesh);
        }
        private List <Uniforms> fetchUniforms(SqlCommand cmd)
        {
            SqlConnection   con      = cmd.Connection;
            List <Uniforms> uniforms = null;

            con.Open();
            using (con)
            {
                SqlDataReader dr = cmd.ExecuteReader();
                if (dr.HasRows)
                {
                    uniforms = new List <Uniforms>();
                    while (dr.Read())
                    {
                        Uniforms u = new Uniforms();
                        u.db_Id        = Convert.ToString(dr["id"]);
                        u.Name         = Convert.ToString(dr["name"]);
                        u.Class_lvl_id = Convert.ToString(dr["class_lvl_id"]);
                        u.Picture      = Convert.ToString(dr["picture"]);
                        u.Publish      = Convert.ToString(dr["publish"]);
                        uniforms.Add(u);
                    }
                    uniforms.TrimExcess();
                }
            }
            return(uniforms);
        }
Esempio n. 7
0
        /// <summary>
        /// Main function in this program, render shader with his file name
        /// </summary>
        public void RenderShader(string nameOfShaderFile, SettingModel model)
        {
            string fShaderSource = null;

            ShaderLoader.LoadShader(nameOfShaderFile, out fShaderSource);
            if (fShaderSource == null)
            {
                _logger.LoadShaderError();
                return;
            }

            if (!ShaderLoader.InitShaders(fShaderSource, out program))
            {
                _logger.InitShaderError();
                return;
            }

            nVertices = InitVertexBuffers();
            if (nVertices <= 0)
            {
                _logger.WritePosError();
                return;
            }

            uniforms = new Uniforms(model, program);

            GL.ClearColor(Color.SteelBlue);
            canDraw = true;
        }
Esempio n. 8
0
 public Deformation()
 {
     m_uniforms       = new Uniforms();
     m_localToCamera  = new Matrix4x4d();
     m_localToScreen  = new Matrix4x4d();
     m_localToTangent = new Matrix3x3d();
 }
Esempio n. 9
0
 public DeformationBase()
 {
     uniforms       = new Uniforms();
     localToCamera  = Matrix4x4d.identity;
     localToScreen  = Matrix4x4d.identity;
     localToTangent = Matrix3x3d.identity;
 }
Esempio n. 10
0
 public Deformation()
 {
     m_uniforms = new Uniforms();
     m_localToCamera = new Matrix4x4d();
     m_localToScreen = new Matrix4x4d();
     m_localToTangent = new Matrix3x3d();
 }
Esempio n. 11
0
        public ActionResult Publish(Uniform pu, int id)
        {
            if (Session["Username"] == null && Session["Password"] == null)
            {
                return(RedirectToAction("Index", "Admin", new { area = "" }));
            }
            else
            {
                if (ModelState.IsValid)
                {
                    Uniforms PublishUniform = new Uniforms();
                    PublishUniform.Publish = pu.Publish;
                    new Cateloge().PublishUniform(PublishUniform, id);
                    if (pu.Publish == "2")
                    {
                        TempData["Msg"] = "This Uniform Have Published Successfully";
                    }
                    else
                    {
                        TempData["Msg"] = "This Uniform Have Blocked Successfully";
                    }
                    return(RedirectToAction("View", new { id = id }));
                }

                return(RedirectToAction("Index"));
            }
        }
Esempio n. 12
0
        public ActionResult Create(Uniform Add)
        {
            if (Session["Username"] == null && Session["Password"] == null)
            {
                return(RedirectToAction("Index", "Admin", new { area = "" }));
            }
            else
            {
                if (ModelState.IsValid)
                {
                    Uniforms AddUniform = new Uniforms();
                    AddUniform.Name         = Add.Name;
                    AddUniform.Class_lvl_id = Add.Class_lvl_id;
                    HttpPostedFileBase imgFile = Request.Files["Picture"];
                    if (imgFile.ContentLength > 0)
                    {
                        string ext     = imgFile.FileName.Substring(imgFile.FileName.LastIndexOf("."));
                        string imgName = DateTime.Now.Ticks + ext;
                        string webpath = "~/Uniforms/" + imgName;
                        imgFile.SaveAs(Request.MapPath(webpath));
                        AddUniform.Picture = imgName;
                    }
                    AddUniform.Date  = DateTime.Today.ToString("dd-MM-yyyy");
                    AddUniform.Month = DateTime.Today.ToString("MMM");
                    AddUniform.Year  = DateTime.Today.ToString("yyyy");
                    AddUniform.Time  = DateTime.Now.ToString("HH:mm:ss");
                    new Cateloge().AddUniform(AddUniform);
                    TempData["Msg"] = "New Uniform Have Added Successfully";
                    return(RedirectToAction("Index"));
                }

                return(RedirectToAction("Index"));
            }
        }
Esempio n. 13
0
 protected override void InitNode()
 {
     Producer    = GetComponent <TileProducer>();
     TerrainNode = GetComponentInParent <TerrainNode>();
     uniforms    = new Uniforms(Producer.GetName());
     Filters     = GetComponents <TileFilter>();
 }
Esempio n. 14
0
        /// <summary>
        /// Reloads the shader if marked to reload, binds the shader, uploads all changed uniforms;
        /// </summary>
        public bool Bind()
        {
            if (LoadState == State.NotLoaded)
            {
                Load();
            }
            else if (ShouldReload)
            {
                Log.Info("Reloading " + file.VirtualPath);
                Dispose();
                Load();
                ShouldReload = false;
            }

            if (LoadState == State.LoadedError)
            {
                return(false);
            }

            if (lastBindedShaderHandle != ShaderProgramHandle)
            {
                GL.UseProgram(ShaderProgramHandle); MyGL.Check();
                lastBindedShaderHandle = ShaderProgramHandle;
            }
            Uniforms.UploadChangedUniforms(this);
            return(true);
        }
Esempio n. 15
0
 public DeformationBase()
 {
     uniforms       = new Uniforms();
     localToCamera  = new Matrix4x4d();
     localToScreen  = new Matrix4x4d();
     localToTangent = new Matrix3x3d();
 }
Esempio n. 16
0
        /// <summary>
        /// Merges two sourcedescriptions to a single description
        /// This is required for HLSL for example as it allows only
        /// compiling + linking one file
        /// </summary>
        public SourceDescription Merge(SourceDescription other)
        {
            //var funs = Functions.Union(other.Functions, Compare<FunctionDescription>((a, b) => a.Name == b.Name)).ToList();
            //Functions.Except(other.Functions, )

            var funcComparer = new Comparer <FunctionDescription>(
                (a, b) =>
            {
                if (a.Name != b.Name)
                {
                    return(false);
                }
                if (a.Body != b.Body)
                {
                    throw new SLSharpException(a.Name + " has been redeclared with different body");
                }
                return(true);
            });
            var variableComparer = new Comparer <VariableDescription>(
                (a, b) =>
            {
                if (a != b)
                {
                    return(false);
                }
                if (a.Type != b.Type)
                {
                    throw new SLSharpException("Type mismatch during variable merge");
                }
                if (a.Semantic != b.Semantic)
                {
                    throw new SLSharpException("Semantic mismatch during variable merge");
                }
                return(true);
            });


            // duplicate def actually occurs when a func has been defined as
            // vertex as well as fragment code
            //
            //var doubles = Functions.Except(other.Functions, funcComparer);
            //if (doubles.Count() != 0)
            //    throw new SLSharpException("Method declared twice: " + doubles.First().Name);
            //var funcs = Functions.Concat(other.Functions).ToList();

            var funcs = Functions.Union(other.Functions, funcComparer).ToList();

            // union global vars
            var uniforms = Uniforms.Union(other.Uniforms, variableComparer).ToList();
            var varyings = Varyings.Union(other.Varyings, variableComparer).ToList();
            var attribs  = Attributes.Union(other.Attributes, variableComparer).ToList();
            var ins      = VertexIns.Union(other.VertexIns, variableComparer).ToList();
            var outs     = FragmentOuts.Union(other.FragmentOuts, variableComparer).ToList();

            // union forward declartations
            var fdecl = ForwardDecl.Union(other.ForwardDecl).ToList();

            return(new SourceDescription(funcs, uniforms, attribs, varyings, ins, outs, fdecl));
        }
Esempio n. 17
0
        protected internal virtual ShaderUniformInfo addShaderUniform(Uniforms uniform, string type, int matrixSize)
        {
            ShaderUniformInfo shaderUniformInfo = new ShaderUniformInfo(uniform, type, matrixSize);

            shaderUniformInfos.Add(shaderUniformInfo);

            return(shaderUniformInfo);
        }
Esempio n. 18
0
 public ShaderUniformInfo(Uniforms uniform, string type, int matrixSize)
 {
     name            = uniform.UniformString;
     structureName   = string.Format("{0}[{1:D}]", name, matrixSize);
     this.type       = type;
     this.matrixSize = matrixSize;
     used            = true;
 }
Esempio n. 19
0
 public ShaderUniformInfo(Uniforms uniform, string type)
 {
     name          = uniform.UniformString;
     structureName = this.name;
     this.type     = type;
     used          = true;
     matrixSize    = 0;
 }
Esempio n. 20
0
 public HableCurve()
 {
     for (int i = 0; i < 3; i++)
     {
         segments[i] = new Segment();
     }
     uniforms = new Uniforms(this);
 }
Esempio n. 21
0
        public void PublishUniform(Uniforms pu, int id)
        {
            SqlCommand cmd = new SqlCommand("Update uniform Set publish=@Publish Where id = @Id", DALUtil.getConnection());

            cmd.Parameters.AddWithValue("@Id", id);
            cmd.Parameters.AddWithValue("@Publish", (pu.Publish == null) ? Convert.DBNull : pu.Publish);
            uniform(cmd);
        }
Esempio n. 22
0
        public override void InitNode()
        {
            Producer    = GetComponent <TileProducer>();
            TerrainNode = GetComponentInParent <TerrainNode>();
            uniforms    = new Uniforms(Producer.Name);

            Producer.InitNode();
        }
Esempio n. 23
0
        public override void Start()
        {
            base.Start();

            m_producer    = GetComponent <TileProducer>();
            m_terrainNode = m_terrainNodeGO.GetComponent <TerrainNode>();
            m_uniforms    = new Uniforms(m_producer.GetName());
            m_tileFilters = GetComponents <TileFilter>();
        }
Esempio n. 24
0
        public void UpdateUniform(Uniforms uu, int id)
        {
            SqlCommand cmd = new SqlCommand("Update uniform Set name=@Name , class_lvl_id=@Class_lvl_id Where id=@Id", DALUtil.getConnection());

            cmd.Parameters.AddWithValue("@Id", id);
            cmd.Parameters.AddWithValue("@Name", (uu.Name == null) ? Convert.DBNull : uu.Name);
            cmd.Parameters.AddWithValue("@Class_lvl_id", (uu.Name == null) ? Convert.DBNull : uu.Class_lvl_id);
            uniform(cmd);
        }
Esempio n. 25
0
 public void setUniform(string name, bool value)
 {
     if (Uniforms.ContainsKey(name))
     {
         GL.Uniform1(Uniforms[name].address, (value) ? 1 : 0);
     }
     else
     {
         logWarning(string.Format("Warning: \"{0}\" not found in shader \"{1}\"", name, Name));
     }
 }
Esempio n. 26
0
 public void setUniform(string name, Matrix4 mat)
 {
     if (Uniforms.ContainsKey(name))
     {
         GL.UniformMatrix4(Uniforms[name].address, false, ref mat);
     }
     else
     {
         logWarning(string.Format("Warning: \"{0}\" not found in shader \"{1}\"", name, Name));
     }
 }
Esempio n. 27
0
 public void setUniform(string name, float value, float value2, float value3, float value4)
 {
     if (Uniforms.ContainsKey(name))
     {
         GL.Uniform4(Uniforms[name].address, value, value2, value3, value4);
     }
     else
     {
         logWarning(string.Format("Warning: \"{0}\" not found in shader \"{1}\"", name, Name));
     }
 }
 /// <summary cref="IBackendCodeGenerator.GenerateCode(ReturnTerminator)"/>
 public void GenerateCode(ReturnTerminator returnTerminator)
 {
     if (!returnTerminator.IsVoidReturn)
     {
         var resultRegister = Load(returnTerminator.ReturnValue);
         EmitStoreParam(ReturnParamName, resultRegister);
     }
     Command(
         Uniforms.IsUniform(returnTerminator)
             ? PTXInstructions.UniformReturnOperation
             : PTXInstructions.ReturnOperation);
 }
Esempio n. 29
0
        public async Task <IActionResult> Create([Bind("UniformsId,UniformsName,UniformsColor,TeamsId")] Uniforms uniforms)
        {
            if (ModelState.IsValid)
            {
                _context.Add(uniforms);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["TeamsId"] = new SelectList(_context.Teams, "TeamsId", "TeamsId", uniforms.TeamsId);
            return(View(uniforms));
        }
Esempio n. 30
0
        public int GetUniformLocation(string name)
        {
            int uniform;

            if (Uniforms.TryGetValue(name, out uniform))
            {
                return(uniform);
            }
            uniform        = GL.GetUniformLocation(ProgramId, name);
            Uniforms[name] = uniform;
            return(uniform);
        }
Esempio n. 31
0
        public void AddUniform(Uniforms u)
        {
            SqlCommand cmd = new SqlCommand("INSERT into uniform (name,class_lvl_id,picture,date,month,year,time) VALUES (@Name,@Class_lvl_id,@Picture,@Date,@Month,@Year,@Time)", DALUtil.getConnection());

            cmd.Parameters.AddWithValue("@Name", (u.Name == null) ? Convert.DBNull : u.Name);
            cmd.Parameters.AddWithValue("@Class_lvl_id", (u.Class_lvl_id == null) ? Convert.DBNull : u.Class_lvl_id);
            cmd.Parameters.AddWithValue("@Picture", (u.Picture == null) ? Convert.DBNull : u.Picture);
            cmd.Parameters.AddWithValue("@Date", (u.Date == null) ? Convert.DBNull : u.Date);
            cmd.Parameters.AddWithValue("@Month", (u.Month == null) ? Convert.DBNull : u.Month);
            cmd.Parameters.AddWithValue("@Year", (u.Year == null) ? Convert.DBNull : u.Year);
            cmd.Parameters.AddWithValue("@Time", (u.Time == null) ? Convert.DBNull : u.Time);
            uniform(cmd);
        }
Esempio n. 32
0
 /// <summary>
 /// Bind <code>GLPass</code> for debugging.
 /// </summary>
 /// <param name="pass">The pass to bind for debugging.</param>
 /// <param name="frame">The current frame ID to generate debug information for.</param>
 public static void Bind(GLPass pass, int frame)
 {
     // get debug uniforms for the pass
     Uniforms unif;
     if (!passes.TryGetValue(pass.glname, out unif))
         passes.Add(pass.glname, unif = new Uniforms(pass));
     // set shader debug uniforms
     unif.Bind(Settings, frame);
 }
Esempio n. 33
0
    static unsafe void RenderThread(Sample sample)
    {
        // initialize the renderer
        Bgfx.Init(RendererBackend.Direct3D11);
        Bgfx.Reset(sample.WindowWidth, sample.WindowHeight, ResetFlags.Vsync);

        // enable debug text
        Bgfx.SetDebugFeatures(DebugFeatures.DisplayText);

        // load shaders
        var programTextureLighting = ResourceLoader.LoadProgram("vs_stencil_texture_lighting", "fs_stencil_texture_lighting");
        var programColorLighting = ResourceLoader.LoadProgram("vs_stencil_color_lighting", "fs_stencil_color_lighting");
        var programColorTexture = ResourceLoader.LoadProgram("vs_stencil_color_texture", "fs_stencil_color_texture");
        var programColorBlack = ResourceLoader.LoadProgram("vs_stencil_color", "fs_stencil_color_black");
        var programTexture = ResourceLoader.LoadProgram("vs_stencil_texture", "fs_stencil_texture");

        // load meshes
        var bunnyMesh = ResourceLoader.LoadMesh("bunny.bin");
        var columnMesh = ResourceLoader.LoadMesh("column.bin");
        var hplaneMesh = new Mesh(MemoryBlock.FromArray(StaticMeshes.HorizontalPlane), PosNormalTexcoordVertex.Layout, StaticMeshes.PlaneIndices);
        var vplaneMesh = new Mesh(MemoryBlock.FromArray(StaticMeshes.VerticalPlane), PosNormalTexcoordVertex.Layout, StaticMeshes.PlaneIndices);

        // load textures
        var figureTex = ResourceLoader.LoadTexture("figure-rgba.dds");
        var flareTex = ResourceLoader.LoadTexture("flare.dds");
        var fieldstoneTex = ResourceLoader.LoadTexture("fieldstone-rgba.dds");

        // create uniforms
        var colorTextureHandle = new Uniform("u_texColor", UniformType.Int1);
        var uniforms = new Uniforms();
        uniforms.SubmitConstUniforms();

        // light colors
        uniforms.LightColor = new[] {
            new Vector4(1.0f, 0.7f, 0.2f, 0.0f), // yellow
            new Vector4(0.7f, 0.2f, 1.0f, 0.0f), // purple
            new Vector4(0.2f, 1.0f, 0.7f, 0.0f), // cyan
            new Vector4(1.0f, 0.4f, 0.2f, 0.0f)  // orange
        };

        // camera
        var camera = new Camera(60.0f, sample.WindowWidth, sample.WindowHeight, 0.1f, 100.0f);
        camera.Position = new Vector3(0.0f, 18.0f, -40.0f);

        // start the frame clock
        var clock = new Clock();
        clock.Start();

        // main loop
        while (sample.ProcessEvents(ResetFlags.Vsync)) {
            // tick the clock
            var elapsed = clock.Frame();
            var time = clock.TotalTime();

            // write some debug text
            Bgfx.DebugTextClear();
            Bgfx.DebugTextWrite(0, 1, DebugColor.White, DebugColor.Blue, "SharpBgfx/Samples/13-Stencil");
            Bgfx.DebugTextWrite(0, 2, DebugColor.White, DebugColor.Cyan, "Description: Stencil reflections.");
            Bgfx.DebugTextWrite(0, 3, DebugColor.White, DebugColor.Cyan, "Frame: {0:F3} ms", elapsed * 1000);

            // clear the background
            Bgfx.SetViewClear(BaseId, ClearTargets.Color | ClearTargets.Depth | ClearTargets.Stencil, 0x30303000);
            Bgfx.SetViewRect(BaseId, 0, 0, sample.WindowWidth, sample.WindowHeight);
            Bgfx.Touch(BaseId);

            // set view params for each pass
            var viewMtx = camera.GetViewMatrix();
            var projMtx = camera.GetProjectionMatrix();
            for (byte i = PassId0; i <= PassId4; i++) {
                Bgfx.SetViewRect(i, 0, 0, sample.WindowWidth, sample.WindowHeight);
                Bgfx.SetViewTransform(i, (float*)&viewMtx, (float*)&projMtx);
            }

            // first pass - draw ground plane
            var floorMtx = FloorTransform;
            hplaneMesh.Submit(PassId0, programColorBlack, &floorMtx, StateGroups[PrebuiltRenderState.StencilReflectionCraftStencil], uniforms);

            // second pass - reflected objects
            Bgfx.SetViewClear(PassId1, ClearTargets.Depth, 0);
            uniforms.AmbientPass = true;
            uniforms.LightingPass = true;
            uniforms.Color = new Vector4(0.70f, 0.65f, 0.60f, 0.8f);
            uniforms.LightCount = LightCount;

            // light positions
            var lightPositions = new Vector4[LightCount];
            var reflectedLights = new Vector4[LightCount];
            for (int i = 0; i < lightPositions.Length; i++) {
                var v3 = new Vector3(
                    (float)Math.Sin(time * 1.1 + i * 0.03 + i * 1.07 * Math.PI / 2) * 20.0f,
                    8.0f + (1.0f - (float)Math.Cos(time * 1.5 + i * 0.29 + 1.49f * Math.PI / 2)) * 4.0f,
                    (float)Math.Cos(time * 1.3 + i * 0.13 + i * 1.79 * Math.PI / 2) * 20.0f
                );

                lightPositions[i] = new Vector4(v3, 15.0f);
                reflectedLights[i] = new Vector4(Vector3.Transform(v3, ReflectionTransform), 15.0f);
            }

            uniforms.LightPosRadius = reflectedLights;
            var bunnyMtx =
                Matrix4x4.CreateScale(5) *
                Matrix4x4.CreateRotationY(time - 1.56f) *
                Matrix4x4.CreateTranslation(0.0f, 2.0f, 0.0f);
            var reflectedBunnyMtx = bunnyMtx * ReflectionTransform;
            bunnyMesh.Submit(PassId1, programColorLighting, &reflectedBunnyMtx, StateGroups[PrebuiltRenderState.StencilReflectionDrawReflected], uniforms);

            for (int i = 0; i < 4; i++) {
                var mtx = ColumnTransforms[i] * ReflectionTransform;
                columnMesh.Submit(PassId1, programColorLighting, &mtx, StateGroups[PrebuiltRenderState.StencilReflectionDrawReflected], uniforms);
            }

            // third pass - blend the plane and reflections
            uniforms.LightPosRadius = lightPositions;
            hplaneMesh.Submit(PassId2, programTextureLighting, &floorMtx, StateGroups[PrebuiltRenderState.StencilReflectionBlendPlane], uniforms, fieldstoneTex, colorTextureHandle);

            // fourth pass - draw the solid objects
            bunnyMesh.Submit(PassId3, programColorLighting, &bunnyMtx, StateGroups[PrebuiltRenderState.StencilReflectionDrawScene], uniforms);
            for (int i = 0; i < 4; i++) {
                var mtx = ColumnTransforms[i];
                columnMesh.Submit(PassId3, programColorLighting, &mtx, StateGroups[PrebuiltRenderState.StencilReflectionDrawScene], uniforms);
            }

            // fifth pass - draw the lights as objects
            for (int i = 0; i < LightCount; i++) {
                var c = uniforms.LightColor[i];
                uniforms.Color = new Vector4(c.X, c.Y, c.Z, 0.8f);

                var p = lightPositions[i];
                var mtx = Matrix4x4.CreateScale(1.5f) * Matrix4x4.CreateBillboard(new Vector3(p.X, p.Y, p.Z), camera.Position, Vector3.UnitY, -Vector3.UnitZ);
                vplaneMesh.Submit(PassId4, programColorTexture, &mtx, StateGroups[PrebuiltRenderState.CustomBlendLightTexture], uniforms, flareTex, colorTextureHandle);
            }

            // advance to the next frame. Rendering thread will be kicked to
            // process submitted rendering primitives.
            Bgfx.Frame();
        }

        // clean up
        bunnyMesh.Dispose();
        columnMesh.Dispose();
        hplaneMesh.Dispose();
        vplaneMesh.Dispose();

        figureTex.Dispose();
        fieldstoneTex.Dispose();
        flareTex.Dispose();

        programTextureLighting.Dispose();
        programColorLighting.Dispose();
        programColorTexture.Dispose();
        programColorBlack.Dispose();
        programTexture.Dispose();

        colorTextureHandle.Dispose();
        uniforms.Dispose();

        Bgfx.Shutdown();
    }
Esempio n. 34
0
 public Matrix4 this[Uniforms uniform]
 {
     get
     {
         return (Matrix4)this[globalUniforms[uniform]];
     }
     set
     {
         this[globalUniforms[uniform]] = value;
     }
 }