reformat shader with Rider's improved formatting

this formatting and intellisense was not available when the Shader was originally developed
This commit is contained in:
Xevion
2020-11-09 10:18:39 -06:00
parent 6085dbf705
commit bca7e1f33f
2 changed files with 103 additions and 89 deletions

View File

@@ -63,7 +63,7 @@ Material:
- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1
- _GridSize: 31
- _GridSize: 32
- _LineSize: 0.05
- _Metallic: 0
- _Mode: 0

View File

@@ -1,106 +1,120 @@
// Upgrade NOTE: upgraded instancing buffer 'Props' to new syntax.
Shader "PDT Shaders/TestGrid" {
Properties {
_LineColor ("Line Color", Color) = (1,1,1,1)
_InactiveColor ("Inactive Color", Color) = (0,0,0,0)
_ActiveColor ("Active Color", Color) = (1,0,0,1)
[PerRendererData] _MainTex ("Albedo (RGB)", 2D) = "white" {}
[IntRange] _GridSize("Grid Size", Range(1,100)) = 10
_LineSize("Line Size", Range(0,1)) = 0.15
}
SubShader {
Tags { "Queue"="AlphaTest" "RenderType"="TransparentCutout" }
LOD 200
Shader "PDT Shaders/TestGrid"
{
Properties
{
_LineColor ("Line Color", Color) = (1,1,1,1)
_InactiveColor ("Inactive Color", Color) = (0,0,0,0)
_ActiveColor ("Active Color", Color) = (1,0,0,1)
[PerRendererData] _MainTex ("Albedo (RGB)", 2D) = "white" {}
[IntRange] _GridSize("Grid Size", Range(1,100)) = 10
_LineSize("Line Size", Range(0,1)) = 0.15
}
SubShader
{
Tags
{
"Queue"="AlphaTest" "RenderType"="TransparentCutout"
}
LOD 200
CGPROGRAM
// Physically based Standard lighting model, and enable shadows on all light types
#pragma surface surf Standard fullforwardshadows
#pragma target 5.0
sampler2D _MainTex;
CGPROGRAM
// Physically based Standard lighting model, and enable shadows on all light types
#pragma surface surf Standard fullforwardshadows
#pragma target 5.0
struct Input {
float2 uv_MainTex;
};
sampler2D _MainTex;
half _Glossiness = 0.0;
half _Metallic = 0.0;
float4 _LineColor;
float4 _InactiveColor;
float4 _ActiveColor;
static const float4 _gridColors[7] = {
float4(255 / 255.0, 255 / 255.0, 255 / 255.0, 1.0), // Empty
float4(0 / 255.0, 0 / 255.0, 0 / 255.0, 1.0), // Wall
float4(0 / 255.0, 255 / 255.0, 0 / 255.0, 1.0), // Start
float4(255 / 255.0, 0 / 255.0, 0 / 255.0, 1.0), // End
float4(252 / 255.0, 236 / 255.0, 3 / 255.0, 1.0), // Seen
float4(227 / 255.0, 65 / 255.0, 11 / 255.0, 1.0), // Expanded
float4(166 / 255.0, 2 / 255.0, 51 / 255.0, 1.0) // Path
struct Input
{
float2 uv_MainTex;
};
float _GridSize;
float _LineSize;
half _Glossiness = 0.0;
half _Metallic = 0.0;
float4 _LineColor;
float4 _InactiveColor;
float4 _ActiveColor;
static const float4 _gridColors[7] = {
float4(255 / 255.0, 255 / 255.0, 255 / 255.0, 1.0), // Empty
float4(0 / 255.0, 0 / 255.0, 0 / 255.0, 1.0), // Wall
float4(0 / 255.0, 255 / 255.0, 0 / 255.0, 1.0), // Start
float4(255 / 255.0, 0 / 255.0, 0 / 255.0, 1.0), // End
float4(252 / 255.0, 236 / 255.0, 3 / 255.0, 1.0), // Seen
float4(227 / 255.0, 65 / 255.0, 11 / 255.0, 1.0), // Expanded
float4(166 / 255.0, 2 / 255.0, 51 / 255.0, 1.0) // Path
};
float _GridSize;
float _LineSize;
// DX11 needed to run shader at high grid sizes
#ifdef SHADER_API_D3D11
StructuredBuffer<int> _values;
#else
#ifdef SHADER_API_D3D11
StructuredBuffer<int> _values;
#else
float _values[1024];
#endif
float _valueLength;
#endif
float _valueLength;
// Add instancing support for this shader. You need to check 'Enable Instancing' on materials that use the shader.
// See https://docs.unity3d.com/Manual/GPUInstancing.html for more information about instancing.
// #pragma instancing_options assumeuniformscaling
UNITY_INSTANCING_BUFFER_START(Props)
// put more per-instance properties here
UNITY_INSTANCING_BUFFER_END(Props)
void surf (Input IN, inout SurfaceOutputStandard o) {
// Albedo comes from a texture tinted by color
// Add instancing support for this shader. You need to check 'Enable Instancing' on materials that use the shader.
// See https://docs.unity3d.com/Manual/GPUInstancing.html for more information about instancing.
// #pragma instancing_options assumeuniformscaling
UNITY_INSTANCING_BUFFER_START(Props)
// put more per-instance properties here
UNITY_INSTANCING_BUFFER_END(Props)
float2 uv = IN.uv_MainTex;
void surf(Input IN, inout SurfaceOutputStandard o)
{
// Albedo comes from a texture tinted by color
fixed4 c = float4(0.0,0.0,0.0,0.0);
float gsize = floor(_GridSize);
gsize += _LineSize;
float2 uv = IN.uv_MainTex;
float2 id = float2(floor(uv.x/(1.0/gsize)), floor(uv.y/(1.0/gsize)));
fixed4 c = float4(0.0, 0.0, 0.0, 0.0);
float gsize = floor(_GridSize);
gsize += _LineSize;
float2 id = float2(
floor(uv.x / (1.0 / gsize)), floor(uv.y / (1.0 / gsize))
);
float4 color = _InactiveColor;
float brightness = _InactiveColor.w;
float4 color = _InactiveColor;
float brightness = _InactiveColor.w;
// Line Color Check
if (_LineSize > 0.0 && (frac(uv.x*gsize) <= _LineSize || frac(uv.y*gsize) <= _LineSize)){
color = _LineColor;
brightness = color.w;
// Heatmap Value Fallback
} else {
float pos = id.y * _GridSize + id.x;
if(pos < _valueLength) {
float index = _values[pos];
color = _gridColors[index];
// color = lerp(_InactiveColor, _ActiveColor, _values[pos]);
brightness = color.w;
}
}
if (_LineSize > 0.0 && (frac(uv.x * gsize) <= _LineSize || frac(uv.y * gsize) <= _LineSize))
{
color = _LineColor;
brightness = color.w;
// Heatmap Value Fallback
}
else
{
float pos = id.y * _GridSize + id.x;
if (pos < _valueLength)
{
float index = _values[pos];
color = _gridColors[index];
// color = lerp(_InactiveColor, _ActiveColor, _values[pos]);
brightness = color.w;
}
}
// Clip transparent spots using alpha cutout
if (brightness == 0.0)
clip(c.a - 1.0);
o.Albedo = float4(color.x * brightness,color.y * brightness,color.z * brightness, brightness);
// Metallic and smoothness come from slider variables
o.Metallic = 0.0;
o.Smoothness = 0.0;
o.Alpha = 0.0;
}
ENDCG
}
FallBack "Diffuse"
}
// Clip transparent spots using alpha cutout
if (brightness == 0.0)
clip(c.a - 1.0);
o.Albedo = float4(color.x * brightness, color.y * brightness, color.z * brightness, brightness);
// Metallic and smoothness come from slider variables
o.Metallic = 0.0;
o.Smoothness = 0.0;
o.Alpha = 0.0;
}
ENDCG
}
FallBack "Diffuse"
}