Last active
September 12, 2020 02:19
-
-
Save esnya/dc56c0075166f66c3ac3496de2a9811e to your computer and use it in GitHub Desktop.
LightmapStaic有効かEnable GPU Instancing有効でないと機能しません。
This file contains hidden or 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 "Custom/RandomObjectColor" | |
{ | |
Properties | |
{ | |
_Color("Color", Color) = (1,1,1,1) | |
_MainTex("Albedo", 2D) = "white" {} | |
// _Cutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5 | |
[Space] [NoScaleOffset] _SpecGlossMap("Roughness Map", 2D) = "black" {} | |
[NoScaleOffset] _MetallicGlossMap("Metallic", 2D) = "black" {} | |
[NoScaleOffset][Normal] _BumpMap("Normal Map", 2D) = "bump" {} | |
_BumpScale("Normal Scale", Float) = 1.0 | |
_EmissionColor("Emission", Color) = (0,0,0) | |
[NoScaleOffset] _EmissionMap("Emission", 2D) = "white" {} | |
[Header(Random Object Color)] | |
[NoScaleOffset] _ColorRamp ("Color Ramp", 2D) = "white" {} | |
_Mix("Mix", Range(0, 1)) = 1.0 | |
[Space] | |
[Enum(UnityEngine.Rendering.CullMode)] _Cull("Cull", Float) = 2 | |
[Enum(Off, 0, On, 1)] _ZWrite("ZWrite", Float) = 1 | |
} | |
SubShader | |
{ | |
Tags { | |
"RenderType" = "Opaque" | |
"Queue" = "Geometry" | |
} | |
LOD 200 | |
Cull [_Cull] | |
ZWrite [_ZWrite] | |
CGPROGRAM | |
#pragma surface surf Standard fullforwardshadows | |
#include "./RandomObjectColor_Core.cginc" | |
ENDCG | |
} | |
FallBack "Diffuse" | |
} |
This file contains hidden or 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
fileFormatVersion: 2 | |
guid: 9144492889f574845b831a67a90a7341 | |
ShaderImporter: | |
externalObjects: {} | |
defaultTextures: [] | |
nonModifiableTextures: [] | |
userData: | |
assetBundleName: | |
assetBundleVariant: |
This file contains hidden or 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 "Custom/RandomObjectColor_AlphaCutout" | |
{ | |
Properties | |
{ | |
_Color("Color", Color) = (1,1,1,1) | |
_MainTex("Albedo", 2D) = "white" {} | |
_Cutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5 | |
[Space] [NoScaleOffset] _SpecGlossMap("Roughness Map", 2D) = "black" {} | |
[NoScaleOffset] _MetallicGlossMap("Metallic", 2D) = "black" {} | |
_BumpScale("Scale", Float) = 1.0 | |
[NoScaleOffset][Normal] _BumpMap("Normal Map", 2D) = "bump" {} | |
_EmissionColor("Emission", Color) = (0,0,0) | |
[NoScaleOffset] _EmissionMap("Emission", 2D) = "white" {} | |
[Header(Random Object Color)] | |
[NoScaleOffset] _ColorRamp ("Color Ramp", 2D) = "white" {} | |
_Mix("Mix", Range(0, 1)) = 1.0 | |
[Space] | |
[Enum(UnityEngine.Rendering.CullMode)] _Cull("Cull", Float) = 2 | |
[Enum(Off, 0, On, 1)] _ZWrite("ZWrite", Float) = 1 | |
} | |
SubShader | |
{ | |
Tags { | |
"RenderType" = "Opaque" | |
"Queue" = "AlphaTest" | |
} | |
LOD 200 | |
Cull [_Cull] | |
ZWrite [_ZWrite] | |
CGPROGRAM | |
#pragma surface surf Standard fullforwardshadows alphatest:_Cutoff | |
#include "./RandomObjectColor_Core.cginc" | |
ENDCG | |
} | |
FallBack "Diffuse" | |
} |
This file contains hidden or 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
fileFormatVersion: 2 | |
guid: 75c20a2b7f560974a8f4765b72af23fa | |
ShaderImporter: | |
externalObjects: {} | |
defaultTextures: [] | |
nonModifiableTextures: [] | |
userData: | |
assetBundleName: | |
assetBundleVariant: |
This file contains hidden or 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
struct Input | |
{ | |
float2 uv_MainTex; | |
}; | |
fixed4 _Color; | |
sampler2D _MainTex; | |
float _Glossiness; | |
sampler2D _SpecGlossMap; | |
float _Metallic; | |
sampler2D _MetallicGlossMap; | |
float _BumpScale; | |
sampler2D _BumpMap; | |
fixed4 _EmissionColor; | |
sampler2D _EmissionMap; | |
float _Mix; | |
sampler2D _ColorRamp; | |
// UNITY_INSTANCING_BUFFER_START(Props) | |
// UNITY_INSTANCING_BUFFER_END(Props) | |
inline float rand(float3 co) | |
{ | |
return frac(sin(dot(co.xyz, float3(12.9898, 78.233, 56.787))) * 43758.5453); | |
} | |
void surf (Input IN, inout SurfaceOutputStandard o) | |
{ | |
// float objectId = rand(float3(unity_ObjectToWorld._14, unity_ObjectToWorld._24, unity_ObjectToWorld._34)); | |
float objectId = rand(mul(unity_ObjectToWorld, float4(0, 0, 0, 1.0)).xyz); | |
fixed4 color = tex2D(_MainTex, IN.uv_MainTex) * _Color * lerp(fixed4(1, 1, 1, 1), tex2D(_ColorRamp, float2(objectId, 0.5)), _Mix); | |
o.Albedo = color.rgb; | |
o.Alpha = color.a; | |
o.Normal = UnpackScaleNormal(tex2D(_BumpMap, IN.uv_MainTex), _BumpScale); | |
o.Metallic = tex2D(_MetallicGlossMap, IN.uv_MainTex); | |
o.Smoothness = 1.0f - tex2D(_SpecGlossMap, IN.uv_MainTex); | |
o.Emission = _EmissionColor * tex2D(_EmissionMap, IN.uv_MainTex); | |
} |
This file contains hidden or 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
fileFormatVersion: 2 | |
guid: d402c6b5161aaaf4b98c514ca1b865fd | |
ShaderImporter: | |
externalObjects: {} | |
defaultTextures: [] | |
nonModifiableTextures: [] | |
userData: | |
assetBundleName: | |
assetBundleVariant: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment