示例#1
0
        public void RenderBucketNormals(Environment env, Camera cam, Bucket bucket)
        {
            for (int i = 0; i < geometries.Count; i++)
            {
                if (geometries[i].AttachedToRoot && geometries[i].Material.Bucket == bucket)
                {
                    if (geometries[i].NormalsShader == null)
                    {
                        if (geometries[i].GetShader() == null)
                        {
                            geometries[i].SetDefaultShader();
                        }
                        ShaderProperties p = new ShaderProperties(geometries[i].ShaderProperties);
                        p.SetProperty("NORMALS", true);
                        geometries[i].NormalsShader = ShaderManager.GetShader(geometries[i].GetShader().GetType(), p);
                    }

                    geometries[i].NormalsShader.Use();
                    geometries[i].NormalsShader.ApplyMaterial(geometries[i].Material);
                    geometries[i].NormalsShader.SetTransforms(geometries[i].GetWorldMatrix(), cam.ViewMatrix, cam.ProjectionMatrix);
                    geometries[i].NormalsShader.Update(env, cam, geometries[i].Mesh);
                    geometries[i].NormalsShader.Render(geometries[i].Mesh);
                    geometries[i].NormalsShader.End();

                    Shader.Clear();
                }
            }
        }
示例#2
0
        public void RenderBucketDepth(Environment env, Camera cam, Bucket bucket, DepthRenderMode renderMode)
        {
            for (int i = 0; i < geometries.Count; i++)
            {
                if (geometries[i].AttachedToRoot && geometries[i].Material.Bucket == bucket)
                {
                    if (geometries[i].DepthShader == null)
                    {
                        if (geometries[i].GetShader() == null)
                        {
                            geometries[i].SetDefaultShader();
                        }
                        ShaderProperties p = new ShaderProperties(geometries[i].ShaderProperties);
                        p.SetProperty("DEPTH", true);
                        geometries[i].DepthShader = ShaderManager.GetShader(typeof(Shaders.DepthShader), p);
                    }
                    if (renderMode == DepthRenderMode.Shadow && geometries[i].Material.GetBool(Material.MATERIAL_CASTSHADOWS))
                    {
                        geometries[i].DepthShader.Use();
                        geometries[i].DepthShader.ApplyMaterial(geometries[i].Material);
                        geometries[i].DepthShader.SetTransforms(geometries[i].GetWorldMatrix(), cam.ViewMatrix, cam.ProjectionMatrix);
                        geometries[i].DepthShader.Update(env, cam, geometries[i].Mesh);
                        geometries[i].DepthShader.Render(geometries[i].Mesh);
                        geometries[i].DepthShader.End();
                    }

                    Shader.Clear();
                    Texture2D.Clear();
                }
            }
        }
示例#3
0
 public void SetShader(Type shaderType, ShaderProperties properties)
 {
     properties.SetProperty("DEFAULT", true);
     SetShader(ShaderManager.GetShader(shaderType, properties));
     properties.SetProperty("DEFAULT", false);
 }
示例#4
0
        public void RenderBucketNormals(Environment env, Camera cam, Bucket bucket)
        {
            for (int i = 0; i < geometries.Count; i++)
            {
                if (geometries[i].AttachedToRoot && geometries[i].Material.Bucket == bucket)
                {
                    if (geometries[i].NormalsShader == null)
                    {
                        if (geometries[i].GetShader() == null)
                            geometries[i].SetDefaultShader();
                        ShaderProperties p = new ShaderProperties(geometries[i].ShaderProperties);
                        p.SetProperty("NORMALS", true);
                        geometries[i].NormalsShader = ShaderManager.GetShader(typeof(Shaders.NormalsShader), p);

                    }

                    geometries[i].NormalsShader.Use();
                    geometries[i].NormalsShader.ApplyMaterial(geometries[i].Material);
                    geometries[i].NormalsShader.SetTransforms(geometries[i].GetWorldMatrix(), cam.ViewMatrix, cam.ProjectionMatrix);
                    geometries[i].NormalsShader.Update(env, cam, geometries[i].Mesh);
                    geometries[i].NormalsShader.Render(geometries[i].Mesh);
                    geometries[i].NormalsShader.End();

                    Shader.Clear();
                }
            }
        }
示例#5
0
        public void RenderBucketDepth(Environment env, Camera cam, Bucket bucket, DepthRenderMode renderMode)
        {
            for (int i = 0; i < geometries.Count; i++)
            {
                if (geometries[i].AttachedToRoot && geometries[i].Material.Bucket == bucket)
                {
                    if (geometries[i].DepthShader == null)
                    {
                        if (geometries[i].GetShader() == null)
                            geometries[i].SetDefaultShader();
                        ShaderProperties p = new ShaderProperties(geometries[i].ShaderProperties);
                        p.SetProperty("DEPTH", true);
                        geometries[i].DepthShader = ShaderManager.GetShader(typeof(Shaders.DepthShader), p);
                    }
                    if (renderMode == DepthRenderMode.Shadow && geometries[i].Material.GetBool(Material.MATERIAL_CASTSHADOWS))
                    {
                        geometries[i].DepthShader.Use();
                        geometries[i].DepthShader.ApplyMaterial(geometries[i].Material);
                        geometries[i].DepthShader.SetTransforms(geometries[i].GetWorldMatrix(), cam.ViewMatrix, cam.ProjectionMatrix);
                        geometries[i].DepthShader.Update(env, cam, geometries[i].Mesh);
                        geometries[i].DepthShader.Render(geometries[i].Mesh);
                        geometries[i].DepthShader.End();
                    }

                    Shader.Clear();
                    Texture2D.Clear();
                }
            }
        }
示例#6
0
 public void SetShader(Type shaderType, ShaderProperties properties)
 {
     ShaderProperties p = new ShaderProperties(properties);
     p.SetProperty("DEFAULT", true);
     SetShader(ShaderManager.GetShader(shaderType, p));
 }