In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
How to get started with ShaderLab in Unity graphics? in view of this problem, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible method.
1. Format Shader "Custom/MyShader" / / naming + right create shader path {/ / attribute must be declared in the code to use Properties {/ / attribute Will appear in inspector panel _ MainTex ("MainTex", 2D) = "white" {} / / name ("panel display name", data type) = initialization} / / there can be different subshader for different video cards Define the rendering setting ZWrite Off / / RenderSetup corresponding to the rendering SubShader {Tags {"LightMode" = "ForwardBase"} / / tags of different quality Render settings Pass {/ / Channel pass, a subshader can have multiple pass Name = "MyPass" / / pass can be named In other subshader references UsePass uppercase CGPROGRAM / / start CG code-pair with ENDCG # pragma vertex vert / / define rendering function Vertex # pragma fragment frag / / element # pragma surface surf Lambert / / Surface # include "Lighting.cginc" / / include method library sample2D _ MainTex / / declare variable float4 _ MainTex_ST; struct a2v / / Custom structure {float4 vertex: POSITION; / / variable type variable name: semantic description (language stipulation) float3 normal: NORMAL } v2f vert (appdata v) / / function body {v2f o; return o } ENDCG}} SubShader {...} FallBack "Diffuse" / / above subshader cards are not supported. Diffuse is returned by default.
Uniform modifier
Name = "MyPass"
-- UsePass "Unlit/Outline/MYPASS" / / must be capitalized
-- GrapPass// capture screen results are stored in a texture
two。 Attribute
Declare the use of the variable type corresponding to the attribute; the type in the attribute is not necessarily the same as the type in the variable
3. Semantic meaning
SV_ begins with semantic variables defined by the System-Value-- system
4.Tags
1) SubShader is available
Queue-- rendering queue
RenderType-- render Typ
(1) "Opaque": this is used by most opaque objects.
(2) "Transparent": this is used by most transparent objects, including particle effects.
(3) "Background": this is used in all sky boxes.
(4) "Overlay": this is used for GUI and lens halo.
(5) there are other Rendering with Replaced Shaders; users who can also define any RenderType string of their own.
(6) "TransparentCutout": transparent testing use
IgnoreProjector = "True"-ignoring the influence of the projector, AlphaTest and AlphaBlend use
ForceNoShadowCasting = "True"-indicates that shadows are not accepted
2) Pass is available
"LightMode" = "ForwardBase"
5.RenderSetup
1) Cull culling
Cull Front/Back/Off
2) depth testing and writing
ZWrite Off
ZTest Off
3) Blend-- transparent blending settings
BlendOp
Blend effect
6. Method
Common structures of UnityCG.cginc
Writing suggestions:
1. The shader of the mobile platform uses the variable with low precision as much as possible: fixed-half-float
two。 Error: lack of registers due to a large number of calculations in the chip element-raising the shaderTarget level
3. Try not to use branch statements
4. Do not divide by 0
Life is too short for so much sorrow.
This is the answer to the question about how to get started with ShaderLab in Unity graphics. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel to learn more about it.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.