zoukankan      html  css  js  c++  java
  • Texture Combiner

    Texture Combiner

      After the basic vertex lighting has been calculated, textures are applied. In ShaderLab this is done using SetTexture command.

      SetTexture commands have no effect when fragment programs are used; as in that case pixel operations are completely described in the shader.

      

      Texturing is the place to do old-style combiner effects. You can have multiple SetTexture commands inside a pass - all textures are applied in sequence, like layers in a painting program. SetTexture commands must be placed at the end of a Pass.

    [三种命令]

    1、combine命令

      

    2、constantColor命令

      ConstantColor color

    Defines a constant color that can be used in the combine command.

     3、matrix命令

      matrix [MatrixPropertyName]Transforms texture coordinates used in this command with the given matrix.

    4、所有源属性都可以是previous, constant, primary or texture其中的一个。

      

    5、All the src properties can be followed by alpha to take only the alpha channel. 

      所有src属性能通过跟随 alpha 标签来表示只取用alpha通道。

    6、The formulas specified above can optionally be followed by the keywords Double or Quad to make the resulting color 2x or 4x as bright.

    [Separate Alpha & Color computation]

      

    [Specular highlight]

      By default the primary color is the sum of the diffuse, ambient and specular colors (as defined in the Lighting calculation). If you specify SeparateSpecular On in the pass options, the specular color will be added in after the combiner calculation, rather than before. This is the default behavior of the built-in VertexLit shader.

    [Examples]

    1、Alpha Blending Two Textures

      This small examples takes two textures. First it sets the first combiner to just take the _MainTex, then is uses the alpha channel of _BlendTex to fade in the RGB colors of _BlendTex。  

    Shader "Examples/2 Alpha Blended Textures" {
        Properties {
            _MainTex ("Base (RGB)", 2D) = "white" {}
            _BlendTex ("Alpha Blended (RGBA) ", 2D) = "white" {}
        }
        SubShader {
            Pass {
                // Apply base texture
                SetTexture [_MainTex] {
                    combine texture
                }
                // Blend in the alpha texture using the lerp operator
                SetTexture [_BlendTex] {
                    combine texture lerp (texture) previous
                }
            }
        }
    } 
    View Code

    2、Alpha Controlled Self-illumination

      This shader uses the alpha component of the _MainTex to decide where to apply lighting. It does this by applying the texture to two stages; In the first stage, the alpha value of the texture is used to blend between the vertex color and solid white. In the second stage, the RGB values of the texture are multiplied in.

    Shader "Examples/Self-Illumination" {
        Properties {
            _MainTex ("Base (RGB) Self-Illumination (A)", 2D) = "white" {}
        }
        SubShader {
            Pass {
                // Set up basic white vertex lighting
                Material {
                    Diffuse (1,1,1,1)
                    Ambient (1,1,1,1)
                }
                Lighting On
    
                // Use texture alpha to blend up to white (= full illumination)
                SetTexture [_MainTex] {
                    constantColor (1,1,1,1)
                    combine constant lerp(texture) previous
                }
                // Multiply in texture
                SetTexture [_MainTex] {
                    combine previous * texture
                }
            }
        }
    } 
    View Code

    参考:file://localhost/Applications/Unity/Unity.app/Contents/Documentation/Documentation/Components/SL-SetTexture.html

     

     

  • 相关阅读:
    10.25 测试
    ##2018-2019-1 20165327 《信息安全系统设计基础》第四周学习总结
    实验一 开发环境的熟悉
    ch03 课下作业——缓冲区溢出漏洞实验
    20165327 2018-2017-1 《信息安全系统设计基础》第三周学习总结
    week02 课堂作业
    第四周学习总结
    2018-2019-1 20165204 《信息安全系统设计基础》第三周学习总结
    2018-2019-1 20165204《信息安全系统设计基础》第二周学习总结
    2018-2019-1 20165204 《信息安全系统设计基础》第一周学习总结
  • 原文地址:https://www.cnblogs.com/tekkaman/p/3862586.html
Copyright © 2011-2022 走看看