Unity EditorWindow And Assetprocessor

Tutorials Editor folder contains any editor scripts. It allows no mono behavior scripts in it. AssetPostprocessor is one of the editor class. One of the properties is assetPath, the path name of the asset being imported. A series of function is called in the following order during the model import: OnPreprocessModel: I can override ModelImporter settings in here. After meshes and materials are imported, GameObjects hierarchy is created from the imported nodes....

November 30, 2020 · Kyle Fang

Tree And Wind Shader

Vertex Color, Alpha and Shadow Surface shader is actually a vertex and fragment shader too, so theoretically the vertex data is accessible in surface shader too by using SEMANTICS or common state vert struct v2f { half4 color : COLOR; }; As for the Alpha Texture, we can decide the color based on the UV mapping in vertex function fixed4 frag (v2f i) : COLOR0 { ... fixed alpha = tex2D (_AlphaTex, i....

October 23, 2020 · Kyle Fang

Unity Render Pipeline

RP is a series of operations that take the contents of a Scene and displays them on a screen. At a high level, these operations are Culling, Rendering, and Post-Processing. It’s difficult to switch from one to another RP because the shader outputs varies and might not have the same feature. We can custom shaders in different piplelines, but the ultimate effect may be different. Unity has Built-In, Universal, and High Definition and Scriptable RP....

May 30, 2020 · Kyle Fang

Guide Mask Shader

Shader "UI/GuideMask" { Properties { [PreRendererData] _MainTex ("Sprite Texture", 2D) = "white" {} _Color ("tint", Color) = (1,1,1,1) _StencilComp ("Stencil Comparison", Float) = 8 _Stencil ("Stencil ID", Float) = 0 _StencilOp ("Stencil Operation", Float) = 0 _StencilWritemask("Stencil Write Mask", Float ) = 255 _StencilReadMask("Stencil Read Mask", Float) = 255 _ColorMask("Color Mask", Float) = 15 [Toggle(UNITY_UI_ALPHACLIP)] _UseUIAlphaClip ("Use Alpha Clip", Float) = 0 _Center("Center", vector) = (0, 0, 0, 0) _Slider("Slider", Range(0, 1500)) = 1500 } SubShader { Tags { "RenderType"="Opaque" "IgnoreProjector" = "True" "RenderType" = "Transparent" "PreviewType" = "Plane" "CanUseSpriteAtlas" = "True" } Stencil { Ref [_Stencil] Comp [_StencilComp] Pass [_StencilOp] ReadMask [_StencilReadmask] Writemask [_StencilWriteMask] } Cull Off Lighting Off ZWrite Off ZTest [unit_GUIZTestMode] Blend SrcAlpha OneMinusSrcAlpha ColorMask [_ColorMask] Pass { Name "Default" CGPROGRAM #pragma vertex vert #pragma fragment frag #pragma target 2....

May 7, 2020 · Kyle Fang

Unity Vertex And Fragment Shader

Rendering is done in 2 steps. First, geometry is passed to the vertex function which can alter the position and data of each vertex. Then, the result goes through a fragment function which outputs the color. There’s no albedo, gloss and specular properties in here, so Vertex and fragment shader is often used in non-realistic material, 2D graphics, and post-processing effects. *Surface shader is actually compiled to vert/frag shader. Shader "Unlit/SolidColor" { SubShader { Pass { CGPROGRAM #pragma vertex vert #pragma fragment frag struct vertInput { float4 pos : POSITION; }; struct vertOuput { float4 pos : SV_POSITION; }; vertOuput vert(vertInput input) { vertOuput o; o....

November 30, 2019 · Kyle Fang