add vertex floatiness uwu

This commit is contained in:
Cat Flynn 2021-04-25 00:59:37 +01:00
parent b91e97984f
commit b192263344
12 changed files with 6869 additions and 119 deletions

View File

@ -31,11 +31,11 @@ MonoBehaviour:
m_AdvancedMode: 0 m_AdvancedMode: 0
threshold: threshold:
m_OverrideState: 1 m_OverrideState: 1
m_Value: 0.85 m_Value: 1.09
min: 0 min: 0
intensity: intensity:
m_OverrideState: 1 m_OverrideState: 1
m_Value: 2 m_Value: 2.93
min: 0 min: 0
scatter: scatter:
m_OverrideState: 0 m_OverrideState: 0

View File

@ -117,7 +117,7 @@ Material:
- _QueueOffset: 0 - _QueueOffset: 0
- _RadiusWithDistance: 0.003 - _RadiusWithDistance: 0.003
- _ReceiveShadows: 1 - _ReceiveShadows: 1
- _Sample: 0.05 - _Sample: 0.9
- _Smoothness: 0.5 - _Smoothness: 0.5
- _SmoothnessTextureChannel: 0 - _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1 - _SpecularHighlights: 1

View File

@ -11,7 +11,7 @@ Material:
m_Shader: {fileID: 4800000, guid: 91517451bf5416c44a73fd65d42c122a, type: 3} m_Shader: {fileID: 4800000, guid: 91517451bf5416c44a73fd65d42c122a, type: 3}
m_ShaderKeywords: m_ShaderKeywords:
m_LightmapFlags: 4 m_LightmapFlags: 4
m_EnableInstancingVariants: 0 m_EnableInstancingVariants: 1
m_DoubleSidedGI: 0 m_DoubleSidedGI: 0
m_CustomRenderQueue: 2000 m_CustomRenderQueue: 2000
stringTagMap: {} stringTagMap: {}
@ -21,7 +21,7 @@ Material:
m_TexEnvs: m_TexEnvs:
- _BaseMap: - _BaseMap:
m_Texture: {fileID: 2800000, guid: 9790e688a544b39469364dfdde573e23, type: 3} m_Texture: {fileID: 2800000, guid: 9790e688a544b39469364dfdde573e23, type: 3}
m_Scale: {x: 0.2, y: 0.2} m_Scale: {x: 0.1, y: 0.05}
m_Offset: {x: 0, y: 0} m_Offset: {x: 0, y: 0}
- _BumpMap: - _BumpMap:
m_Texture: {fileID: 0} m_Texture: {fileID: 0}
@ -111,13 +111,14 @@ Material:
- _Cutoff: 0.5 - _Cutoff: 0.5
- _DetailAlbedoMapScale: 1 - _DetailAlbedoMapScale: 1
- _DetailNormalMapScale: 1 - _DetailNormalMapScale: 1
- _Distortion: 0 - _Distortion: 4.41
- _DstBlend: 0 - _DstBlend: 0
- _EnvironmentReflections: 1 - _EnvironmentReflections: 1
- _GlossMapScale: 0 - _GlossMapScale: 0
- _Glossiness: 0 - _Glossiness: 0
- _GlossyReflections: 0 - _GlossyReflections: 0
- _HorizontalScale: 0.1 - _HorizontalScale: 0.1
- _Intensity: 1.19
- _M: 0.5 - _M: 0.5
- _Metallic: 0 - _Metallic: 0
- _OcclusionStrength: 1 - _OcclusionStrength: 1
@ -133,17 +134,20 @@ Material:
- _SrcBlend: 1 - _SrcBlend: 1
- _Surface: 0 - _Surface: 0
- _TrackWidth: 20 - _TrackWidth: 20
- _TrailScatter: 0.1
- _VertShake: 0.05
- _VerticalScale: 10 - _VerticalScale: 10
- _WorkflowMode: 1 - _WorkflowMode: 1
- _ZWrite: 1 - _ZWrite: 1
m_Colors: m_Colors:
- _BaseColor: {r: 0.8603976, g: 0.8603976, b: 0.8603976, a: 1} - _BaseColor: {r: 1.0592737, g: 0.7930688, b: 0.58786917, a: 1}
- _Color: {r: 1, g: 1, b: 1, a: 1} - _Color: {r: 1, g: 1, b: 1, a: 1}
- _Color1: {r: 1, g: 1, b: 1, a: 1} - _Color1: {r: 1, g: 1, b: 1, a: 1}
- _Color2: {r: 1, g: 1, b: 1, a: 1} - _Color2: {r: 1, g: 1, b: 1, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1} - _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _FarColor: {r: 1, g: 1, b: 1, a: 1} - _FarColor: {r: 1, g: 1, b: 1, a: 1}
- _NoiseColor: {r: 0, g: 0.52963686, b: 0.45476672, a: 1} - _GlitchColor: {r: 0.6901961, g: 0, b: 0, a: 1}
- _NoiseColor: {r: 0.25653195, g: 0.28690022, b: 1.2647622, a: 1}
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1} - _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
m_BuildTextureStacks: [] m_BuildTextureStacks: []
--- !u!114 &3508380654290378483 --- !u!114 &3508380654290378483

File diff suppressed because it is too large Load Diff

View File

@ -1,3 +1,4 @@
using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
@ -36,11 +37,11 @@ public class BlendPass : ScriptableRenderPass
// set properties on material // set properties on material
var blend = Settings.blendMat; var blend = Settings.blendMat;
blend.SetFloat("_Sample", Settings.sample * Time.deltaTime); blend.SetFloat("_Sample", Settings.sample);
blend.SetFloat("_DeltaTime", Time.deltaTime); // blend.SetFloat("_DeltaTime", Time.deltaTime);
blend.SetTexture("_GlitchTex", Settings.glitchTex); // blend.SetTexture("_GlitchTex", Settings.glitchTex);
blend.SetTexture("_BlendTex", Settings.blendTex); // blend.SetTexture("_BlendTex", Settings.blendTex);
cmd.Blit(_src,_dest,blend); cmd.Blit(_src,_dest,blend);

View File

@ -34,6 +34,8 @@ public class GlitchFeature : ScriptableRendererFeature
public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData) public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData)
{ {
// var cmd = CommandBufferPool.Get();
_blendPass.renderPassEvent = RenderPassEvent.BeforeRenderingPostProcessing; _blendPass.renderPassEvent = RenderPassEvent.BeforeRenderingPostProcessing;
_blendPass.Settings = _settings; _blendPass.Settings = _settings;
renderer.EnqueuePass(_blendPass); renderer.EnqueuePass(_blendPass);

View File

@ -0,0 +1,23 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Random = UnityEngine.Random;
public class GlitchInit : MonoBehaviour
{
private Renderer[] _glitchRenderers;
private void OnEnable()
{
_glitchRenderers = GetComponentsInChildren<Renderer>();
foreach (var glitchRenderer in _glitchRenderers)
{
var mpb = new MaterialPropertyBlock();
mpb.SetVector(
"_Positions",
new Vector4(Random.value,Random.value,Random.value,Random.value));
glitchRenderer.SetPropertyBlock(mpb);
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c3ce05717d7828b418026c43e7583aac
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -61,5 +61,5 @@ MonoBehaviour:
blendTex: {fileID: 8400000, guid: 36a2435496603f54cb0ed075dccd1146, type: 2} blendTex: {fileID: 8400000, guid: 36a2435496603f54cb0ed075dccd1146, type: 2}
blendMat: {fileID: 2100000, guid: da580221ba039484c9583941b62b78c5, type: 2} blendMat: {fileID: 2100000, guid: da580221ba039484c9583941b62b78c5, type: 2}
fadeMat: {fileID: 2100000, guid: eaee005f02a8524439f9f42ab8dc0001, type: 2} fadeMat: {fileID: 2100000, guid: eaee005f02a8524439f9f42ab8dc0001, type: 2}
sample: 0.5 sample: 0.9
fadeStrength: 1 fadeStrength: 1

View File

@ -2,10 +2,7 @@ Shader "KernelPanic/add"
{ {
Properties Properties
{ {
// _NoiseTex ("Noise Tex", 2D) = "black" [HideInInspector] _MainTex ("Base (RGB)", 2D) = "white" {}
// [HideInInspector]_MainTex ("Base (RGB)", 2D) = "white" {}
// _GlitchTex ("Glitch Tex", 2D) = "black"
// [Range(0,1)] _Sample ("Sample", Float) = 0.5
} }
SubShader SubShader
{ {
@ -48,26 +45,25 @@ Shader "KernelPanic/add"
// SAMPLER(sampler_MainTex); // SAMPLER(sampler_MainTex);
// SAMPLER(sampler_NoiseMap); // SAMPLER(sampler_NoiseMap);
sampler2D _BlendTex;
sampler2D _GlitchTex;
sampler2D _MainTex; sampler2D _MainTex;
// sampler2D _GlitchTex;
float _Sample; float _Sample;
float _DeltaTime;
fixed4 frag (v2f i) : SV_Target fixed4 frag (v2f i) : SV_Target
{ {
// sample raw glitch // sample raw glitch
float4 g = float4(tex2D(_GlitchTex, i.uv).rgb, _Sample);
// float a = length(g.xyz)/length(float3(1,1,1)); float4 c = float4(tex2D(_MainTex, i.uv).rgb, _Sample);
// g.a = lerp(a, 0, _Sample);
// float4 g = float4(tex2D(_GlitchTex, i.uv).rgb, _Sample); // float4 c = tex2D(_MainTex, i.uv);
// float4 b = float4(tex2D(_BlendTex, i.uv).rgb, _Sample); // c.a = _Sample;
return g; // float4 g = tex2D(_GlitchTex, i.uv);
// return lerp(c,g,_Sample);
return c;
} }
ENDCG ENDCG
} }

View File

@ -7,19 +7,22 @@ Shader "KernelPanic/glitch"
{ {
[HDR] _BaseColor("Base Color", Color) = (1,1,1,1) [HDR] _BaseColor("Base Color", Color) = (1,1,1,1)
[HDR] _NoiseColor("Noise Color", Color) = (1,1,1,1) [HDR] _NoiseColor("Noise Color", Color) = (1,1,1,1)
[HDR] _GlitchColor("Glitch Color", Color) = (1,1,1,1)
_BaseMap("Base Map", 2D) = "white" _BaseMap("Base Map", 2D) = "white"
_NoiseMap1("Noise 1", 2D) = "black" _NoiseMap1("Noise 1", 2D) = "black"
_NoiseMap2("Noise 2", 2D) = "black"
_NoiseMap3("Noise 3", 2D) = "black"
_GlitchTex("Glitch Tex", 2D) = "black" _GlitchTex("Glitch Tex", 2D) = "black"
_Distortion("Distortion", Float) = 0 [Range(0,1)] _Distortion("Distortion", Float) = 0
_Intensity("Intensity", Float) = 1
_TrailScatter("Trail Scatter", Float) = 0.02
_VertShake("Vertex Shake", Float) = 0.05
} }
SubShader SubShader
{ {
Tags { Tags
{
"RenderType" = "Opaque" "RenderType" = "Opaque"
"Queue" = "Geometry" "Queue" = "Geometry"
"RenderPipeline" = "UniversalRenderPipeline" "RenderPipeline" = "UniversalRenderPipeline"
@ -27,16 +30,10 @@ Shader "KernelPanic/glitch"
Pass Pass
{ {
// Stencil
// {
// Ref 1
// Pass replace
// Fail replace
// ZFail replace
// }
Cull Off Cull Off
Zwrite On Zwrite On
// ZTest LEqual ZTest LEqual
Blend SrcAlpha OneMinusSrcAlpha Blend SrcAlpha OneMinusSrcAlpha
HLSLPROGRAM HLSLPROGRAM
@ -51,93 +48,139 @@ Shader "KernelPanic/glitch"
struct Attributes struct Attributes
{ {
float4 positionOS : POSITION; float4 positionOS : POSITION;
// The uv variable contains the UV coordinate on the texture for the // The uv variable contains the UV coordinate on the texture for the
// given vertex. // given vertex.
float2 uv : TEXCOORD0; float2 uv : TEXCOORD0;
half3 normal : NORMAL; half3 normal : NORMAL;
}; };
struct Varyings struct Varyings
{ {
float4 positionHCS : SV_POSITION; float4 positionHCS : SV_POSITION;
// The uv variable contains the UV coordinate on the texture for the // The uv variable contains the UV coordinate on the texture for the
// given vertex. // given vertex.
float2 uv : TEXCOORD0; float2 uv : TEXCOORD0;
half3 normal : NORMAL; half3 normal : NORMAL;
float4 screenPos : TEXCOORD1; float4 screenPos : TEXCOORD1;
}; };
float _Distortion; float _Distortion;
float _Intensity;
float _TrailScatter;
float _VertShake;
float4 _NoiseColor; float4 _NoiseColor;
float4 _BaseColor; float4 _BaseColor;
float4 _GlitchColor;
// This macro declares _BaseMap as a Texture2D object. // This macro declares _BaseMap as a Texture2D object.
TEXTURE2D(_BaseMap); TEXTURE2D(_BaseMap);
TEXTURE2D(_NoiseMap1); TEXTURE2D(_NoiseMap1);
TEXTURE2D(_NoiseMap2);
TEXTURE2D(_NoiseMap3);
TEXTURE2D(_GlitchTex); TEXTURE2D(_GlitchTex);
TEXTURE2D(_CameraDepthTexture); TEXTURE2D(_CameraDepthTexture);
// This macro declares the sampler for the _BaseMap texture. // This macro declares the sampler for the _BaseMap texture.
SAMPLER(sampler_BaseMap); SAMPLER(sampler_BaseMap);
SAMPLER(sampler_NoiseMap1); SAMPLER(sampler_NoiseMap1);
SAMPLER(sampler_NoiseMap2);
SAMPLER(sampler_NoiseMap3);
SAMPLER(sampler_GlitchTex); SAMPLER(sampler_GlitchTex);
SAMPLER(sampler_CameraDepthTexture); SAMPLER(sampler_CameraDepthTexture);
CBUFFER_START(UnityPerMaterial) CBUFFER_START(UnityPerMaterial)
// The following line declares the _BaseMap_ST variable, so that you // The following line declares the _BaseMap_ST variable, so that you
// can use the _BaseMap variable in the fragment shader. The _ST // can use the _BaseMap variable in the fragment shader. The _ST
// suffix is necessary for the tiling and offset function to work. // suffix is necessary for the tiling and offset function to work.
float4 _BaseMap_ST; float4 _BaseMap_ST;
float4 _NoiseMap_ST; float4 _NoiseMap_ST;
CBUFFER_END CBUFFER_END
UNITY_INSTANCING_BUFFER_START(Props)
UNITY_DEFINE_INSTANCED_PROP(float4, _Positions)
UNITY_INSTANCING_BUFFER_END(Props)
Varyings vert(Attributes IN) Varyings vert(Attributes IN)
{ {
Varyings OUT; Varyings OUT;
OUT.normal = TransformObjectToWorldDir(IN.normal); OUT.normal = TransformObjectToWorldDir(IN.normal);
// OUT.normal = IN.normal; // OUT.normal = IN.normal;
OUT.positionHCS = TransformObjectToHClip(IN.positionOS);
float4 poscs = TransformObjectToHClip(IN.positionOS);
float4 n = SAMPLE_TEXTURE2D_LOD(_NoiseMap1, sampler_NoiseMap1, hash42(poscs), 0);
float3 pos = IN.positionOS + (n-0.5) * _VertShake;
float4 p = UNITY_ACCESS_INSTANCED_PROP(Props, _Positions);
float t = sin(p.y*_Time.w + p.x*6.28);
float3 wpos = TransformObjectToWorld(pos);
wpos += float3(0,t*p.z*0.1,0);
pos = TransformWorldToObject(wpos);
OUT.positionHCS = TransformObjectToHClip(pos);
// The TRANSFORM_TEX macro performs the tiling and offset // The TRANSFORM_TEX macro performs the tiling and offset
// transformation. // transformation.
OUT.uv = TRANSFORM_TEX(IN.uv, _BaseMap); OUT.uv = TRANSFORM_TEX(IN.uv, _BaseMap);
OUT.screenPos = ComputeScreenPos(OUT.positionHCS); OUT.screenPos = ComputeScreenPos(OUT.positionHCS);
return OUT; return OUT;
} }
half4 frag(Varyings IN) : SV_Target half4 frag(Varyings IN) : SV_Target
{ {
float2 suv = IN.screenPos.xy / IN.screenPos.w;
float2 suv = IN.screenPos.xy/IN.screenPos.w;
float d = SAMPLE_TEXTURE2D(_CameraDepthTexture, sampler_CameraDepthTexture, suv); float d = SAMPLE_TEXTURE2D(_CameraDepthTexture, sampler_CameraDepthTexture, suv);
float4 p = float4(.42069, .6969, .1337, .8008);
float t = sin(_Time.y)*0.5+0.5;
float2 nuv = lerp(p.xz, p.yw, t);
float4 n = SAMPLE_TEXTURE2D(_NoiseMap1, sampler_NoiseMap1, suv + float2(_Time.y*69.6969, _Time.y*23.513)); // float4 p = float4(.42069, .6969, .1337, .8008135);
float4 p = UNITY_ACCESS_INSTANCED_PROP(Props, _Positions);
float t = (p.x*sin(_Time.y)+p.w*cos(_Time.x)) * 0.5 + 0.5;
// sample regular color
float4 c = SAMPLE_TEXTURE2D(_BaseMap, sampler_BaseMap, (IN.uv +lerp(p.xy,p.zw,0.2+0.6*t))*0.5);
// c = lerp(c, _BaseColor, 0.5);
float4 n = SAMPLE_TEXTURE2D(_NoiseMap1, sampler_NoiseMap1, (IN.uv +lerp(p.xy,p.zw,0.9-30*t))*19);
n *= _NoiseColor; n *= _NoiseColor;
// sample color // sample blended glitch
float4 c = SAMPLE_TEXTURE2D(_BaseMap, sampler_BaseMap, nuv); float4 g = SAMPLE_TEXTURE2D(_GlitchTex, sampler_GlitchTex,
suv + _TrailScatter*n*hash42(IN.uv));
g *= _GlitchColor;
// g = 1 - g;
// sample color distorted by noise
float distortion = _Distortion + (t-0.5) * _Intensity;
float4 cd = SAMPLE_TEXTURE2D(_BaseMap, sampler_BaseMap, IN.uv + n * distortion * t);
// float4 cn = SAMPLE_TEXTURE2D(_BaseMap, sampler_BaseMap, IN.uv + nuv * _GlitchColor);
// c *= _BaseColor; // c *= _BaseColor;
// sample blended glitch // cn = lerp(cn,(1-cn),_Distortion);
float4 b = SAMPLE_TEXTURE2D(_GlitchTex, sampler_GlitchTex, suv); // cn += n;
c = lerp(c,(1-c),b);
c += n; // float4 color = lerp(c, cn, n);
// cheeky bit of top shading // cheeky bit of top shading
c += dot(float3(0,1,0), IN.normal) * d; float un = dot(float3(0,1,0), IN.normal); // dot of up and normal
c = lerp(c,_BaseColor,un*d);
// color += (1-abs(un)) *_BaseColor;
return c *= _BaseColor; c = lerp(c, cd, g);
c = min(c, float4(1, 1, 1, 1));
c += n;
// c = lerp(n,c,0.5);
// c = lerp(c, _BaseColor, _BaseColor.a);
return c;
} }
ENDHLSL ENDHLSL
} }

View File

@ -19,7 +19,7 @@ RenderTexture:
m_AntiAliasing: 1 m_AntiAliasing: 1
m_MipCount: -1 m_MipCount: -1
m_DepthFormat: 0 m_DepthFormat: 0
m_ColorFormat: 52 m_ColorFormat: 48
m_MipMap: 0 m_MipMap: 0
m_GenerateMips: 1 m_GenerateMips: 1
m_SRGB: 0 m_SRGB: 0