Home Unity

Unity Shader Help

polycounter lvl 14
Offline / Send Message
Noth polycounter lvl 14
Does anyone know of a shader for Unity that can do this, or where to get one?

I need it to emulate the effect Razor has from DOTA2. I've seen someone ask here before but didn't seem to get that far. I guess the shader would need two diffuse inputs, with the ability to apply a mask to one and the animated uv's effect just it, if that is possible? I'm no wiz here, but it seems like that would animate both textures sharing the uv set, maybe the shader will need two uvsets? Help meh out here.

yXtkzbx.png

Replies

  • mookster
    Options
    Offline / Send Message
    mookster polycounter lvl 18
    This is just one way to do it.

    One uv set, animated uvs are created in the shader. Hit play to preview.

    Use an alpha channel on Detail/lightning texture
    Composite mask slot is the detail map mask in your image.

    Shader "Custom/DetailTexture" {
    	Properties {
    		_MainTex ("Base (RGB)", 2D) = "white" {}
    		_DetailTex ("Detail Texture (RGB) Detail Mask (A)", 2D) = "black" {}
    		_Mask ("Composite Mask", 2D) = "black" {}
    		_XMove ("X Movement Speed", Float) = 0.0
    		_YMove ("Y Movement Speed", Float) = 0.0
    	}
    	SubShader {
    		Tags { "RenderType"="Opaque" }
    		LOD 200
    		
    		CGPROGRAM
    		#pragma surface surf Lambert
    
    		sampler2D _MainTex, _DetailTex, _Mask;
    		float _XMove, _YMove;
    
    		struct Input {
    			float2 uv_MainTex;
    		};
    
    		void surf (Input IN, inout SurfaceOutput o) {
    			float2 uv = float2(IN.uv_MainTex.x + _XMove * _Time.x , IN.uv_MainTex.y + _YMove * _Time.x);
    			half4 d = tex2D (_DetailTex, uv);
    			half dm = tex2D (_Mask, IN.uv_MainTex).a;
    			half4 c = tex2D (_MainTex, IN.uv_MainTex);
    			o.Albedo = c.rgb;
    			o.Emission = d.rgb*d.a*dm;
    			o.Alpha = c.a;
    		}
    		ENDCG
    	} 
    	FallBack "Diffuse"
    }
    
    
  • Zoid
    Options
    Offline / Send Message
    Zoid polycounter lvl 14
    now that's pretty hot mook!
  • Noth
    Options
    Offline / Send Message
    Noth polycounter lvl 14
    Lmao, this is awesome! It worked flawlessly once I found the Movement speed xy at the bottom, you are the MAN. I'll post my character once it's done with it in action. : DDDD Many thanks.
  • mookster
    Options
    Offline / Send Message
    mookster polycounter lvl 18
    No problem. Like i said there are many ways to accomplish the end result, or at least many maps that are excluded from this code sample.

    Looking forward to see what you do with it.
  • fire67
    Options
    Offline / Send Message
    fire67 polycounter lvl 8
    Hi @Noth I also suggest you to take a look at the Game Shaders Volume 1 - Dota 2, it is a shader framework for Unity based on the well known Dota 2 game.
    You will be able to follow the Dota 2 workflow and discover all the effects available :)
Sign In or Register to comment.