This commit is contained in:
Jean Lamarre 2022-10-29 18:32:02 -04:00
parent 9a920baaa7
commit 8aee8663ae
8 changed files with 411 additions and 5 deletions

View File

@ -12,6 +12,4 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 0517c7201b6a73841950436abd2ee35f, type: 3}
m_Name: CustomPostProcessingMaterials
m_EditorClassIdentifier:
customEffect: {fileID: 2100000, guid: a110daba21b580f4898ccf841727c0c2, type: 2}
customEffect2: {fileID: -8761910824519130491, guid: 68b1b3ac4888d5447a2da3fd32249a63,
type: 3}
customEffect: {fileID: 2100000, guid: eee0d494252ff8b49a69d3b8e1b74894, type: 2}

View File

@ -1225,6 +1225,75 @@ CanvasRenderer:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1079852938}
m_CullTransparentMesh: 1
--- !u!1001 &1176655633
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 8571637250638348960, guid: 7febab9e1a84fa449991f0126f4eccbc,
type: 3}
propertyPath: m_RootOrder
value: 4
objectReference: {fileID: 0}
- target: {fileID: 8571637250638348960, guid: 7febab9e1a84fa449991f0126f4eccbc,
type: 3}
propertyPath: m_LocalPosition.x
value: 62.8
objectReference: {fileID: 0}
- target: {fileID: 8571637250638348960, guid: 7febab9e1a84fa449991f0126f4eccbc,
type: 3}
propertyPath: m_LocalPosition.y
value: 2.4
objectReference: {fileID: 0}
- target: {fileID: 8571637250638348960, guid: 7febab9e1a84fa449991f0126f4eccbc,
type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8571637250638348960, guid: 7febab9e1a84fa449991f0126f4eccbc,
type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 8571637250638348960, guid: 7febab9e1a84fa449991f0126f4eccbc,
type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8571637250638348960, guid: 7febab9e1a84fa449991f0126f4eccbc,
type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8571637250638348960, guid: 7febab9e1a84fa449991f0126f4eccbc,
type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8571637250638348960, guid: 7febab9e1a84fa449991f0126f4eccbc,
type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8571637250638348960, guid: 7febab9e1a84fa449991f0126f4eccbc,
type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8571637250638348960, guid: 7febab9e1a84fa449991f0126f4eccbc,
type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8571637250638348962, guid: 7febab9e1a84fa449991f0126f4eccbc,
type: 3}
propertyPath: m_Name
value: SHADER_VOLUME
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 7febab9e1a84fa449991f0126f4eccbc, type: 3}
--- !u!1 &1281004660
GameObject:
m_ObjectHideFlags: 0

View File

@ -16,11 +16,11 @@ namespace Shaders
{
// For example, an intensity parameter that goes from 0 to 1
public ClampedFloatParameter intensity =
new ClampedFloatParameter(value: 1, min: 0, max: 1, overrideState: true);
new ClampedFloatParameter(value: 0, min: 0, max: 1, overrideState: true);
// Other 'Parameter' variables you might have
public bool IsActive() => intensity.value > 0;
public bool IsActive() => intensity.value > 0 && this.active;
// I have no idea what this does yet but I'll update the post once I find an usage
public bool IsTileCompatible() => true;

View File

@ -0,0 +1,150 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &-937696407428621231
MonoBehaviour:
m_ObjectHideFlags: 11
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
m_Name:
m_EditorClassIdentifier:
version: 5
--- !u!21 &2100000
Material:
serializedVersion: 8
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: CRTMaterialShaderFixed
m_Shader: {fileID: 4800000, guid: d4c49b1ac4f8dd44d98d7885681c6d4d, type: 3}
m_ValidKeywords: []
m_InvalidKeywords: []
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BaseMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 0, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _SpecGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- unity_Lightmaps:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- unity_LightmapsInd:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- unity_ShadowMasks:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Ints: []
m_Floats:
- _AlphaClip: 0
- _Blend: 0
- _BumpScale: 1
- _ClearCoatMask: 0
- _ClearCoatSmoothness: 0
- _Cull: 2
- _Cutoff: 0.5
- _DetailAlbedoMapScale: 1
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _EnvironmentReflections: 1
- _GlossMapScale: 0
- _Glossiness: 0
- _GlossyReflections: 0
- _Intensity: 1
- _Metallic: 0
- _OcclusionStrength: 1
- _Parallax: 0.005
- _QueueOffset: 0
- _ReceiveShadows: 1
- _Smoothness: 0.5
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _Surface: 0
- _WorkflowMode: 1
- _ZWrite: 1
- u_bend: 4.84
- u_blue_offset_y: 0.0021
- u_green_offset_y: 0
- u_noise_amount: 0.0154
- u_noise_size: 417
- u_red_offset_y: -0.0021
- u_scanlin_transparence1: 0.005
- u_scanlin_transparence2: 0.005
- u_scanline_amount: 0.178
- u_scanline_size_1: 277
- u_scanline_size_2: 521
- u_scanline_speed_1: 1569.4
- u_scanline_speed_2: 76.6
- u_space_bend: 2
- u_time: 5.1
- u_vignette_edge_round: 6
- u_vignette_size: 1.81
- u_vignette_smoothness: 0.51
m_Colors:
- _BaseColor: {r: 1, g: 1, b: 1, a: 1}
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
- u_blue_offset: {r: 0, g: 0.002, b: 0, a: 0}
- u_blue_offset_y: {r: 0.25, g: 0.5, b: 0.5, a: 0}
- u_green_offset: {r: 0, g: 0, b: 0, a: 0}
- u_green_offset_y: {r: 0.25, g: 0.5, b: 0.5, a: 0}
- u_red_offset: {r: 0, g: -0.002, b: 0, a: 0}
- u_red_offset_y: {r: 0.25, g: 0.5, b: 0.5, a: 0}
m_BuildTextureStacks: []

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: eee0d494252ff8b49a69d3b8e1b74894
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:

View File

@ -131,6 +131,7 @@ Shader "CRTShader"
fixed4 frag(v2f i) : SV_Target
{
u_time = _Time;
half2 crt_uv = crt_coords(i.uv, u_bend);
fixed4 col;
col.r = tex2D(_MainTex, crt_uv + u_color_offset(u_red_offset_y)).r;

View File

@ -0,0 +1,170 @@
Shader "CRTShaderFixed"
{
Properties
{
_MainTex("Texture", 2D) = "Transparent" {}
u_time("Time",float) = 0.5
u_bend("Bend",range(0.5, 10.0)) = 0.5
u_space_bend("Space Bend",range(1.5, 2.5)) = 2.5
u_scanlin_transparence1("Scanline 1 Transparence",range(0, 0.5)) = 0.5
u_scanline_size_1("Scanline Size 1",range(0, 750)) = 0.5
u_scanline_speed_1("Scanline Speed 1",float) = 0.5
u_scanlin_transparence2("Scanline 2 Transparence",range(0, 0.5)) = 0.5
u_scanline_size_2("Scanline Size 2",range(0, 750)) = 0.5
u_scanline_speed_2("Scanline Speed 2",float) = 0.5
u_scanline_amount("Scanline Amount",range(0, 1)) = 0.5
u_vignette_size("Vignette Size",range(0, 10)) = 0.5
u_vignette_smoothness("Vignette Smoothness",range(0, 2)) = 0.5
u_vignette_edge_round("Vignette Edge Round",range(0, 100)) = 0.5
u_noise_size("Noise Size",range(0, 500 )) = 0.5
u_noise_amount("Noise Amount",range(0, 0.15)) = 0.5
u_red_offset_y("Red Offset",range(-0.01,0.01)) = 0
u_green_offset_y("Green Offset",range(-0.01,0.01)) = 0
u_blue_offset_y("Blue Offset",range(-0.01,0.01)) = 0
}
SubShader
{
// No culling or depth
Cull Off ZWrite Off ZTest Always
Tags
{
"RenderType"="Opaque" "RenderPipeline" = "UniversalPipeline"
}
Pass
{
HLSLPROGRAM
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/SurfaceInput.hlsl"
#pragma vertex vert
#pragma fragment frag
TEXTURE2D(_MainTex);
SAMPLER(sampler_MainTex);
float _Intensity;
struct Attributes
{
float4 positionOS : POSITION;
float2 uv : TEXCOORD0;
};
struct Varyings
{
float2 uv : TEXCOORD0;
float4 vertex : SV_POSITION;
UNITY_VERTEX_OUTPUT_STEREO
};
Varyings vert(Attributes input)
{
Varyings output = (Varyings)0;
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
VertexPositionInputs vertexInput = GetVertexPositionInputs(input.positionOS.xyz);
output.vertex = vertexInput.positionCS;
output.uv = input.uv;
return output;
}
uniform float u_time;
uniform float u_bend;
uniform float u_space_bend;
uniform float u_scanlin_transparence1;
uniform float u_scanline_size_1;
uniform float u_scanline_speed_1;
uniform float u_scanlin_transparence2;
uniform float u_scanline_size_2;
uniform float u_scanline_speed_2;
uniform float u_scanline_amount;
uniform float u_vignette_size;
uniform float u_vignette_smoothness;
uniform float u_vignette_edge_round;
uniform float u_noise_size;
uniform float u_noise_amount;
uniform float u_red_offset_y;
uniform float u_green_offset_y;
uniform float u_blue_offset_y;
half2 u_color_offset(float offset)
{
return half2(0, offset);
}
half2 crt_coords(half2 uv, float bend)
{
uv -= 0.5;
uv *= 2.;
uv.x *= 1. + pow(abs(uv.y) / bend, 2.);
uv.y *= 1. + pow(abs(uv.x) / bend, 2.);
uv /= u_space_bend;
return (uv + .5);
}
float vignette(half2 uv, float size, float smoothness, float edgeRounding)
{
uv -= .5;
uv *= size;
float amount = sqrt(pow(abs(uv.x), edgeRounding) + pow(abs(uv.y), edgeRounding));
amount = 1. - amount;
return smoothstep(0, smoothness, amount);
}
float scanline(half2 uv, float lines, float speed, float transparence)
{
return sin(uv.y * lines + u_time * speed) * transparence;
}
float random(half2 uv)
{
return frac(sin(dot(uv, half2(15.1511, 42.5225))) * 12341.51611 * sin(u_time * 0.03));
}
float noise(half2 uv)
{
half2 i = floor(uv);
half2 f = frac(uv);
float a = random(i);
float b = random(i + half2(1., 0.));
float c = random(i + half2(0, 1.));
float d = random(i + half2(1., 1.));
half2 u = smoothstep(0., 1., f);
return (lerp(a, b, u.x) + (c - a) * u.y * (1. - u.x) + (d - b) * u.x * u.y);
}
float4 frag(Varyings i) : SV_Target
{
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
u_time = _Time;
half2 crt_uv = crt_coords(i.uv, u_bend);
float4 color = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.uv);
color.r = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, crt_uv + u_color_offset(u_red_offset_y)).r;
color.g = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, crt_uv + u_color_offset(u_green_offset_y)).g;
color.b = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, crt_uv + u_color_offset(u_blue_offset_y)).b;
color.a = SAMPLE_TEXTURE2D(_MainTex,sampler_MainTex, crt_uv).a;
float s1 = scanline(i.uv, u_scanline_size_1, u_scanline_speed_1, u_scanlin_transparence1);
float s2 = scanline(i.uv, u_scanline_size_2, u_scanline_speed_2, u_scanlin_transparence2);
color = lerp(color, (s1 + s2), u_scanline_amount);
color = lerp(color, noise(i.uv * u_noise_size), u_noise_amount);
color *= vignette(i.uv, u_vignette_size, u_vignette_smoothness, u_vignette_edge_round);
return color;
}
ENDHLSL
}
}
FallBack "Diffuse"
}

View File

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: d4c49b1ac4f8dd44d98d7885681c6d4d
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
preprocessorOverride: 0
userData:
assetBundleName:
assetBundleVariant: