Jump to content
Unity Insider Forum
Sign in to follow this  
MustafGames

Shader Cutout sieht blöd aus

Recommended Posts

Grüße,

vorne weg das ist mein erster Shader.

Wenn ich den für z.b. Gras nehme dann sieht das so gesliced also zerschnitten aus, wenn ich den Cutoff Wert erhöhe.

Shader "Custom/Shader" {
	Properties {
		_Color("Color", Color) = (1,1,1,1)
		_MyArr("Texure", 2DArray) = "" {}
		_Glossiness ("Smoothness", Range(0,1)) = 0.5

		_MetallicMap("Metallic", 2D) = "white" {}
		[Gamma] _Metallic ("Metallic", Range(0,1)) = 0.0

		_BumpMap("Normals", 2D) = "bump" {}
		_BumpScale("Bump Scale", Float) = 1

		_ParallaxMap("Parallax", 2D) = "black" {}
		_ParallaxStrength("Parallax Strength", Range(0, 0.1)) = 0

		_OcclusionMap("Occlusion", 2D) = "white" {}
		_OcclusionStrength("Occlusion Strength", Range(0, 1)) = 1

		_EmissionMap("Emission", 2D) = "black" {}
		_Emission("Emission", Color) = (0, 0, 0)

		_Cutoff("Alpha Cutoff", Range(0, 1)) = 0.5
	}
		
		SubShader{
				Tags{ "RenderType" = "TransparentCutout" }
				LOD 200

				CGPROGRAM
				#pragma target 3.5

				#pragma surface surf Standard fullforwardshadows addshadow
				UNITY_DECLARE_TEX2DARRAY(_MyArr);

				struct Input {
					float2 uv_MyArr;
					float2 uv_BumpMap;
				};

				UNITY_INSTANCING_BUFFER_START(Props)
					UNITY_DEFINE_INSTANCED_PROP(fixed4, _Color)
						#define _Color_arr Props
					UNITY_DEFINE_INSTANCED_PROP(float, _TextureIndex)
						#define _TextureIndex_arr Props
					UNITY_DEFINE_INSTANCED_PROP(half, _Glossiness)
						#define _Glossiness_arr Props
					UNITY_DEFINE_INSTANCED_PROP(half, _Metallic)
						#define _Metallic_arr Props
					UNITY_DEFINE_INSTANCED_PROP(float, _BumpScale)
						#define _BumpScale_arr Props
					UNITY_DEFINE_INSTANCED_PROP(half, _Cutoff)
						#define _Cutoff_arr Props
				UNITY_INSTANCING_BUFFER_END(Props)

				sampler2D _BumpMap;
				sampler2D _MetallicMap;
				sampler2D _OcclusionMap;
				half _OcclusionStrength;

				void surf(Input IN, inout SurfaceOutputStandard o) {
					fixed4 c = UNITY_SAMPLE_TEX2DARRAY(_MyArr, float3(IN.uv_MyArr, UNITY_ACCESS_INSTANCED_PROP(_TextureIndex_arr, _TextureIndex))) * UNITY_ACCESS_INSTANCED_PROP(_Color_arr, _Color);
					o.Albedo = c.rgb;

					fixed4 metal = tex2D(_MetallicMap, IN.uv_MyArr);

					o.Metallic = metal.r * UNITY_ACCESS_INSTANCED_PROP(_Metallic_arr, _Metallic);
					o.Smoothness = metal.a * UNITY_ACCESS_INSTANCED_PROP(_Glossiness_arr, _Glossiness);
					o.Alpha = c.a * UNITY_ACCESS_INSTANCED_PROP(_Color_arr, _Color).a;
					clip(o.Alpha - UNITY_ACCESS_INSTANCED_PROP(_Cutoff_arr, _Cutoff));

					o.Occlusion = tex2D(_OcclusionMap, IN.uv_MyArr) * _OcclusionStrength;

					o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap)) * UNITY_ACCESS_INSTANCED_PROP(_BumpScale_arr, _BumpScale);
				}

				ENDCG
		}
}

Mfg Mustaf

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×