| 765 | | LayerBlendModeEx blend = curTextureLayerState.LayerBlendModeEx; |
| 766 | | switch (blend.source1) |
| 767 | | { |
| 768 | | case LayerBlendSource.Current: |
| 769 | | shaderSource += "\t\tfloat4 source1 = finalColor;\n"; |
| 770 | | break; |
| 771 | | case LayerBlendSource.Texture: |
| 772 | | shaderSource += "\t\tfloat4 source1 = texColor;\n"; |
| 773 | | break; |
| 774 | | case LayerBlendSource.Diffuse: |
| 775 | | shaderSource += "\t\tfloat4 source1 = input.Color;\n"; |
| 776 | | break; |
| 777 | | case LayerBlendSource.Specular: |
| 778 | | shaderSource += "\t\tfloat4 source1 = input.ColorSpec;\n"; |
| 779 | | break; |
| 780 | | case LayerBlendSource.Manual: |
| 781 | | shaderSource += "\t\tfloat4 Texture" + layerCounter + "_colourArg1=float4("+ |
| 782 | | blend.colorArg1.r.ToString()+","+ |
| 783 | | blend.colorArg1.g.ToString()+","+ |
| 784 | | blend.colorArg1.b.ToString()+","+ |
| 785 | | blend.colorArg1.a.ToString()+");\r\n"; |
| 786 | | shaderSource += "\t\tfloat4 source1 = Texture" + layerCounter + "_colourArg1;\n"; |
| 787 | | break; |
| 788 | | } |
| 789 | | switch (blend.source2) |
| 790 | | { |
| 791 | | case LayerBlendSource.Current: |
| 792 | | shaderSource += "\t\tfloat4 source2 = finalColor;\n"; |
| 793 | | break; |
| 794 | | case LayerBlendSource.Texture: |
| 795 | | shaderSource += "\t\tfloat4 source2 = texColor;\n"; |
| 796 | | break; |
| 797 | | case LayerBlendSource.Diffuse: |
| 798 | | shaderSource += "\t\tfloat4 source2 = input.Color;\n"; |
| 799 | | break; |
| 800 | | case LayerBlendSource.Specular: |
| 801 | | shaderSource += "\t\tfloat4 source2 = input.ColorSpec;\n"; |
| 802 | | break; |
| 803 | | case LayerBlendSource.Manual: |
| 804 | | shaderSource += "\t\tfloat4 Texture" + layerCounter + "_colourArg2=float4(" + |
| 805 | | blend.colorArg2.r.ToString() + "," + |
| 806 | | blend.colorArg2.g.ToString() + "," + |
| 807 | | blend.colorArg2.b.ToString() + "," + |
| 808 | | blend.colorArg2.a.ToString() + ");\r\n"; |
| 809 | | shaderSource += "\t\tfloat4 source2 = Texture" + layerCounter + "_colourArg2;\n"; |
| 810 | | break; |
| 811 | | } |
| 812 | | |
| 813 | | switch (blend.operation) |
| 814 | | { |
| 815 | | case LayerBlendOperationEx.Source1: |
| 816 | | shaderSource += "\t\tfinalColor = source1;\n"; |
| 817 | | break; |
| 818 | | case LayerBlendOperationEx.Source2: |
| 819 | | shaderSource += "\t\tfinalColor = source2;\n"; |
| 820 | | break; |
| 821 | | case LayerBlendOperationEx.Modulate: |
| 822 | | shaderSource += "\t\tfinalColor = source1 * source2;\n"; |
| 823 | | break; |
| 824 | | case LayerBlendOperationEx.ModulateX2: |
| 825 | | shaderSource += "\t\tfinalColor = source1 * source2 * 2.0;\n"; |
| 826 | | break; |
| 827 | | case LayerBlendOperationEx.ModulateX4: |
| 828 | | shaderSource += "\t\tfinalColor = source1 * source2 * 4.0;\n"; |
| 829 | | break; |
| 830 | | case LayerBlendOperationEx.Add: |
| 831 | | shaderSource += "\t\tfinalColor = source1 + source2;\n"; |
| 832 | | break; |
| 833 | | case LayerBlendOperationEx.AddSigned: |
| 834 | | shaderSource += "\t\tfinalColor = source1 + source2 - 0.5;\n"; |
| 835 | | break; |
| 836 | | case LayerBlendOperationEx.AddSmooth: |
| 837 | | shaderSource += "\t\tfinalColor = source1 + source2 - (source1 * source2);\n"; |
| 838 | | break; |
| 839 | | case LayerBlendOperationEx.Subtract: |
| 840 | | shaderSource += "\t\tfinalColor = source1 - source2;\n"; |
| 841 | | break; |
| 842 | | case LayerBlendOperationEx.BlendDiffuseAlpha: |
| 843 | | shaderSource += "\t\tfinalColor = source1 * input.Color.w + source2 * (1.0 - input.Color.w);\n"; |
| 844 | | break; |
| 845 | | case LayerBlendOperationEx.BlendTextureAlpha: |
| 846 | | shaderSource += "\t\tfinalColor = source1 * texColor.w + source2 * (1.0 - texColor.w);\n"; |
| 847 | | break; |
| 848 | | case LayerBlendOperationEx.BlendCurrentAlpha: |
| 849 | | shaderSource += "\t\tfinalColor = source1 * finalColor.w + source2 * (1.0 - finalColor.w);\n"; |
| 850 | | break; |
| 851 | | case LayerBlendOperationEx.BlendManual: |
| 852 | | shaderSource += "\t\tfinalColor = source1 * " + Convert.ToString(blend.blendFactor) + |
| 853 | | " + source2 * (1.0 - " + Convert.ToString(blend.blendFactor) + ");\n"; |
| 854 | | break; |
| 855 | | case LayerBlendOperationEx.DotProduct: |
| 856 | | shaderSource += "\t\tfinalColor = product(source1,source2);\n"; |
| 857 | | break; |
| 858 | | |
| | 765 | LayerBlendModeEx blend = curTextureLayerState.LayerBlendMode; |
| | 766 | if ( blend != null ) |
| | 767 | { |
| | 768 | switch ( blend.source1 ) |
| | 769 | { |
| | 770 | case LayerBlendSource.Current: |
| | 771 | shaderSource += "\t\tfloat4 source1 = finalColor;\n"; |
| | 772 | break; |
| | 773 | case LayerBlendSource.Texture: |
| | 774 | shaderSource += "\t\tfloat4 source1 = texColor;\n"; |
| | 775 | break; |
| | 776 | case LayerBlendSource.Diffuse: |
| | 777 | shaderSource += "\t\tfloat4 source1 = input.Color;\n"; |
| | 778 | break; |
| | 779 | case LayerBlendSource.Specular: |
| | 780 | shaderSource += "\t\tfloat4 source1 = input.ColorSpec;\n"; |
| | 781 | break; |
| | 782 | case LayerBlendSource.Manual: |
| | 783 | shaderSource += "\t\tfloat4 Texture" + layerCounter + "_colourArg1=float4(" + |
| | 784 | blend.colorArg1.r.ToString() + "," + |
| | 785 | blend.colorArg1.g.ToString() + "," + |
| | 786 | blend.colorArg1.b.ToString() + "," + |
| | 787 | blend.colorArg1.a.ToString() + ");\r\n"; |
| | 788 | shaderSource += "\t\tfloat4 source1 = Texture" + layerCounter + "_colourArg1;\n"; |
| | 789 | break; |
| | 790 | } |
| | 791 | switch ( blend.source2 ) |
| | 792 | { |
| | 793 | case LayerBlendSource.Current: |
| | 794 | shaderSource += "\t\tfloat4 source2 = finalColor;\n"; |
| | 795 | break; |
| | 796 | case LayerBlendSource.Texture: |
| | 797 | shaderSource += "\t\tfloat4 source2 = texColor;\n"; |
| | 798 | break; |
| | 799 | case LayerBlendSource.Diffuse: |
| | 800 | shaderSource += "\t\tfloat4 source2 = input.Color;\n"; |
| | 801 | break; |
| | 802 | case LayerBlendSource.Specular: |
| | 803 | shaderSource += "\t\tfloat4 source2 = input.ColorSpec;\n"; |
| | 804 | break; |
| | 805 | case LayerBlendSource.Manual: |
| | 806 | shaderSource += "\t\tfloat4 Texture" + layerCounter + "_colourArg2=float4(" + |
| | 807 | blend.colorArg2.r.ToString() + "," + |
| | 808 | blend.colorArg2.g.ToString() + "," + |
| | 809 | blend.colorArg2.b.ToString() + "," + |
| | 810 | blend.colorArg2.a.ToString() + ");\r\n"; |
| | 811 | shaderSource += "\t\tfloat4 source2 = Texture" + layerCounter + "_colourArg2;\n"; |
| | 812 | break; |
| | 813 | } |
| | 814 | |
| | 815 | switch ( blend.operation ) |
| | 816 | { |
| | 817 | case LayerBlendOperationEx.Source1: |
| | 818 | shaderSource += "\t\tfinalColor = source1;\n"; |
| | 819 | break; |
| | 820 | case LayerBlendOperationEx.Source2: |
| | 821 | shaderSource += "\t\tfinalColor = source2;\n"; |
| | 822 | break; |
| | 823 | case LayerBlendOperationEx.Modulate: |
| | 824 | shaderSource += "\t\tfinalColor = source1 * source2;\n"; |
| | 825 | break; |
| | 826 | case LayerBlendOperationEx.ModulateX2: |
| | 827 | shaderSource += "\t\tfinalColor = source1 * source2 * 2.0;\n"; |
| | 828 | break; |
| | 829 | case LayerBlendOperationEx.ModulateX4: |
| | 830 | shaderSource += "\t\tfinalColor = source1 * source2 * 4.0;\n"; |
| | 831 | break; |
| | 832 | case LayerBlendOperationEx.Add: |
| | 833 | shaderSource += "\t\tfinalColor = source1 + source2;\n"; |
| | 834 | break; |
| | 835 | case LayerBlendOperationEx.AddSigned: |
| | 836 | shaderSource += "\t\tfinalColor = source1 + source2 - 0.5;\n"; |
| | 837 | break; |
| | 838 | case LayerBlendOperationEx.AddSmooth: |
| | 839 | shaderSource += "\t\tfinalColor = source1 + source2 - (source1 * source2);\n"; |
| | 840 | break; |
| | 841 | case LayerBlendOperationEx.Subtract: |
| | 842 | shaderSource += "\t\tfinalColor = source1 - source2;\n"; |
| | 843 | break; |
| | 844 | case LayerBlendOperationEx.BlendDiffuseAlpha: |
| | 845 | shaderSource += "\t\tfinalColor = source1 * input.Color.w + source2 * (1.0 - input.Color.w);\n"; |
| | 846 | break; |
| | 847 | case LayerBlendOperationEx.BlendTextureAlpha: |
| | 848 | shaderSource += "\t\tfinalColor = source1 * texColor.w + source2 * (1.0 - texColor.w);\n"; |
| | 849 | break; |
| | 850 | case LayerBlendOperationEx.BlendCurrentAlpha: |
| | 851 | shaderSource += "\t\tfinalColor = source1 * finalColor.w + source2 * (1.0 - finalColor.w);\n"; |
| | 852 | break; |
| | 853 | case LayerBlendOperationEx.BlendManual: |
| | 854 | shaderSource += "\t\tfinalColor = source1 * " + Convert.ToString( blend.blendFactor ) + |
| | 855 | " + source2 * (1.0 - " + Convert.ToString( blend.blendFactor ) + ");\n"; |
| | 856 | break; |
| | 857 | case LayerBlendOperationEx.DotProduct: |
| | 858 | shaderSource += "\t\tfinalColor = product(source1,source2);\n"; |
| | 859 | break; |
| | 860 | |
| | 861 | } |