Files
CopterSimulator/Unity/Assets/Materials/SegmentDisplay.shader
T
2025-05-13 03:30:23 +03:00

58 lines
1.3 KiB
Plaintext

Shader "Custom/SegmentDisplay" {
Properties {
_Color ("Color", Color) = (1,1,1,1)
_EmissionColor("EmissionColor", Color) = (1,1,1,1)
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_SegmentMask("Segment mask", 2D) = "white" {}
_Glossiness ("Smoothness", Range(0,1)) = 0.5
_Metallic ("Metallic", Range(0,1)) = 0.0
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 200
CGPROGRAM
// Physically based Standard lighting model, and enable shadows on all light types
#pragma surface surf Standard fullforwardshadows
// Use shader model 3.0 target, to get nicer looking lighting
#pragma target 4.0
sampler2D _MainTex;
sampler2D _SegmentMask;
struct Input {
float2 uv_MainTex;
};
half _Glossiness;
half _Metallic;
fixed4 _Color;
float4 _EmissionColor;
int segments;
void surf (Input IN, inout SurfaceOutputStandard o) {
float4 cc = tex2D(_MainTex, IN.uv_MainTex);
float msk = tex2D(_SegmentMask, IN.uv_MainTex).r;
uint id = (uint)(msk * 255.0f) / 20;
//o.Emission = msk;
if ((uint)segments & (1 << (id - 1))) {
o.Emission = _EmissionColor.rgb *cc.r;
}
o.Albedo = cc.r * 0.08f;
// Metallic and smoothness come from slider variables
o.Metallic = _Metallic;
o.Smoothness = _Glossiness;
o.Alpha =1;
}
ENDCG
}
FallBack "Diffuse"
}