Esempio n. 1
0
        private void SetShaderValues(ShaderProgram sp)
        {
            RC.SetShader(sp);
            var myset = new RenderStateSet
            {
                AlphaBlendEnable = false,
                ZEnable = true
            };

            RC.SetRenderState(myset);
            switch (_textShaderName)
            {
                case "Diffuse Color":
                    RC.SetShaderParam(_paramColor, new float4(1, 0, 0, 1));
                    RC.Render(_currentMesh);
                    break;

                case "Texture Only":
                    RC.SetShaderParamTexture(_paramTexture, _currentTexture);
                    RC.Render(_currentMesh);
                    break;

                case "Diffuse Texture":
                    RC.SetShaderParamTexture(_paramTexture, _currentTexture);
                    RC.Render(_currentMesh);
                    break;

                case "Diffuse Bump Texture":
                    RC.SetShaderParamTexture(_paramTexture, _currentTexture);
                    RC.SetShaderParamTexture(_paramBumpTexture, _currentBumpTexture);
                    RC.SetShaderParam(_paramSpecular, 64.0f);
                    RC.SetShaderParam(_paramShininess, 0.5f);
                    RC.Render(_currentMesh);
                    break;

                case "Specular Texture":
                    RC.SetShaderParamTexture(_paramTexture, _currentTexture);
                    RC.SetShaderParam(_paramSpecular, 64.0f);
                    RC.SetShaderParam(_paramShininess, 0.5f);
                    RC.Render(_currentMesh);
                    break;

                case "Toon":
                    RC.SetRenderState(new RenderStateSet
                    {
                        AlphaBlendEnable = true,
                        BlendFactor = new float4(0.5f, 0.5f, 0.5f, 0.5f),
                        BlendOperation = BlendOperation.Add,
                        SourceBlend = Blend.BlendFactor,
                        DestinationBlend = Blend.InverseBlendFactor
                    });

                    _shaderEffect.RenderMesh(_currentMesh);
                    break;
            }
        }
 /// <summary>
 /// Apply a number of render states to this render context. All subsequent rendering will be
 /// performed using the currently set state set unless one of its values it is changed. Use this 
 /// method to change more than one render state at once. 
 /// </summary>
 /// <param name="renderStateSet">A set of render states with their respective values to be set.</param>
 public void SetRenderState(RenderStateSet renderStateSet)
 {
     foreach (var state in renderStateSet.States)
     {
         var theKey = state.Key;
         var theValue = state.Value;
         _rci.SetRenderState(theKey, theValue);
     }
 }