mirror of
https://github.com/maxartz15/SceneDebugViewer.git
synced 2025-06-16 23:46:09 +02:00
Added Presets.
Reworked shaders and added more presets.
This commit is contained in:
30
Runtime/Shaders/Lit.shader
Normal file
30
Runtime/Shaders/Lit.shader
Normal file
@ -0,0 +1,30 @@
|
||||
Shader "Hidden/RS/Lit"
|
||||
{
|
||||
SubShader
|
||||
{
|
||||
Tags { "RenderType"="Opaque" }
|
||||
LOD 200
|
||||
|
||||
CGPROGRAM
|
||||
#pragma surface surf Standard fullforwardshadows
|
||||
#pragma target 3.0
|
||||
|
||||
#include "RSPropertiesCG.cginc"
|
||||
|
||||
struct Input
|
||||
{
|
||||
float2 uv_MainTex;
|
||||
};
|
||||
|
||||
void surf (Input IN, inout SurfaceOutputStandard o)
|
||||
{
|
||||
fixed4 c = tex2D(_RS_Texture, IN.uv_MainTex) * _RS_Color;
|
||||
o.Albedo = c.rgb;
|
||||
o.Metallic = _RS_Metallic;
|
||||
o.Smoothness = _RS_Glossiness;
|
||||
o.Alpha = c.a;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
FallBack "Diffuse"
|
||||
}
|
10
Runtime/Shaders/Lit.shader.meta
Normal file
10
Runtime/Shaders/Lit.shader.meta
Normal file
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fa8b3bbeb520d1c47b2ee619fe14e343
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
preprocessorOverride: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
37
Runtime/Shaders/ObjectSpaceNormals.shader
Normal file
37
Runtime/Shaders/ObjectSpaceNormals.shader
Normal file
@ -0,0 +1,37 @@
|
||||
Shader "Hidden/RS/ObjectSpaceNormals"
|
||||
{
|
||||
SubShader
|
||||
{
|
||||
Pass
|
||||
{
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
struct v2f
|
||||
{
|
||||
half3 normal : TEXCOORD0;
|
||||
float4 pos : SV_POSITION;
|
||||
};
|
||||
|
||||
v2f vert(float4 vertex : POSITION, float3 normal : NORMAL)
|
||||
{
|
||||
v2f o;
|
||||
o.pos = UnityObjectToClipPos(vertex);
|
||||
o.normal = normal;
|
||||
return o;
|
||||
}
|
||||
|
||||
fixed4 frag(v2f i) : SV_Target
|
||||
{
|
||||
fixed4 c = 0;
|
||||
c.a = 1;
|
||||
c.rgb = i.normal * 0.5 + 0.5;
|
||||
return c;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
10
Runtime/Shaders/ObjectSpaceNormals.shader.meta
Normal file
10
Runtime/Shaders/ObjectSpaceNormals.shader.meta
Normal file
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7f376fdcb4cabb94fa00a24677019988
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
preprocessorOverride: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -1,4 +1,4 @@
|
||||
Shader "Hidden/Overdraw"
|
||||
Shader "Hidden/RS/Overdraw"
|
||||
{
|
||||
SubShader
|
||||
{
|
||||
@ -19,6 +19,8 @@ Shader "Hidden/Overdraw"
|
||||
#pragma fragment frag
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
#include "RSPropertiesCG.cginc"
|
||||
#include "RSUtilsCG.cginc"
|
||||
|
||||
struct appdata
|
||||
{
|
||||
@ -37,8 +39,6 @@ Shader "Hidden/Overdraw"
|
||||
return o;
|
||||
}
|
||||
|
||||
fixed4 _RS_Color;
|
||||
|
||||
fixed4 frag (v2f i) : SV_Target
|
||||
{
|
||||
return _RS_Color;
|
||||
|
11
Runtime/Shaders/RSPropertiesCG.cginc
Normal file
11
Runtime/Shaders/RSPropertiesCG.cginc
Normal file
@ -0,0 +1,11 @@
|
||||
#ifndef RS_PROPERTIES_CG_INCLUDED
|
||||
#define RS_PROPERTIES_CG_INCLUDED
|
||||
|
||||
sampler2D _RS_Texture;
|
||||
float4 _RS_Texture_ST;
|
||||
float _RS_Sharpness;
|
||||
fixed4 _RS_Color;
|
||||
half _RS_Metallic;
|
||||
half _RS_Glossiness;
|
||||
|
||||
#endif
|
10
Runtime/Shaders/RSPropertiesCG.cginc.meta
Normal file
10
Runtime/Shaders/RSPropertiesCG.cginc.meta
Normal file
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 932b73fee7600724b8740711c79dc3fc
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
preprocessorOverride: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
37
Runtime/Shaders/RSUtilsCG.cginc
Normal file
37
Runtime/Shaders/RSUtilsCG.cginc
Normal file
@ -0,0 +1,37 @@
|
||||
#ifndef RS_UTILS_CG_INCLUDED
|
||||
#define RS_UTILS_CG_INCLUDED
|
||||
|
||||
// https://www.ronja-tutorials.com/post/010-triplanar-mapping/
|
||||
fixed4 SampleTriPlanar(sampler2D tex, float4 tex_ST, float3 position, float3 normal, float sharpness)
|
||||
{
|
||||
//calculate UV coordinates for three projections
|
||||
float2 uv_front = TRANSFORM_TEX(position.xy, tex);
|
||||
float2 uv_side = TRANSFORM_TEX(position.zy, tex);
|
||||
float2 uv_top = TRANSFORM_TEX(position.xz, tex);
|
||||
|
||||
//read texture at uv position of the three projections
|
||||
fixed4 col_front = tex2D(tex, uv_front);
|
||||
fixed4 col_side = tex2D(tex, uv_side);
|
||||
fixed4 col_top = tex2D(tex, uv_top);
|
||||
|
||||
//generate weights from world normals
|
||||
float3 weights = normal;
|
||||
//show texture on both sides of the object (positive and negative)
|
||||
weights = abs(weights);
|
||||
//make the transition sharper
|
||||
weights = pow(weights, sharpness);
|
||||
//make it so the sum of all components is 1
|
||||
weights = weights / (weights.x + weights.y + weights.z);
|
||||
|
||||
//combine weights with projected colors
|
||||
col_front *= weights.z;
|
||||
col_side *= weights.x;
|
||||
col_top *= weights.y;
|
||||
|
||||
//combine the projected colors
|
||||
fixed4 col = col_front + col_side + col_top;
|
||||
|
||||
return col;
|
||||
}
|
||||
|
||||
#endif
|
10
Runtime/Shaders/RSUtilsCG.cginc.meta
Normal file
10
Runtime/Shaders/RSUtilsCG.cginc.meta
Normal file
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6a6a8ee4b7ec5974abb1157bc943d8de
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
preprocessorOverride: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -1,4 +1,4 @@
|
||||
Shader "Hidden/Surface"
|
||||
Shader "Hidden/RS/TriPlanarLit"
|
||||
{
|
||||
SubShader
|
||||
{
|
||||
@ -12,23 +12,24 @@ Shader "Hidden/Surface"
|
||||
// Use shader model 3.0 target, to get nicer looking lighting
|
||||
#pragma target 3.0
|
||||
|
||||
sampler2D _RS_Texture;
|
||||
fixed4 _RS_Color;
|
||||
half _RS_Metallic;
|
||||
half _RS_Glossiness;
|
||||
#include "RSPropertiesCG.cginc"
|
||||
#include "RSUtilsCG.cginc"
|
||||
|
||||
struct Input
|
||||
{
|
||||
float2 uv_RS_Texture;
|
||||
float3 worldPos;
|
||||
float3 worldNormal;
|
||||
};
|
||||
|
||||
void surf (Input IN, inout SurfaceOutputStandard o)
|
||||
{
|
||||
o.Albedo = tex2D(_RS_Texture, IN.uv_RS_Texture) * _RS_Color;
|
||||
fixed4 c = SampleTriPlanar(_RS_Texture, _RS_Texture_ST, IN.worldPos, IN.worldNormal, _RS_Sharpness);
|
||||
|
||||
o.Albedo = c * _RS_Color;
|
||||
o.Metallic = _RS_Metallic;
|
||||
o.Smoothness = _RS_Glossiness;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
FallBack "Diffuse"
|
||||
}
|
||||
}
|
@ -1,79 +0,0 @@
|
||||
// https://www.ronja-tutorials.com/post/010-triplanar-mapping/
|
||||
|
||||
Shader "Hidden/TriPlanarTexture"
|
||||
{
|
||||
SubShader
|
||||
{
|
||||
Tags { "RenderType"="Opaque" }
|
||||
|
||||
Pass
|
||||
{
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
struct appdata
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float3 normal : NORMAL;
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 vertex : SV_POSITION;
|
||||
float3 worldPos : TEXCOORD0;
|
||||
float3 normal : TEXCOORD1;
|
||||
};
|
||||
|
||||
sampler2D _RS_Texture;
|
||||
float4 _RS_Texture_ST;
|
||||
float _RS_Sharpness;
|
||||
|
||||
v2f vert (appdata v)
|
||||
{
|
||||
v2f o;
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
o.worldPos = mul(unity_ObjectToWorld, v.vertex);
|
||||
o.normal = normalize(mul(v.normal, (float3x3)unity_WorldToObject));
|
||||
return o;
|
||||
}
|
||||
|
||||
fixed4 frag (v2f i) : SV_Target
|
||||
{
|
||||
//calculate UV coordinates for three projections
|
||||
float2 uv_front = TRANSFORM_TEX(i.worldPos.xy, _RS_Texture);
|
||||
float2 uv_side = TRANSFORM_TEX(i.worldPos.zy, _RS_Texture);
|
||||
float2 uv_top = TRANSFORM_TEX(i.worldPos.xz, _RS_Texture);
|
||||
|
||||
//read texture at uv position of the three projections
|
||||
fixed4 col_front = tex2D(_RS_Texture, uv_front);
|
||||
fixed4 col_side = tex2D(_RS_Texture, uv_side);
|
||||
fixed4 col_top = tex2D(_RS_Texture, uv_top);
|
||||
|
||||
//generate weights from world normals
|
||||
float3 weights = i.normal;
|
||||
//show texture on both sides of the object (positive and negative)
|
||||
weights = abs(weights);
|
||||
//make the transition sharper
|
||||
weights = pow(weights, _RS_Sharpness);
|
||||
//make it so the sum of all components is 1
|
||||
weights = weights / (weights.x + weights.y + weights.z);
|
||||
|
||||
//combine weights with projected colors
|
||||
col_front *= weights.z;
|
||||
col_side *= weights.x;
|
||||
col_top *= weights.y;
|
||||
|
||||
//combine the projected colors
|
||||
fixed4 col = col_front + col_side + col_top;
|
||||
|
||||
return col;
|
||||
|
||||
// return fixed4(abs(i.normal.xyz), 1);
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
50
Runtime/Shaders/TriPlanarUnlit.shader
Normal file
50
Runtime/Shaders/TriPlanarUnlit.shader
Normal file
@ -0,0 +1,50 @@
|
||||
Shader "Hidden/RS/TriPlanarUnlit"
|
||||
{
|
||||
SubShader
|
||||
{
|
||||
Tags { "RenderType"="Opaque" }
|
||||
|
||||
Pass
|
||||
{
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
#include "RSPropertiesCG.cginc"
|
||||
#include "RSUtilsCG.cginc"
|
||||
|
||||
struct appdata
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float3 normal : NORMAL;
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 vertex : SV_POSITION;
|
||||
float3 worldPos : TEXCOORD0;
|
||||
float3 normal : TEXCOORD1;
|
||||
};
|
||||
|
||||
v2f vert (appdata v)
|
||||
{
|
||||
v2f o;
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
o.worldPos = mul(unity_ObjectToWorld, v.vertex);
|
||||
o.normal = normalize(mul(v.normal, (float3x3)unity_WorldToObject));
|
||||
return o;
|
||||
}
|
||||
|
||||
fixed4 frag(v2f i) : SV_Target
|
||||
{
|
||||
fixed4 c = SampleTriPlanar(_RS_Texture, _RS_Texture_ST, i.worldPos, i.normal, _RS_Sharpness);
|
||||
c *= _RS_Color;
|
||||
return c;
|
||||
|
||||
//return fixed4(abs(i.normal.xyz), 1);
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
45
Runtime/Shaders/Unlit.shader
Normal file
45
Runtime/Shaders/Unlit.shader
Normal file
@ -0,0 +1,45 @@
|
||||
Shader "Hidden/RS/Unlit"
|
||||
{
|
||||
SubShader
|
||||
{
|
||||
Tags { "RenderType"="Opaque" }
|
||||
LOD 100
|
||||
|
||||
Pass
|
||||
{
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
#include "RSPropertiesCG.cginc"
|
||||
|
||||
struct appdata
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 vertex : SV_POSITION;
|
||||
};
|
||||
|
||||
v2f vert (appdata v)
|
||||
{
|
||||
v2f o;
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
o.uv = TRANSFORM_TEX(v.uv, _RS_Texture);
|
||||
return o;
|
||||
}
|
||||
|
||||
fixed4 frag (v2f i) : SV_Target
|
||||
{
|
||||
fixed4 col = tex2D(_RS_Texture, i.uv);
|
||||
return col;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
10
Runtime/Shaders/Unlit.shader.meta
Normal file
10
Runtime/Shaders/Unlit.shader.meta
Normal file
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b7f90ee778e287d4f9bde3252fe9bdd9
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
preprocessorOverride: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
46
Runtime/Shaders/WorldSpaceNormals.shader
Normal file
46
Runtime/Shaders/WorldSpaceNormals.shader
Normal file
@ -0,0 +1,46 @@
|
||||
// https://docs.unity3d.com/Manual/SL-VertexFragmentShaderExamples.html
|
||||
|
||||
Shader "Hidden/RS/WorldSpaceNormals"
|
||||
{
|
||||
SubShader
|
||||
{
|
||||
Pass
|
||||
{
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
// include file that contains UnityObjectToWorldNormal helper function
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
struct v2f
|
||||
{
|
||||
// we'll output world space normal as one of regular ("texcoord") interpolators
|
||||
half3 worldNormal : TEXCOORD0;
|
||||
float4 pos : SV_POSITION;
|
||||
};
|
||||
|
||||
// vertex shader: takes object space normal as input too
|
||||
v2f vert(float4 vertex : POSITION, float3 normal : NORMAL)
|
||||
{
|
||||
v2f o;
|
||||
o.pos = UnityObjectToClipPos(vertex);
|
||||
// UnityCG.cginc file contains function to transform
|
||||
// normal from object to world space, use that
|
||||
o.worldNormal = UnityObjectToWorldNormal(normal);
|
||||
return o;
|
||||
}
|
||||
|
||||
fixed4 frag(v2f i) : SV_Target
|
||||
{
|
||||
fixed4 c = 0;
|
||||
c.a = 1;
|
||||
// normal is a 3D vector with xyz components; in -1..1
|
||||
// range. To display it as color, bring the range into 0..1
|
||||
// and put into red, green, blue components
|
||||
c.rgb = i.worldNormal * 0.5 + 0.5;
|
||||
return c;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
10
Runtime/Shaders/WorldSpaceNormals.shader.meta
Normal file
10
Runtime/Shaders/WorldSpaceNormals.shader.meta
Normal file
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f2163d0d9cb9f8a4fbb6c07dcf8ac7d3
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
preprocessorOverride: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user