Unityshader Fixed Pipeline command combine texture blending "shader data 4"

Source: Internet
Author: User

Combine, texture blending.

Let's look at the explanations given in the Holy Scriptures.

The texture is applied after the basic vertex illumination is computed. This is done through the settexture command in the shader.

The SetTexture command does not take effect when one-sided programs are used, and in this mode pixel operations are fully described in the shader.

  

Texture maps can be used to make old-style mixer effects. You can use multiple SetTexture commands in one channel-all textures are applied sequentially, just like layers in a drawing program. SetTexture command must be placed at the end of the channel

Texture block Combine command texture block merge commands
Combine src1 * src2
multiplies Src1 and src2 together. The result would be darker than either input.
multiplies the elements of source 1 and Source 2. The result will be darker than any individual output
.
Combine src1 + src2
Adds Src1 and Src2 together. The result would be lighter than either input.
adds the elements of source 1 and Source 2. The result will be brighter than any individual output
Combine src1 - src2
subtracts src2 from Src1.
Source 1 minus source 2
Combine src1 +- src2
Adds Src1 to SRC2 and then subtracts 0.5 (a signed add).
add first, then subtract 0.5 (adds a symbol)
Combine src1 lerp ( src2) src3
Interpolates between SRC3 and SRC1, using the alpha of SRC2. Note that the interpolation is opposite direction:src1 are used when alpha is one, and SRC3 are used when Alpha is zero.
Use the transparency channel value from source 2 for the difference between source 3 and source 1, and note that the difference is reversed: when the transparency value is 1, the source 1 is used, and the transparency is 0, use source 3
Combine src1 * src2 + src3
multiplies src1 with the alpha component of SRC2, then adds Src3.
multiply the transparency of source 1 and Source 2, and then add source 3
Combine src1 * src2 +- src3
Multiplies SRC1 with the alpha component of SRC2, then does a signed add with SRC3.
the transparency of source 1 and Source 2 is multiplied, and then the source 3 is signed plus
Combine src1 * src2 - src3
multiplies src1 with the alpha component of SRC2, then subtracts src3.
the transparency of source 1 and source 2 is multiplied and then subtracted from source 3

All the src properties can be either one of previous, constant, primary or texture.

All source properties can be previous, constant, primary, or texture one of them.

    • Previous is the result of the Previous settexture.
      Results of last SetTexture
    • Primary is the color from the lighting calculation or the vertex color if it is bound.
      The color from the light calculation or the vertex color when it is bound
    • Texture is the color of the Texture specified by [_texturename] in the settexture (see above).
      The color of the texture defined in SetTexture
    • Constant is the color specified in constantcolor.
      Color defined by Constantcolor

Modifiers Explanation:

    • The formulas specified above can optionally be followed by the keywords Double or Quad to make the Resul Ting color 2x or 4x as bright.
      All of the above formulas can be twice or 4 times times brighter with the final color by the keyword Double or Quad.
    • All the src properties, except lerp argument, can optionally is preceded by one - to make the resulting Color negated.
      All SRC attributes, except for the difference parameter, can be labeled with a-symbol to reverse the final color.
    • All the src properties can is followed by Alpha to take only the alpha channel.
      All SRC attributes can be represented by following the alpha tag to indicate that only the alpha channel is taken.
Texture Block Constantcolor command (texture block constantcolor commands)
Constantcolor Color
Defines a constant color that can is used in the Combine command.
Defines the invariant colors that can be used in the Combine command
Texture block Matrix command (texture block matrix commands)
Matrix [Matrixpropertyname]
Transforms Texture coordinates used in this command with the given matrix.
transform texture coordinates with a given matrix
this matrix texture coordinates, the official website did not give a clear explanation, Baidu Google also did not find relevant information, my personal conjecture may be UV settings.
See here, we probably understand the use of combine, it is the role of color or texture to the integration of an instruction.
examples are as follows:
the previous in the example represents the result of the previous settexture calculation, texture represents the current settexture parameter texture, and primary is the color of the current light. If your shader turns on the light, there is no lighting effect if you do not use primary in the parameter.
Shader"examples/self-illumination"{Properties {_maintex ("Base (RGB) self-illumination (A)", 2D) =" White"{}} subshader {Pass {//Set up basic white vertex lighting//set white vertex illuminationMaterial {Diffuse (1,1,1,1)//Diffuse color setting Ambient (1,1,1,1)//ambient light reflection color setting} Lighting on//Use texture alpha-to-blend up-to-white (= Full illumination)//use texture alpha to blend white (full glow)SetTexture [_maintex] {Constantcolor (1,1,1,1)//Custom ColorsCombine constant lerp (texture) Previous}//Multiply in Texture//and texture multiplicationSetTexture [_maintex] {combine previous*Texture}} }}

In addition, we can calculate only for transparency, as shown below:

By default, the blend formula is used to calculate the RGB channel and transparency of the texture. , as shown below:

SetTexture [_MainTex] { combine previous * texture, previous + texture }

逗号后面的previous + texture表示光照和当前图片纹理混合后的透明度,这个时候输出的结果的透明度就不会再是previous * texture的透明度了。

Unityshader Fixed Pipeline command combine texture blending "shader data 4"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.