Unity shader (CG) writes a wave texture with multiple effects, unityshader

Source: Internet
Author: User

Unity shader (CG) writes a wave texture with multiple effects, unityshader
Unity shader (CG) writes a wave texture with multiple effects

1. Unity shader, which simplifies the pace of writing a lot of shader, 2. Unity is based on the left-hand world coordinate system, which makes people feel pretty good. 3. Many people are always sensitive to UV. For example, UV is 0-1, and sometimes uv can be infinitely large. In fact, uv
4. This dick editor has lost the text at the end of 3... Let's take a look at the effects of Ripple. Its code is a bit of unmodified code.
// Shayu shader by qq834144373 // technical compilation by qq834144373 // For more details, please contact qq834144373Shader "Custom/shayu" {Properties {_ MainTex ("Base (RGB )", 2D) = "white" {}_ R1 ("gray color gradient", Range (0.0, 1.1) = 0 _ Texure ("light and shade texture", 2D) = "white" {} _ R ("Ripple brightness", Range (. (0, 4.0) = 1. _ R0 ("Ripple density", float) = 1. _ Color ("light Color", Color) = (1.0, 1.0, 1.0, 1.0 )} subShader {Tags {"RenderType" = "Opaque"} // "Queue" = "Overlay" levels 200 Pas S {ZWrite On Blend Off AlphaTest Off Lighting Off CGPROGRAM // Upgrade NOTE: excluded shader from qq834144373, twitter @ 834144373Zhu because you shoshould call me here. // # pragma exclude_renderers d3d11 xbox360 gles flash all the terget !!!! # Pragma vertex vert # pragma fragment frag # include "UnityCG. cginc "sampler2D _ MainTex; fixed _ R1; sampler2D _ Texure; half _ R; half _ R0; fixed4 _ Color; half4 _ MainTex_ST; half4 _ Texure_ST; // float4x4 _ Object2Light; struct vertIN {float4 vertex: POSITION; fixed2 tex: TEXCOORD0; fixed3 normal: NORMAL;}; struct vertOUT {float4 pos: SV_POSITION; // half4 ver: TEXCOORD1; fixed4 uv: TEXCOORD0; fixed3 nDir: NORMAL; fixed3 lDir: TEXCOORD2; // fixed2 screenUV: TEXCOORD3 ;}; vertOUT vert (vertIN I) {vertOUT o; o. pos = mul (UNITY_MATRIX_MVP, I. vertex); // float4x4 m = float4x4 (float4 (_ Object2World [0]), float4 (_ Object2World [1]), float4 (_ Object2World [2]), float4 (_ Object2World [3]); // o. ver = mul (m, I. vertex); // half4 v = half4 (I. vertex. x, I. vertex. z,-I. vertex. y, I. vertex. w); float4 ver = mul (_ Object2World, I. vertex); // half4x4 m = float4x4 (half4 (UNITY_MATRIX_P [0]), half4 (UNITY_MATRIX_P [1]), half4 (UNITY_MATRIX_P [2]), half4 (UNITY_MATRIX_P [3]); // ver = mul (m, ver); // ver = ver * 2. -1 .; // o. ver = mul (UNITY_MATRIX_P, o. ver); // o. ver. xy = float2 (o. ver. x, o. ver. y * _ ProjectionParams. x) + o. ver. w; // ver. xz = ver. xz/1; ver. xz = ver. xz/ver. y; o. uv. rg = TRANSFORM_TEX (I. tex, _ MainTex); o. uv. ba = TRANSFORM_TEX (ver. xz, _ Texure); o. nDir = normalize (mul (_ World2Object, I. normal); o. lDir = normalize (WorldSpaceLightDir (I. vertex); return o;} fixed4 frag (vertOUT ou): SV_target {fixed4 c0 = tex2D (_ MainTex, ou. uv. rg); fixed3 c1 = Luminance (c0.rgb); fixed diff = max (0, dot (fixed3 (0, 0), ou. nDir); fixed4 c = tex2D (_ Texure, ou. uv. zw * _ R0 + sin (_ Time. x) * _ Color * c0; // if (diff <-0.1) {// c. rgb = 0; //} c. rgb * = lerp (0 ., _ R, diff); c0.rgb = lerp (c1, c0.rgb, _ R1); return c + c0; // * diff;} ENDCG} FallBack "code belongs to qq834144373 "}
Shader = World + imagination + feeling

Writing shader is a wonderful and enjoyable thing. When you find that the world can be written with shader, you will never feel shader boring ....

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.