- Home /
Question by
lagidigu3ll · May 01, 2015 at 05:08 PM ·
unity 5surface shader
How to get the standard Shader look on a custom shader
Hi there! I've been working on a surface shader that distorts vertices based on their distance to the camera, it works fine, but only has a very primitive diffuse effect.
Do you know if there is a way to include the look of the "Standard" shader of Unity 5, which look pretty damn neat? :)
Here's what the shader looks like:
Shader "Custom/CurvedWorld" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
_Sin1_Frequency ("Frequency Of Wave 1", Float) = 0.12
_Sin1_Offset ("Offset Of Wave 1", Float) = 2.61
_Sin1_Amplitude ("Amplitude of Wave 1", Float) = 0.35
_Sin2_Frequency ("Frequency Of Wave 2", Float) = 0.46
_Sin2_Offset ("Offset Of Wave 2", Float) = 3.26
_Sin2_Amplitude ("Amplitude of Wave 2", Float) = 0.55
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 200
CGPROGRAM
#pragma surface surf Lambert vertex:vert addshadow
uniform sampler2D _MainTex;
uniform float _Sin1_Frequency;
uniform float _Sin1_Offset;
uniform float _Sin1_Amplitude;
uniform float _Sin2_Frequency;
uniform float _Sin2_Offset;
uniform float _Sin2_Amplitude;
struct Input {
float2 uv_MainTex;
};
void vert( inout appdata_full v)
{
float4 vv = mul( _Object2World, v.vertex );
vv.xyz -= _WorldSpaceCameraPos.xyz;
vv = float4( 0.0f, (vv.z *sin(vv.z* _Sin1_Frequency - _Sin1_Offset) * _Sin1_Amplitude) + (sin(vv.z * _Sin2_Frequency - _Sin2_Offset) * _Sin2_Amplitude) + pow(abs(vv.x), 2) * vv.z * 0.0005, 0.0f, 0.0f );
v.vertex += mul(_World2Object, vv);
}
void surf (Input IN, inout SurfaceOutput o) {
half4 c = tex2D (_MainTex, IN.uv_MainTex);
o.Albedo = c.rgb;
o.Alpha = c.a;
}
ENDCG
}
}
Thanks a lot in advance! :D
Comment
Your answer
Follow this Question
Related Questions
Splat Map shader no longer working in Unity 5 1 Answer
Unlit terrain shader 0 Answers
Simple cartoon water shader shoreline 1 Answer
Multipass Surface Shader with _CameraDepthNormalsTexture 0 Answers
Transparent shadow in surface shader 0 Answers