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 - _GlossMapScale: 1
- _Glossiness: 0.5 - _Glossiness: 0.5
- _GlossyReflections: 1 - _GlossyReflections: 1
- _GridSize: 31 - _GridSize: 32
- _LineSize: 0.05 - _LineSize: 0.05
- _Metallic: 0 - _Metallic: 0
- _Mode: 0 - _Mode: 0

View File

@@ -1,7 +1,9 @@
// Upgrade NOTE: upgraded instancing buffer 'Props' to new syntax. // Upgrade NOTE: upgraded instancing buffer 'Props' to new syntax.
Shader "PDT Shaders/TestGrid" { Shader "PDT Shaders/TestGrid"
Properties { {
Properties
{
_LineColor ("Line Color", Color) = (1,1,1,1) _LineColor ("Line Color", Color) = (1,1,1,1)
_InactiveColor ("Inactive Color", Color) = (0,0,0,0) _InactiveColor ("Inactive Color", Color) = (0,0,0,0)
_ActiveColor ("Active Color", Color) = (1,0,0,1) _ActiveColor ("Active Color", Color) = (1,0,0,1)
@@ -9,8 +11,12 @@ Shader "PDT Shaders/TestGrid" {
[IntRange] _GridSize("Grid Size", Range(1,100)) = 10 [IntRange] _GridSize("Grid Size", Range(1,100)) = 10
_LineSize("Line Size", Range(0,1)) = 0.15 _LineSize("Line Size", Range(0,1)) = 0.15
} }
SubShader { SubShader
Tags { "Queue"="AlphaTest" "RenderType"="TransparentCutout" } {
Tags
{
"Queue"="AlphaTest" "RenderType"="TransparentCutout"
}
LOD 200 LOD 200
@@ -21,7 +27,8 @@ Shader "PDT Shaders/TestGrid" {
sampler2D _MainTex; sampler2D _MainTex;
struct Input { struct Input
{
float2 uv_MainTex; float2 uv_MainTex;
}; };
@@ -61,7 +68,8 @@ Shader "PDT Shaders/TestGrid" {
// put more per-instance properties here // put more per-instance properties here
UNITY_INSTANCING_BUFFER_END(Props) UNITY_INSTANCING_BUFFER_END(Props)
void surf (Input IN, inout SurfaceOutputStandard o) { void surf(Input IN, inout SurfaceOutputStandard o)
{
// Albedo comes from a texture tinted by color // Albedo comes from a texture tinted by color
float2 uv = IN.uv_MainTex; float2 uv = IN.uv_MainTex;
@@ -70,19 +78,25 @@ Shader "PDT Shaders/TestGrid" {
float gsize = floor(_GridSize); float gsize = floor(_GridSize);
gsize += _LineSize; gsize += _LineSize;
float2 id = float2(floor(uv.x/(1.0/gsize)), floor(uv.y/(1.0/gsize))); float2 id = float2(
floor(uv.x / (1.0 / gsize)), floor(uv.y / (1.0 / gsize))
);
float4 color = _InactiveColor; float4 color = _InactiveColor;
float brightness = _InactiveColor.w; float brightness = _InactiveColor.w;
// Line Color Check // Line Color Check
if (_LineSize > 0.0 && (frac(uv.x*gsize) <= _LineSize || frac(uv.y*gsize) <= _LineSize)){ if (_LineSize > 0.0 && (frac(uv.x * gsize) <= _LineSize || frac(uv.y * gsize) <= _LineSize))
{
color = _LineColor; color = _LineColor;
brightness = color.w; brightness = color.w;
// Heatmap Value Fallback // Heatmap Value Fallback
} else { }
else
{
float pos = id.y * _GridSize + id.x; float pos = id.y * _GridSize + id.x;
if(pos < _valueLength) { if (pos < _valueLength)
{
float index = _values[pos]; float index = _values[pos];
color = _gridColors[index]; color = _gridColors[index];
// color = lerp(_InactiveColor, _ActiveColor, _values[pos]); // color = lerp(_InactiveColor, _ActiveColor, _values[pos]);