Advertisement
Malzar

Melted Shader

Sep 2nd, 2018
339
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Shader "Malzar/Melted" {
  2.     Properties {
  3.         _Color ("Color", Color) = (1,1,1,1)
  4.         _MainTex ("Albedo (RGB)", 2D) = "white" {}
  5.         _Glossiness ("Smoothness", Range(0,1)) = 0.5
  6.         _Metallic ("Metallic", Range(0,1)) = 0.0
  7.         //_High ("Melted point", Float) = 0
  8.         _High("Melted point",Range(0,1.5))=0
  9.         _ColorMelted("Melted Color", Color) = (1,1,1,1)
  10.     }
  11.     SubShader {
  12.         Tags { "RenderType"="Opaque" }
  13.         LOD 200
  14.         ZWrite ON
  15.  
  16.         CGPROGRAM
  17.         // Physically based Standard lighting model, and enable shadows on all light types
  18.         #pragma surface surf Standard fullforwardshadows vertex:vert addshadow
  19.  
  20.         // Use shader model 3.0 target, to get nicer looking lighting
  21.         #pragma target 3.0
  22.  
  23.         sampler2D _MainTex;
  24.         half _Glossiness;
  25.         half _Metallic;
  26.         fixed4 _Color;
  27.         fixed4 _ColorMelted;
  28.         half _High;
  29.  
  30.         struct Input {
  31.             float2 uv_MainTex;
  32.             half percentaje;
  33.             half vMod;
  34.         };
  35.  
  36.         struct appdata{
  37.             float4 vertex :POSITION;
  38.             float3 normal : NORMAL;
  39.             float4 texcoord : TEXCOORD0;
  40.         };
  41.  
  42.         void vert(inout appdata v, out Input o){
  43.             UNITY_INITIALIZE_OUTPUT(Input,o);
  44.             o.percentaje = (v.vertex.y-_High)/v.vertex.y;
  45.             v.vertex.y =(v.vertex.y>_High)*(v.vertex.y* o.percentaje)
  46.                         + (v.vertex.y<_High)*v.vertex.y*0.001;
  47.             o.vMod = (v.vertex.y<_High);
  48.         }
  49.         UNITY_INSTANCING_BUFFER_START(Props)
  50.             // put more per-instance properties here
  51.         UNITY_INSTANCING_BUFFER_END(Props)
  52.  
  53.         void surf (Input IN, inout SurfaceOutputStandard o) {
  54.             // Albedo comes from a texture tinted by color
  55.             fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;
  56.             o.Albedo = c.rgb * (1-IN.vMod) + (_ColorMelted+c.rgb*IN.percentaje)*IN.vMod;
  57.             // Metallic and smoothness come from slider variables
  58.             o.Metallic = _Metallic;
  59.             o.Smoothness = _Glossiness * (1-IN.vMod) + (1-IN.percentaje)*IN.vMod;
  60.             o.Alpha = c.a;
  61.         }
  62.         ENDCG
  63.     }
  64.     FallBack "Diffuse"
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement