Advertisement
noradninja

Standard Mobile Vertex Lit

Feb 27th, 2025
259
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 5.58 KB | None | 0 0
  1. Shader "Vita/Standard Mobile Vertex Lit" {
  2.     Properties {
  3.         _MainTex("Base (RGB)", 2D) = "white" { }
  4.         _MOAR("MOAR (RGBA)", 2D) = "white" { }
  5.         _Metallic ("Metallic", Range(0,1)) = 0.5
  6.         _Roughness ("Roughness", Range(0,1)) = 0.5
  7.         _Cutoff ("Alpha cutoff", Range(0,1)) = 0.5
  8.         [Toggle(ALPHA_ON)] _AlphaOn("Seperate Alpha", Float) = 1
  9.         [Toggle(AMBIENT_ON)] _AmbientOn("Ambient Lighting", Float) = 0
  10.     }
  11.  
  12.     SubShader {
  13.     Tags { "Queue"="AlphaTest" "IgnoreProjector"="True" "RenderType"="TransparentCutout" } //I know this is weird but it's a workaround for the Vita
  14.         LOD 80
  15.         ZWrite On
  16.         Cull Off
  17.         Blend One OneMinusSrcAlpha //because we are going to clip at the end
  18.  
  19.         // Non-lightmapped
  20.         Pass
  21.         {
  22.             Tags { "LightMode" = "Vertex" }
  23.             CGPROGRAM
  24.             #pragma vertex vert
  25.             #pragma fragment frag
  26.             #pragma target 3.0
  27.             #pragma multi_compile_fog
  28.             // Compile specialized variants for when positional (point/spot) and spot lights are present
  29.             #pragma multi_compile __ POINT SPOT
  30.             #pragma multi_compile _ LOD_FADE_CROSSFADE
  31.             #include "VertexLightmapCommon.cginc"
  32.             #include "AutoLight.cginc"
  33.             #include "Lighting.cginc"
  34.  
  35.        
  36.  
  37.         ENDCG
  38.         }
  39.    
  40.         // Lightmapped
  41.         Pass
  42.         {
  43.             Tags { "LightMode" = "VertexLM" }
  44.        
  45.      
  46.             CGPROGRAM
  47.             #pragma vertex vert
  48.             #pragma fragment frag  
  49.             #pragma target 3.0
  50.             #pragma multi_compile_fog
  51.             // Compile specialized variants for when positional (point/spot) and spot lights are present
  52.             #pragma multi_compile __ POINT SPOT
  53.             #pragma multi_compile __ AMBIENT_ON
  54.             #pragma multi_compile _ LOD_FADE_CROSSFADE
  55.             #pragma shader_feature BAKERY_VERTEXLM
  56.             #pragma shader_feature BAKERY_VERTEXLMDIR
  57.             #pragma shader_feature BAKERY_VERTEXLMSH
  58.             #pragma shader_feature BAKERY_VERTEXLMMASK
  59.             #pragma shader_feature BAKERY_SH
  60.             #pragma shader_feature BAKERY_SHNONLINEAR
  61.             #pragma shader_feature BAKERY_RNM
  62.             #pragma shader_feature BAKERY_LMSPEC
  63.             #pragma shader_feature BAKERY_BICUBIC
  64.             #pragma shader_feature BAKERY_PROBESHNONLINEAR
  65.             #pragma shader_feature BAKERY_VOLUME
  66.             #pragma shader_feature BAKERY_COMPRESSED_VOLUME
  67.             #pragma shader_feature BAKERY_VOLROTATION
  68.             #define CUSTOM_LIGHTMAPPED 1
  69.             #include "VertexLightmapCommon.cginc"
  70.             #include "AutoLight.cginc"
  71.             #include "Lighting.cginc"
  72.    
  73.    
  74.         ENDCG
  75.         }
  76.             // Extracts information for lightmapping, GI (emission, albedo, ...)
  77.             // This pass it not used during regular rendering.
  78.         Pass
  79.         {
  80.             Name "META"
  81.             Tags { "LightMode"="Meta" }
  82.  
  83.             Cull Off
  84.  
  85.             CGPROGRAM
  86.             #pragma vertex vert_meta
  87.             #pragma fragment frag_meta
  88.  
  89.             #pragma shader_feature _EMISSION
  90.             #pragma shader_feature _METALLICGLOSSMAP
  91.             #pragma shader_feature _ _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
  92.             #pragma shader_feature ___ _DETAIL_MULX2
  93.             #pragma shader_feature EDITOR_VISUALIZATION
  94.  
  95.             #include "UnityStandardMeta.cginc"
  96.             ENDCG
  97.         }
  98.         Pass
  99.         {
  100.             Tags {"LightMode"="ShadowCaster"}
  101.  
  102.             CGPROGRAM
  103.             #pragma vertex vert_shadow
  104.             #pragma fragment frag_shadow
  105.             #pragma target 3.0
  106.             #pragma multi_compile_shadowcaster
  107.             #pragma multi_compile_fog
  108.             #pragma multi_compile _ LOD_FADE_CROSSFADE
  109.             #include "UnityCG.cginc"
  110.             #include "UnityPBSLighting.cginc" // TBD: remove
  111.             #include "UnityShadowLibrary.cginc"
  112.            
  113.             struct v2f {
  114.                 V2F_SHADOW_CASTER;
  115.                 float2  uv : TEXCOORD0;
  116.                 UNITY_VERTEX_OUTPUT_STEREO
  117.     //              half3 normal : NORMAL;
  118.             };
  119.             struct appdata {
  120.                 half3 vertex : POSITION;
  121.                 half3 color : COLOR0;
  122.                 half3 uv : TEXCOORD0;
  123.                
  124.  
  125.             };
  126.  
  127.            
  128.             uniform float4 _MainTex_ST;
  129.             half4 _wind_dir;
  130.             half _wind_size;
  131.             half _leaves_wiggle_disp;
  132.             half _leaves_wiggle_speed;
  133.             half _influence;
  134.             half _LeavesOn;
  135.  
  136.             v2f vert_shadow( appdata v )
  137.             {
  138.                 v2f o;
  139.                 half3 worldPos = mul (unity_ObjectToWorld, half4(v.vertex, 1) ).xyz;
  140.                 half3 currentPos = v.vertex;
  141.                 half3 previousPos = currentPos;
  142.                 half3 nextPos = currentPos;
  143.                 if(_LeavesOn)
  144.                     {
  145.                         //Leaf Movement and Wiggle
  146.                         ( (nextPos.x += sin(_Time.y * currentPos.x * _leaves_wiggle_speed + (worldPos.x/_wind_size) ) * _leaves_wiggle_disp * _wind_dir.x * (_influence * v.color)), //x
  147.                         (nextPos.y += sin(_Time.y * currentPos.y * _leaves_wiggle_speed + (worldPos.y/_wind_size) ) * _leaves_wiggle_disp * _wind_dir.y * (_influence * v.color)),   //y
  148.                         (nextPos.z += sin(_Time.y * currentPos.z * _leaves_wiggle_speed + (worldPos.z/_wind_size) ) * _leaves_wiggle_disp * _wind_dir.z * (_influence * v.color))); //z
  149.                     }
  150.                 // Now interpolate using a factor (which might be based on a small time delta)
  151.                 float t = 0.5h; // or any other interpolation factor
  152.                 v.vertex = lerp(previousPos, nextPos, t);
  153.  
  154.                 UNITY_SETUP_INSTANCE_ID(v);
  155.                 UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
  156.                 TRANSFER_SHADOW_CASTER(o);
  157.                 o.uv = TRANSFORM_TEX(v.uv, _MainTex);
  158.                 return o;
  159.             }
  160.  
  161.             uniform sampler2D _MainTex;
  162.             uniform sampler2D _MOAR;
  163.             uniform fixed _Cutoff;
  164.             float _AlphaOn;
  165.  
  166.             float4 frag_shadow( v2f i ) : SV_Target
  167.             {
  168.                 if (!_AlphaOn)
  169.                 {
  170.                     fixed4 texcol = tex2D( _MainTex, i.uv );
  171.                     clip( texcol.a - _Cutoff );
  172.                 }
  173.                 else
  174.                 {
  175.                     fixed4 texcol = tex2D( _MOAR, i.uv );
  176.                     clip( texcol.b - _Cutoff );
  177.                 }
  178.  
  179.                 SHADOW_CASTER_FRAGMENT(i);
  180.             }
  181.         ENDCG
  182.         }
  183.     }
  184.     Fallback "Legacy Shaders/Diffuse"
  185. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement