Last active
October 22, 2018 15:36
-
-
Save sasanon/5d85bb4b96b8a7b3b8e95d9655d7d140 to your computer and use it in GitHub Desktop.
Unity Noise-Shader Sample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Shader "Sasami/NoiseSample" | |
{ | |
Properties | |
{ | |
_NoiseTilingOffset ("NoiseTex Tiling(x,y)/Offset(z,w)", Vector) = (0.1,0.1,0,0) | |
_NoiseSizeScroll ("NoiseTex Size(x,y)/Scroll(z,w)" , Vector) = (16,16,0,0) | |
} | |
SubShader | |
{ | |
Tags { "RenderType"="Opaque" } | |
LOD 100 | |
Pass | |
{ | |
CGPROGRAM | |
#pragma vertex vert | |
#pragma fragment frag | |
#include "SasamiNoise.cginc" | |
struct appdata | |
{ | |
float4 vertex : POSITION; | |
float2 uv : TEXCOORD0; | |
}; | |
struct v2f | |
{ | |
float4 vertex : SV_POSITION; | |
float2 uv : TEXCOORD0; | |
}; | |
fixed4 _NoiseTilingOffset; | |
fixed4 _NoiseSizeScroll; | |
v2f vert (appdata v) | |
{ | |
v2f o; | |
o.vertex = UnityObjectToClipPos(v.vertex); | |
o.uv = TRANSFORM_NOISE_TEX(v.uv, _NoiseTilingOffset, _NoiseSizeScroll); | |
return o; | |
} | |
fixed4 frag (v2f i) : SV_Target | |
{ | |
fixed p = perlinNoise(i.uv, _NoiseSizeScroll.xy); | |
//return fixed4 ( p, p, p, 1 ); // 白黒のノイズ画像を生成 | |
return fixed4 ( normalNoise(i.uv, _NoiseSizeScroll.xy), 1 ); // 法線マップ用パーリンノイズ画像を生成 | |
} | |
ENDCG | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment