Unity3D Shader官方教程翻译(八)----Shader语法:Pass的纹理处理 .

Unity运行时开关Shader Pass的一种方法 做个记录 SetShaderPassEnabled 这个函数作用与名称相当不符。。。 材质球调用开关LightMode的tag可以达到开关当前pass的作用,尤其是在需要多个pass都渲染的情况! Tags{ "LightMode" = "ForwardBase" } material.SetShaderPassEnabled("ForwardBase", false); 下面是官方文档中SetShaderPassEnabled 函数说明 Enables or disables a .. 阅读详情

ShaderLab syntax: Texturing

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

在基本的顶点照明计算完成以后,纹理将被设置。在ShaderLab中用SetTexture命令来设置纹理。

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

当使用片段编程时候SetTexture 命令无效。在这种情况下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个pass中使用多个SetTexture命令--所有的纹理都在一个队列当中,就像多个图层在1个绘图程序中一样。SetTexture 命令必须处在Pass的末尾。

Syntax

SetTexture  [TexturePropertyName]  {  Texture Block  }
A s sign s a texture.  TextureName mu st be defined a s a texture property. How to apply the texture i s defined in side the  TextureBlock.
指派一个纹理, TextureName 必须是被当做纹理的属性来定义。在 TextureBlock中设置如何定义这个纹理。

The texture block controls how the texture is applied. Inside the texture block can be up to three commands:combine, matrix and constantColor.

TextureBlock控制了如何设置这些纹理。在这个块中可以使用3个命令:combine, matrix , constantColor.

Texture block combine command

combine 命令

combine  src1 *  src2
Multiplie s  src1 and  src2 together. The re sult will be darker than either input.
src1和 src2相乘,结果纹理将比输入纹理更暗。
 
combine  src1 +  src2
Add s  src1 and  src2 together. The re sult will be lighter than either input.
src1和 src2相加,结果纹理将比输入纹理更明亮。
 
combine  src1 -  src2
Subtract s  src2 from  src1.
src1和 src2相减
      
combine  src1 +-  src2
Add s  src1 to  src2, then  subtract s 0.5 (a  signed add). 
src1和 src2相加,然后减去0.5( 有 符号相加)
combine  src1  lerp ( src2)  src3
Interpolate s between  src3 and  src1, u sing the alpha of  src2. Note that the interpolation i s oppo site direction: src1 i s u sed when alpha i s one, and  src3 i s u sed when alpha i s zero. 
在 src3和 src1之间做插值,使用 src2的alpha值。请注意插值是相反的方向,当alpha为1 时候 src1使用,当alpha为0 时候 src3使用。
combine  src1 *  src2 +  src3
Multiplie s  src1 with the alpha component of  src2, then add s  src3. 
src1与 src2的alpha值混合,然后添加 src3.
combine  src1 *  src2 +-  src3
Multiplie s  src1 with the alpha component of  src2, then doe s a  signed add with  src3. 
src1与 src2的alpha值混合,然后和 有 符号的 src3相加.
 
combine  src1 *  src2 -  src3
Multiplie s  src1 with the alpha component of  src2, then  subtract s  src3.
src1和 src2的alpha值相乘,然后和 src3相减。

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

所有的src属性可以是previous, constant, primary 或texture

  • Previous is the the result of the previous SetTexture. 在使用SetTexture命令之前的纹理
  • Primary is the color from the lighting calculation or the vertex color if it is bound.  从光照计算或者受限的顶点颜色中得到的颜色
  • Texture is the color of the texture specified by [_TextureName] in the SetTexture (see above). 从SetTexture [_TextureName]中指定的纹理颜色
  • Constant is the color specified in ConstantColor. 常量颜色从ConstantColor设置中得到
Modifier s:  修正:
  • The formulas specified above can optionally be followed by the keywords Double or Quad to make the resulting color 2x or 4x as bright.
  • 上述所有的公式可以选择设置关键词Double或者Quad使结果的颜色2倍或者4倍明亮。
  • All the src properties, except lerp argument, can optionally be preceded by one - to make the resulting color negated.
  • 所有的src属性,除lerp外,可以使用符号-来使最终颜色反相。
  • All the src properties can be followed by alpha to take only the alpha channel.
  • 所有的src属性后面可以有且仅有1个alpha.

Texture block constantColor command 常量颜色命令

ConstantColor  color
Define s a con stant color that can be u sed in the combine command.
定义1个常量颜色,在combina命令中使用

Texture block matrix command

matrix  [MatrixPropertyName]
Tran sform s texture coordinate s u sed in thi s command with the given matrix.
利用此命令使用指定的矩阵转换纹理坐标

Details 详情

Older graphics cards use a layered approach to textures. The textures are applied one after each other, modifying the color that will be written to the screen. For each texture, the texture is typically combined with the result of the previous operation.

老的显卡使用分层的办法来处理纹理。1个纹理在另外1个纹理之后,修改颜色将被显示在屏幕上面。对于每个纹理,纹理通常和前1个操作的结果合并。

点击浏览下一页

Note that on "true fixed function" devices (OpenGL, OpenGL ES 1.1, Wii) the value of each SetTexture stage isclamped to 0..1 range. Everywhere else (Direct3D, OpenGL ES 2.0) the range may or may not be higher. This might affect SetTexture stages that can produce values higher than 1.0.

请注意,“真正的固定功能"设备(OpenGL ES1.1,wii,OpenGL)中,每个SetTexture阶段的值限制在0 ..1范围内。在其他地方(Direct3D,OpenGL ES 2.0)的范围可能会或可能不会更高。这可能会影响SetTexture阶段,因为可以产生值高于1.0的值。

Separate Alpha & Color computation 单独的Alpha计算和颜色计算

By default, the combiner formula is used for calculating both the RGB and alpha component of the color. Optionally, you can specify a separate formula for the alpha calculation. This looks like this:

在默认情况下,合并公式是计算颜色的RGB和Alpha分量。你可以选择指定一个独立的公式去进行alpha计算,就像这样:

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

Here, we multiply the RGB colors and add the alpha.

这里我们将RGB颜色相乘然后添加alpha.

Specular highlights

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 inafter the combiner calculation, rather than before. This is the default behavior of the built-in VertexLit shader.

镜面高光
默认情况下,主色是漫反射光,环境和镜面的颜色(如在光照计算中定义的)的总和。如果你在pass中指定SeparateSpecular on ,镜面反色光的颜色将在合并计算结束后加入,而不是之前。这是内置的VertexLit(顶点光照)着色器的默认行为。

Graphics hardware support 显卡硬件支持

Some old graphics cards might not support some texture combine modes, and different cards have different number of SetTexture stages available. The shader author should write separate SubShaders for the cards he or she wants to support.

一些旧的显卡可能不支持一些纹理合并的模式,不同的显卡有不同数量的SetTexture阶段可用。编写shader时候应该要写他或她想要支持的显卡的独立SubShaders。

Graphics cards with pixel shader 1.1 support (NVIDIA GeForce 3 and up, ATI Radeon 8500 and up, Intel 9xx) support all combiner modes and have at least 4 texture stages available. The following table summarizes the hardwaresupport:

支持像素着色器1.1的显卡(NVIDIA公司的GeForce3时,ATI RADEON 8500及以上,英特尔9XX),支持所有合模式,并有至少有4个纹理阶段。下表总结了硬件支持:

CardStage countCombiner modes not supported
NVIDIA GeForce 3/4Ti and up4In OpenGL on Windows, src1*src2-src3 is notsupported
NVIDIA TNT2, GeForce 256, GeForce 2, GeForce 4MX2In OpenGL on Windows, src1*src2-src3 is notsupported
ATI Radeon 9500 and up4-88 in OpenGL, 4 in D3D9
ATI Radeon 8500-92504-66 in OpenGL, 4 in D3D9
ATI Radeon 75003 
ATI Rage2src1*src2+src3 
src1*src2+-src3 
src1*src2-src3

Examples 例子

Alpha Blending Two Textures  2个纹理的Alpha混合

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

这个小例子,有两个纹理。首先,它设置首次合成只采用_MainTex,然后是使用_BlendTex的alpha通道进行_BlendTex的RGB颜色褪色

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 使用插值操作混合alpha纹理
            SetTexture [_BlendTex] {
                combine texture lerp (texture) previous
            }
        }
    }
} 

Alpha Controlled Self-illumination  alpha控制的自发光

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使用的的_MainTex的alpha分量去决定在哪应用照明。它分两个阶段来实现这个效果。在第一阶段,纹理的alpha值用于混合顶点颜色和白色固体。在第二阶段中,再乘以纹理的RGB值。

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)使用纹理alpha和白色混合
            SetTexture [_MainTex] {
                constantColor (1,1,1,1)
                combine constant lerp(texture) previous
            }
            // Multiply in texture
            SetTexture [_MainTex] {
                combine previous * texture
            }
        }
    }
} 

We can do something else for free here, though; instead of blending to solid white, we can add a self-illumination color and blend to that. Note the use of ConstantColor to get a _SolidColor from the propertiesinto the texture blending.

这里我们就可以发挥想象了。我们可以在属性中设置自发光的颜色,代码如下。

Shader "Examples/Self-Illumination 2" {
    Properties {
        _IlluminCol ("Self-Illumination color (RGB)", Color) = (1,1,1,1)
        _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] {
                // Pull the color property into this blender
                constantColor [_IlluminCol]
                // And use the texture's alpha to blend between it and
                // vertex color
                combine constant lerp(texture) previous
            }
            // Multiply in texture
            SetTexture [_MainTex] {
                combine previous * texture
            }
        }
    }
} 

And finally, we take all the lighting properties of the vertexlit shader and pull that in:

最后我们可以设置顶点光照着色器的光照属性,修改成下面这样:

Shader "Examples/Self-Illumination 3" {
    Properties {
        _IlluminCol ("Self-Illumination color (RGB)", Color) = (1,1,1,1)
        _Color ("Main Color", Color) = (1,1,1,0)
        _SpecColor ("Spec Color", Color) = (1,1,1,1)
        _Emission ("Emmisive Color", Color) = (0,0,0,0)
        _Shininess ("Shininess", Range (0.01, 1)) = 0.7
        _MainTex ("Base (RGB)", 2D) = "white" {}
    }
    SubShader {
        Pass {
            // Set up basic vertex lighting
            Material {
                Diffuse [_Color]
                Ambient [_Color]
                Shininess [_Shininess]
                Specular [_SpecColor]
                Emission [_Emission]
            }
            Lighting On
            // Use texture alpha to blend up to white (= full illumination)
            SetTexture [_MainTex] {
                constantColor [_IlluminCol]
                combine constant lerp(texture) previous
            }
            // Multiply in texture
            SetTexture [_MainTex] {
                combine previous * texture
            }
        }
    }
} 
 
由www.J2meGame.com原创,转载请说明。
ERPS协议原理 目录 1、ERPS概述: 2、ERPS名词概念解释: 3、ERPS协议报文: 4、ERPS单环基本原理: 5、单环多实例原理: 6、多环原理: 1、ERPS概述: ERPS(Ethernet Ring Protection Switching),即以太网多环保护技术,是ITU-T定义的一种二层破环协议标准,标准号为ITU-T G.8032/Y1344,因此又称为G.8032。它定义了RAPS(Ring Auto Protection Switching)协议报文和保护倒换机制。 ERPS目前支持v1和v2两 阅读详情

相关推荐

Linux系统下SAPGUI安装包选择与避坑指南

本文详细介绍了在Linux系统下选择和安装SAPGUI安装包的策略与避坑指南。重点解析了不同版本安装包的关键区别,特别是Linux版必须包含linux-lib.jar和linux64-lib.jar文件,避免误用Mac或Windows版导致的兼容性问题。文章还提供了针对Ubuntu、RHEL等不同Linux发行版的安装实战指南,以及常见报错的解决方案,帮助用户顺利完成SAPGUI的安装与配置。

weixin_28366353的博客 675

Unity3D Shader官方教程翻译(八)----Shader语法:Pass的纹理处理

ShaderLab syntax: Texturing After the basic vertex lighting has been calculated, textures are applied. In ShaderLab this is done usingSetTexture command. 在基本的顶点照明计算完成以后,纹理将被设置。在ShaderLab中用Se

㊰ ❀ ☀ ☁ ☂ ☃ 1997

RPN 解析

RPN全称是Region Proposal Network,Region Proposal的中文意思是“区域选取”,也就是“提取候选框”的意思,所以RPN就是用来提取候选框的网络; 1. RPN的意义 RPN第一次出现在世人眼中是在Faster RCNN这个结构中,专门用来提取候选框,在RCNN和Fast RCNN等物体检测架构中,用来提取候选框的方法通常是Selective Se

lanran2的博客 10万+

Unity之Shader Pass 通道显示贴图的几种方法- 六

Pass 通道显示贴图的几种方法下面是几种显示模型贴图的方法,在此使用的是固定管线方法方法一Shader "Custom/PassOne" { Properties { //定义一个贴图 _MainTex ("Base (RGB)", 2D) = "white" {} //定义一个颜色 _Color ("Main Color",

lq 4889

Circos图审美拯救计划:用TBtools复刻Nature级共线性分析图谱

本文针对Circos图在共线性分析中的审美提升问题,提供了一套基于TBtools的完整优化方案。通过构建和谐的色彩体系、精细控制信息层布局以及模仿顶刊构图逻辑,详细讲解了如何从配色、透明度、标签显示到高级参数设置,将默认图表升级为具有高级学术美感的Nature级图谱,助力研究者提升论文图表质量。

cherry的博客 911

LabVIEW通过ActiveX控件实现与三菱FX5U PLC的高效数据交互

本文详细介绍了如何利用LabVIEW的ActiveX控件,通过三菱官方MX Component工具包实现与FX5U PLC的高效数据交互。文章从环境配置、控件插入到实战代码解析,系统讲解了连接建立、数据读写及资源释放的全流程,并提供了关键的避坑指南,帮助工程师快速构建稳定可靠的上位机通讯系统。

weixin_29197051的博客 376

Unity3d Shader(三) Pass

Pass通道块控制被渲染的对象的几何体。   Syntax 语法 Pass { [Name and Tags] [RenderSetup] [TextureSetup] } 基本通道命令包含一个可选的渲染设置命令的列表,和可选的被使用的纹理的列表。   Name and tags 名称和标签 一个通道能定义它的Name 和任意数量的Tags (用于向渲染引

FindSuningShine的专栏 958

Geant4学习一:写一个简单程序

1、 基本介绍

ccwwNUAA的博客 7700

Unity3D Shader官方教程翻译(三)

Unity3D Shader官方教程翻译(三) 1、Shader语法:Pass 1个Pass块可以使一个几何物体被一次渲染。 Pass { [Name and Tags] [RenderSetup] [TextureSetup] } 最基础的pass命令包含有1个可选的渲染设置命令列表,及1个可选的可用纹理列表。 Name and tags 一个Pass 可以

胡胜同学 2162

virtuoso--DFF

27-实验课-std_cell2

qq_61440044的博客 2009

关于华为高斯数据库出现Invalid or unsupported by client SCRAM mechanisms定位解决的过程

最近公司有个新项目使用的是高斯数据库,因为我们的项目是直接从别的项目组拿来的,配置都是已经配好的,但是在放到正式环境上之后出现报错。起初我们以为是测试和正式的版本不一致,但是结果是版本一致的。最后这个问题搞了我们几个小时,都没法解决。

Curtisjia的博客 3188

Unity3D Shader官方教程翻译(一)

Unity3D Shader官方教程翻译 Shader Reference 着色参考 Shaders in Unity can be written in one of three different ways: Unity3D着色器,可以写在三种不同的方式之一: assurface shaders, asvertex and fragm

roadProgram的专栏 918

AI算力网络与通信领域QoS保障的测试方法

在当今数字化时代,AI技术蓬勃发展,AI算力网络应运而生。它将分布在不同地理位置的算力资源进行整合,以高效地支持各种AI应用,如深度学习训练、智能图像识别等。而通信领域则是信息传输的基石,确保数据能够准确、快速地在不同节点之间传递。QoS保障在通信领域至关重要,它可以确保不同类型的业务(如语音通话、视频会议、在线游戏等)获得与其需求相匹配的服务质量。在AI算力网络中,QoS保障同样不可或缺,因为AI任务对网络的带宽、延迟、可靠性等指标有严格要求。

AI算力网络与通信的博客 529

Unity3D Shader官方教程翻译(四)

Unity3D Shader官方教程翻译(四) 1、Shader语法:Pass的雾化处理 雾化混合产生像素的颜色是依据于常量颜色(这个常量颜色是基于摄像头的距离的)。雾化不会改变像素的alpha值,仅仅是改变它的rgb分量。 指导:雾化是一种模拟自然界中雾气对场景物体视觉效果产生影响的图形绘制技术。此技术从视点到物体逐渐将物体的绘制颜色淡化,直至背景色。通过雾化处理可较好

胡胜同学 1175

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

jre9下载 jdk9

(Java SE Runtime Environment 9.0) 9.0u175 官方最新版 【x86|x64】

Unity3D Shader官方教程翻译(十一)----Shader语法:Pass的Blending(混合)

ShaderLab syntax: Blending 混合 Blending is used to make transparent objects. 混合是用来制作透明物体的。 When graphics are rendered, after all shaders have executed and all textures have been applied, t

u010216987的专栏 567

迈瑞BS系列全自动生化分析仪LIS协议接口手册(内含HL7和ASTM)

迈瑞BS系列全自动生化分析仪LIS协议接口手册,内含HL7和ASTM)

Unity3D Shader官方教程翻译(十四)----Shader语法:Pass的BindChannels 绑定通道

ShaderLab syntax: BindChannels 绑定通道。 BindChannels command allows you to specify how vertex data maps to the graphics hardware. BindChannels 命令 允许你指定顶点数据如何映射到显卡中。 BindChannels has no effect

㊰ ❀ ☀ ☁ ☂ ☃ 1416

温度PID控制PLC程序

温度PID稳定控制程序,适用于欧姆龙PLC,对其他PLC也具有很大参考价值

Unity3D Shader官方教程翻译Unity3D 的渲染管道

Unity's Rendering Pipeline Shaders define both how an object looks by itself (its material properties) and how it reacts to the light. Because lighting calculations must be built into the shader, a

xfnjlove的专栏 1053

Unity3D Shader官方教程翻译(十六)----Shader语法 GrabPass

ShaderLab syntax: GrabPass GrabPass is a special passtype - it grabs the contents of the screen where the object is about to be drawn into a texture. This texture can be used in subsequent passes

㊰ ❀ ☀ ☁ ☂ ☃ 1363

Uity3D Shader官方教程翻译(十四)----Shader语法:Pass的BindChannels 绑定通道

ShaderLab syntax: BindChannels 绑定通道。 BindChannels command allows you to specify how vertex data maps to the graphics hardware. BindChannels 命令 允许你指定顶点数据如何映射到显卡中。 BindChannels has no effect

3G-肖阳 2803
上一篇: Unity3D Shader官方教程翻译(七)----Shader语法:Pass的Culling & Depth Testing
下一篇: Unity3D Shader官方教程翻译(九)----Shader语法:Pass的雾化处理
coding_most
博客等级 码龄15年 13粉丝 38原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值