Unity中的屏幕坐标:ComputeScreenPos/VPOS/WPOS
摘要:【Unity中的屏幕坐标:ComputeScreenPos/VPOS/WPOS】 1、通过 VPOS / WPOS 语义获取。 VPOS 是 HLSL 中 对 屏幕 坐标 的 语义, 而 WPOS 是 Cg 中 对 屏幕 坐标 的 语义。 上面的Shader,得到的效果如图: VPOS/ WPOS
阅读全文
深度和法线纹理
摘要:【深度和法线纹理】 1、使用深度和法线纹理进行边缘检测,则不会受纹理、光照的影响。 深度纹理的范围是[0, 1]。而NDC坐标下深度范围是[-1,1]。转换公式: d = 0.5*Zndc + 0.5 2、如何在Unity中获取这两种纹理。 Unity中,深度纹理可以直接来自于真正的深度缓存,也可以
阅读全文
GraphicsTier
摘要:【GraphicsTier】 1、enum GraphicsTier 2、enum ShaderQuality 3、enum BuildTargetGroup 4、EditorGraphicsSettings.SetTierSettings public static void SetTierSet
阅读全文
multi_compile
摘要:【multi_compile】 Used to compile the shader code multiple times with different preprocessor directives for each case. #pragma multi_compile #pragma sha
阅读全文
Rendering with Replaced Shaders
摘要:【Rendering with Replaced Shaders】 1、RenderType tag RenderType tag categorizes shaders into several predefined groups, e.g. is is an opaque shader, or
阅读全文
ColorMask
摘要:【ColorMask】 When using multiple render target (MRT) rendering, it is possible to set up different color masks for each render target, by adding index
阅读全文
Lamber算法 & SurfaceShader自定义光照
摘要:【SurfaceShader自定义光照】1、在pragma中添加自定义光照函数名: #pragma surface surf BasicDiffuse2、实现自定义光照函数。下面就是Lambert光照模型。也是Lambert算法。 _LightColor0是Unity提供的变量。使用该算法的...
阅读全文
CG中的类型
摘要:【Matrix】 通常像下面这样定义Matrix:int1x1 iMatrix; // integer matrix with 1 row, 1 columnint4x1 iMatrix; // integer matrix with 4 rows, 1 columnint1...
阅读全文
Vertex Modifier of Surface Shader
摘要:【Vertex Modifier of Surface Shader】 Surface shader compilation directivevertex:functionName 可以用于指定顶点着色器。Afunction that takesinout appdata_fullparamet...
阅读全文
Writing Surface Shaders
摘要:【Writing Surface Shaders】 Writing shaders that interact with lighting is complex. There are different light types, different shadow options, differen...
阅读全文
GLSL in ShaderLab
摘要:【Syntax】 However,use of raw GLSL is only recommended for testing, or when you know you will only target Mac OS X or OpenGL ES 2.0 compatible mobile d...
阅读全文
Vertex and fragment programs
摘要:【Vertex and fragment programs】 When you use vertex and fragment programs (the so called "programmable pipeline"), most of the hardcoded functionality...
阅读全文
Stencil
摘要:【Stencil】 The stencil buffer can be used as a general purpose per pixel mask for saving or discarding pixels. The stencil buffer is usually an 8 bit...
阅读全文
Fog
摘要:【Fog】 Fog parameters are controlled with Fog command. Fogging blends the color of the generated pixels down towards a constant color based on dist...
阅读全文
Blending
摘要:【Blending】 Blending is used to make transparent objects. When graphics are rendered, after all shaders have executed and all textures have been applie
阅读全文
AlphaTesting
摘要:【Alpha Testing】 The alpha test is a last chance to reject a pixel from being written to the screen. After the final output color has been calculat...
阅读全文
Culling & Depth Testing
摘要:【Culling & Depth Testing】 Culling is an optimization that does not render polygons facing away from the viewer. All polygons have a front and a back ...
阅读全文
Pass
摘要:【Pass】 The Pass block causes the geometry of an object to be rendered once. Pass相当于如下的OpenGL调用序列: 1) glXXX -> ... glXXX -> glDrawElement* , 这是Pass1 2)
阅读全文
ShaderLab
摘要:【ShaderLab】 Shader is the root command of a shader file. Each file must define one (and only one) Shader. It specifies how any objects whose material
阅读全文