Exemplo n.º 1
0
        public override void Render(Matrix4d viewproj, Matrix4d parentmodel)
        {
            if (Settings.DrawGrass == false)
            {
                return;
            }
            //if (Globals.ShaderOverride != null) return;
            if (Globals.Avatar.DistanceToSurface > HeightThreshold)
            {
                return;
            }
            if (grass != null)
            {
                grass.transform.Position = this.transform.Position;
            }

            //GL.Enable(EnableCap.Blend);
            // GL.BlendFunc(BlendingFactor.SrcAlpha, BlendingFactor.OneMinusSrcAlpha);

            if (material == null)
            {
                return;
            }
            CalculateDrawMatrices(viewproj, parentmodel);

            MShader temp = material.shader;

            if (Globals.ShaderOverride != null)
            {
                temp = Globals.ShaderOverride;
                temp.SetInt("HasBones", 0);
            }
            else
            {
                material.IsUsed = true;
                material.Render(viewproj, parentmodel);
                material.Bind();
                material.shader.SetFloat("Fade", 68);
                //49 6

                temp.SetBool("ShadowEnabled", CastsShadow);
            }
            temp.SetMat4("mvp", mvp);
            temp.SetMat4("model", modelMatrix);

            GL.BindVertexArray(treemesh.VAO);
            lock (matlocker)
            {
                UploadBufferFull();
            }

            GL.DrawArraysInstanced(PrimitiveType.Triangles, 0, treemesh.Indices.Length, TotalInstances);
            // Helper.CheckGLError(this);
            GL.BindVertexArray(0);
            if (Globals.ShaderOverride == null)
            {
                material.UnBind();
            }
            //base.Render(viewproj, parentmodel);
        }
Exemplo n.º 2
0
        public override void Render(Matrix4d viewproj, Matrix4d parentmodel)
        {
            if (Settings.DrawTrees == false)
            {
                return;
            }
            //if (Globals.ShaderOverride != null) return;
            if (DistanceFromAvatar > DistanceThreshold)
            {
                return;
            }

            /*if (tree != null)
             * {
             * tree.transform.Position = this.transform.Position;
             * }*/
            if (Planted == false)
            {
                Setup();
                Planted = true;
            }
            if (material == null)
            {
                return;
            }
            CalculateDrawMatrices(viewproj, parentmodel);

            MShader temp = material.shader;

            if (Globals.ShaderOverride != null)
            {
                temp = Globals.ShaderOverride;
            }
            else
            {
                material.Bind();
            }

            temp.SetMat4("mvp", mvp);
            temp.SetMat4("model", modelMatrix);
            //material.shader.SetBool("selected", Selected);
            temp.SetBool("ShadowEnabled", CastsShadow);

            GL.BindVertexArray(treemesh.VAO);
            //GL.BindBuffer(BufferTarget.ElementArrayBuffer, treemesh.EBO);

            UploadBufferFull();

            material.Render(viewproj, parentmodel);
            GL.DrawArraysInstanced(PrimitiveType.Triangles, 0, treemesh.Vertices.Length, TotalInstances);
            // Helper.CheckGLError(this);
            // GL.BindVertexArray(0);
            // material.UnBind();
            base.Render(viewproj, parentmodel);
        }