First Commit

This commit is contained in:
2025-05-18 22:39:39 +03:00
commit 042ede7228
440 changed files with 103153 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
// Albert Ghost Memory
Shader "Golems/Albert Ghost Memory"
{
Properties
{
_MainTex ("Base (RGB)", 2D) = "white" {}
}
SubShader
{
Tags { "RenderType"="Opaque" "IgnoreProjector" = "True" }
LOD 200
CGPROGRAM
#pragma target 3.0
#pragma surface surf Lambert alpha
sampler2D _MainTex;
struct Input
{
float2 uv_MainTex;
float3 worldPos;
float3 worldNormal;
};
void surf (Input IN, inout SurfaceOutput o)
{
float3 finalColour = tex2D(_MainTex, IN.uv_MainTex.xy);
o.Albedo = finalColour;
}
ENDCG
}
FallBack "Diffuse"
}

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 1cf9641cfbfc1a640948aabcfe105542
timeCreated: 1530553908
licenseType: Pro
ShaderImporter:
externalObjects: {}
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,141 @@
Shader "Golems/RenderFeature/AlbertGhostMemoryBlur"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
}
SubShader
{
Cull Off ZWrite Off ZTest Always
// Horizontal
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f
{
float4 vertex : SV_POSITION;
float2 uv : TEXCOORD0;
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
};
UNITY_DECLARE_SCREENSPACE_TEXTURE(_MainTex);
half4 _MainTex_ST;
float2 _GhostBlurSize;
v2f vert (appdata v)
{
v2f o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_OUTPUT(v2f, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
return o;
}
fixed4 frag (v2f i) : SV_Target
{
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
float2 uv = UnityStereoScreenSpaceUVAdjust(i.uv, _MainTex_ST);
fixed4 s = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, uv) * 0.38774;
uv = UnityStereoScreenSpaceUVAdjust(i.uv + float2(_GhostBlurSize.x * 2, 0), _MainTex_ST);
s += UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, uv) * 0.06136;
uv = UnityStereoScreenSpaceUVAdjust(i.uv + float2(_GhostBlurSize.x, 0), _MainTex_ST);
s += UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, uv) * 0.24477;
uv = UnityStereoScreenSpaceUVAdjust(i.uv + float2(_GhostBlurSize.x * -1, 0), _MainTex_ST);
s += UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, uv) * 0.24477;
uv = UnityStereoScreenSpaceUVAdjust(i.uv + float2(_GhostBlurSize.x * -2, 0), _MainTex_ST);
s += UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, uv) * 0.06136;
return s;
}
ENDCG
}
// Vertical
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f
{
float4 vertex : SV_POSITION;
float2 uv : TEXCOORD0;
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
};
UNITY_DECLARE_SCREENSPACE_TEXTURE(_MainTex);
half4 _MainTex_ST;
float2 _GhostBlurSize;
v2f vert (appdata v)
{
v2f o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_OUTPUT(v2f, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
return o;
}
fixed4 frag (v2f i) : SV_Target
{
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
float2 uv = UnityStereoScreenSpaceUVAdjust(i.uv, _MainTex_ST);
fixed4 s = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, uv) * 0.38774;
uv = UnityStereoScreenSpaceUVAdjust(i.uv + float2(_GhostBlurSize.y * 2, 0), _MainTex_ST);
s += UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, uv) * 0.06136;
uv = UnityStereoScreenSpaceUVAdjust(i.uv + float2(_GhostBlurSize.y, 0), _MainTex_ST);
s += UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, uv) * 0.24477;
uv = UnityStereoScreenSpaceUVAdjust(i.uv + float2(_GhostBlurSize.y * -1, 0), _MainTex_ST);
s += UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, uv) * 0.24477;
uv = UnityStereoScreenSpaceUVAdjust(i.uv + float2(_GhostBlurSize.y * -2, 0), _MainTex_ST);
s += UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, uv) * 0.06136;
return s;
}
ENDCG
}
}
}

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: db5687681f4141342805cfc8e857479c
timeCreated: 1530636780
licenseType: Pro
ShaderImporter:
externalObjects: {}
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,103 @@
Shader "Golems/RenderFeature/AlbertGhostMemoryCmdShader"
{
Properties
{
// This alpha is per model
// NOTE: accessed via MaterialPropertyBlock
[PerRendererData]
_PerGhostAlpha("Per Ghost Alpha", Float) = 1.0
}
SubShader
{
Tags { "RenderType"="Opaque" }
LOD 100
ZWrite Off
Lighting Off
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;
float4 projPos : TEXCOORD0;
//float3 viewNormal : TEXCOORD1;
float2 convertedNormal : TEXCOORD1;
};
float rand(float2 co)
{
return frac(sin(dot(co.xy, float2(12.9898, 78.233))) * 43758.5453);
}
float rand1(float n)
{
return frac(sin(n) * 43758.5453123);
}
float noise(float p)
{
float fl = floor(p);
float fc = frac(p);
return lerp(rand1(fl), rand1(fl + 1.0), fc);
}
v2f vert (const appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.projPos = ComputeScreenPos(o.vertex);
COMPUTE_EYEDEPTH(o.projPos.z);
//o.viewNormal = COMPUTE_VIEW_NORMAL;
// work out camera position to vert position
float3 normalDir = UnityObjectToWorldNormal(v.normal);
float3 viewDir = normalize(WorldSpaceViewDir(v.vertex));
float3 upDir = float3(0.0, 1.0, 0.0);
float3 rightDir = normalize(cross(viewDir, upDir));
upDir = cross(rightDir, viewDir);
o.convertedNormal.x = dot(rightDir, normalDir);
o.convertedNormal.y = dot(upDir, normalDir);
return o;
}
float _PerGhostAlpha;
//sampler2D_float _CameraDepthTexture;
UNITY_DECLARE_DEPTH_TEXTURE(_CameraDepthTexture);
float4 _CameraDepthTexture_TexelSize;
fixed4 frag (v2f i) : SV_Target
{
float sceneZ = LinearEyeDepth(SAMPLE_DEPTH_TEXTURE_PROJ(_CameraDepthTexture, UNITY_PROJ_COORD(i.projPos)));
float vertZ = i.projPos.z;
float alpha = _PerGhostAlpha;
if (vertZ > sceneZ)
discard; // Fragments that fail the depth test shouldn't write to the render target
return fixed4(1.0, 1.0, 1.0, alpha);
}
ENDCG
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d21a60931c6b5ea439930a86dca0aba7
timeCreated: 1530550551
licenseType: Pro
ShaderImporter:
externalObjects: {}
defaultTextures:
- _NoiseTex: {fileID: 2800000, guid: 28c7aad1372ff114b90d330f8a2dd938, type: 3}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,122 @@
Shader "Hidden/AlbertGhostMemoryComposite"
{
Properties
{
_MainTex ("Texture", any) = "white" {}
_EdgeTex ("Edge Texture", 2D) = "white" {}
}
SubShader
{
Cull Off ZWrite Off ZTest Always
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f
{
float4 vertex : SV_POSITION;
float2 uv0 : TEXCOORD0;
float2 uv1 : TEXCOORD1;
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
};
float2 _MainTex_TexelSize;
UNITY_DECLARE_SCREENSPACE_TEXTURE(_MainTex);
UNITY_DECLARE_SCREENSPACE_TEXTURE(_AlbertGhostMemoryMaskTex);
UNITY_DECLARE_SCREENSPACE_TEXTURE(_AlbertGhostMemoryTex);
UNITY_DECLARE_SCREENSPACE_TEXTURE(_AlbertGhostMemoryBlurredTex);
UNITY_DECLARE_SCREENSPACE_TEXTURE(_TempTexGhost);
UNITY_DECLARE_SCREENSPACE_TEXTURE(_EdgeTex);
uniform float EdgeValue;
uniform float OffsetRedX;
uniform float OffsetGreenX;
uniform float OffsetBlueX;
uniform float OffsetRedY;
uniform float OffsetGreenY;
uniform float OffsetBlueY;
uniform float Brightness;
uniform float Contrast;
uniform float GlobalAlpha;
half4 _MainTex_ST;
half4 _EdgeTex_ST;
v2f vert (appdata v)
{
v2f o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_OUTPUT(v2f, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv0 = TRANSFORM_TEX(v.uv, _MainTex);
o.uv1 = TRANSFORM_TEX(v.uv, _MainTex);
#if UNITY_UV_STARTS_AT_TOP
if (_MainTex_TexelSize.y < 0)
o.uv1.y = 1 - o.uv1.y;
#endif
return o;
}
fixed4 frag (v2f i) : SV_Target
{
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
fixed4 colour = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv0, _MainTex_ST));
fixed4 mask = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_AlbertGhostMemoryBlurredTex, UnityStereoScreenSpaceUVAdjust(i.uv1, _MainTex_ST));
// Step 0: Chromatic aberration
float3 finalColour;
float4 blue = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_AlbertGhostMemoryTex, UnityStereoScreenSpaceUVAdjust(i.uv0 + float2(OffsetBlueX, OffsetBlueY), _MainTex_ST));
float4 red = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_AlbertGhostMemoryTex, UnityStereoScreenSpaceUVAdjust(i.uv0 + float2(OffsetRedX, OffsetRedY), _MainTex_ST));
float4 green = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_AlbertGhostMemoryTex, UnityStereoScreenSpaceUVAdjust(i.uv0 + float2(OffsetGreenX, OffsetGreenY), _MainTex_ST));
finalColour.b = blue.b;
finalColour.r = red.r;
finalColour.g = green.g;
// Step 3.5: Adjust brightness and contrast
finalColour.xyz = finalColour.xyz * Brightness;
finalColour.xyz = (finalColour.xyz - 0.5f) * Contrast + 0.5f;
// Edge
if (mask.a > 0.0 && mask.a < 1.0)
{
finalColour.xyz = finalColour.xyz * (1.0 - EdgeValue) + EdgeValue * (finalColour.xyz * mask.a + (1.0 - mask.a) * UNITY_SAMPLE_SCREENSPACE_TEXTURE(_EdgeTex, UnityStereoScreenSpaceUVAdjust(float2(mask.a, mask.a), _EdgeTex_ST)));
}
// Final Step: Mask
float finalAlpha = mask.a ;//* GlobalAlpha;
colour.xyz = finalAlpha * finalColour.xyz + (1.0 - finalAlpha) * colour.xyz;
//colour.xyz = mask.a * finalColour.xyz + (1.0 - mask.a) * colour.xyz + edgenoise;
//colour.xyz = mask.x > 0.0 ? finalColour.xyz : colour.xyz;
// TEST MASK
//colour.xyz = mask.a * mask.xyz;
return colour;
}
ENDCG
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 8a4ba35c968d2cf489a07862b457dd0a
timeCreated: 1530550551
licenseType: Pro
ShaderImporter:
externalObjects: {}
defaultTextures:
- _MainTex: {instanceID: 0}
- _EdgeTex: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,116 @@
// Albert Ghost Memory Object
// Eg use as shader for the actual objects in place of Standard
Shader "Golems/Albert Ghost Memory Object"
{
Properties
{
_MainTex("Texture", 2D) = "white" {}
_BumpMap("Normal Map", 2D) = "bump" {}
// _LightColour("Light Colour", Color) = (1.0, 1.0, 1.0, 1.0)
// _LightDirection("Light Direction", Vector) = (0.5, 0.5, 0.5, 0.0)
_Shininess("Shininess", float) = 10
// _RimColor("Rim Color", Color) = (1.0, 1.0, 1.0, 1.0)
// _RimPower("Rim Power", Range(0.1, 10.0)) = 3.0
_Emission("Emission", float) = 0.8
}
SubShader
{
Tags { "RenderType" = "Opaque" }
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
sampler2D _MainTex;
float4 _MainTex_ST;
sampler2D _BumpMap;
float4 _BumpMap_ST;
float4 _LightColour;
float4 _LightDirection;
float _Shininess;
// float4 _RimColor;
// float _RimPower;
float _Emission;
struct vertexInput
{
float4 vertex: POSITION;
float3 normal: NORMAL;
float4 texcoord: TEXCOORD0;
float4 tangent: TANGENT;
};
struct vertexOutput
{
float4 pos: SV_POSITION;
float4 uv: TEXCOORD0;
float4 posWorld: TEXCOORD1;
float3 normalWorld: TEXCOORD2;
float3 tangentWorld: TEXCOORD3;
float3 binormalWorld: TEXCOORD4;
};
vertexOutput vert(vertexInput v)
{
vertexOutput o;
o.normalWorld = normalize(mul(float4(v.normal, 0.0), unity_WorldToObject).xyz);
o.tangentWorld = normalize(mul(unity_ObjectToWorld, v.tangent).xyz);
o.binormalWorld = normalize(cross(o.normalWorld, o.tangentWorld));
o.posWorld = mul(unity_ObjectToWorld, v.vertex);
o.pos = UnityObjectToClipPos(v.vertex);
o.uv = v.texcoord;
return o;
}
float4 frag(vertexOutput i) : COLOR
{
float3 viewDirection = normalize(_WorldSpaceCameraPos.xyz - i.posWorld.xyz);
// Texture Maps
float4 tex = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv, _MainTex_ST));
float4 texN = tex2D(_BumpMap, UnityStereoScreenSpaceUVAdjust(i.uv, _BumpMap_ST));
// unpackNormal Function
float3 localCoords = float3(2.0 * texN.ag - float2(1.0,1.0), 0.0);
//localCoords.z = 1.0 - 0.5 * dot( localCoords, localCoords );
localCoords.z = 1.0;
// Normal Transpose Matrix
float3x3 local2WorldTranspose = float3x3(i.tangentWorld, i.binormalWorld, i.normalWorld);
// Calculate Normal Direction
float3 normalDirection = normalize(mul(localCoords, local2WorldTranspose));
// Lighting
float3 diffuseReflection = _LightColour * saturate(dot(normalDirection, _LightDirection.xyz));
float3 specularReflection = diffuseReflection * pow(saturate(dot(reflect(-_LightDirection.xyz, normalDirection), viewDirection)), _Shininess);
// Rim Lighting
// float rim = 1.0 - saturate(dot(viewDirection, normalDirection));
// float3 rimLighting = saturate(pow(rim, _RimPower) * _RimColor.rgb * diffuseReflection);
float3 lightFinal = diffuseReflection + specularReflection;// +rimLighting + UNITY_LIGHTMODEL_AMBIENT.rgb;
return float4(tex.xyz * _Emission + tex.xyz * lightFinal, 1.0);
}
ENDCG
}
}
Fallback "Diffuse"
}

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 1dc6c9abad784b8478732fae8a5f00cf
timeCreated: 1534339470
licenseType: Pro
ShaderImporter:
externalObjects: {}
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,103 @@
Shader "Hidden/AlbertMemoryBlur"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
}
SubShader
{
Cull Off ZWrite Off ZTest Always
// Horizontal
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
};
struct v2f
{
float4 vertex : SV_POSITION;
float2 uv : TEXCOORD0;
};
sampler2D _MainTex;
float2 _BlurSize;
half4 _MainTex_ST;
v2f vert (appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
return o;
}
fixed4 frag (v2f i) : SV_Target
{
fixed4 s = tex2D(_MainTex, i.uv) * 0.38774;
s += tex2D(_MainTex, i.uv + float2(_BlurSize.x * 2, 0)) * 0.06136;
s += tex2D(_MainTex, i.uv + float2(_BlurSize.x, 0)) * 0.24477;
s += tex2D(_MainTex, i.uv + float2(_BlurSize.x * -1, 0)) * 0.24477;
s += tex2D(_MainTex, i.uv + float2(_BlurSize.x * -2, 0)) * 0.06136;
return s;
}
ENDCG
}
// Vertical
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
};
struct v2f
{
float4 vertex : SV_POSITION;
float2 uv : TEXCOORD0;
};
sampler2D _MainTex;
float2 _BlurSize;
half4 _MainTex_ST;
v2f vert (appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
return o;
}
fixed4 frag (v2f i) : SV_Target
{
fixed4 s = tex2D(_MainTex, i.uv) * 0.38774;
s += tex2D(_MainTex, i.uv + float2(0, _BlurSize.y * 2)) * 0.06136;
s += tex2D(_MainTex, i.uv + float2(0, _BlurSize.y)) * 0.24477;
s += tex2D(_MainTex, i.uv + float2(0, _BlurSize.y * -1)) * 0.24477;
s += tex2D(_MainTex, i.uv + float2(0, _BlurSize.y * -2)) * 0.06136;
return s;
}
ENDCG
}
}
}

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 353e957d716b23c45a7860230dec00a7
timeCreated: 1524218841
licenseType: Pro
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,119 @@
Shader "Hidden/AlbertMemoryCmdShader"
{
Properties
{
_NoiseTex("Noise Texture", 2D) = "white" {}
}
SubShader
{
Tags { "RenderType"="Opaque" }
LOD 100
ZWrite Off
Lighting Off
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;
float4 projPos : TEXCOORD0;
//float3 viewNormal : TEXCOORD1;
float2 convertedNormal : TEXCOORD1;
};
float rand(float2 co)
{
return frac(sin(dot(co.xy, float2(12.9898, 78.233))) * 43758.5453);
}
float rand1(float n)
{
return frac(sin(n) * 43758.5453123);
}
float noise(float p)
{
float fl = floor(p);
float fc = frac(p);
return lerp(rand1(fl), rand1(fl + 1.0), fc);
}
uniform float VerticalAmplitude;
uniform float VerticalSpeed;
uniform float HorizontalAmplitude;
uniform float HorizontalSpeed;
v2f vert (appdata v)
{
float rand_y = rand(v.vertex.xz);
float rand_x = rand(v.vertex.y);
float rand_z = rand(rand_x);
v.vertex.y = v.vertex.y + (rand_y - 0.5) * VerticalAmplitude * sin(_Time.y * VerticalSpeed);
v.vertex.xz = v.vertex.xz + float2(rand_x - 0.5, rand_z - 0.5) * HorizontalAmplitude * sin(_Time.y * HorizontalSpeed);
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.projPos = ComputeScreenPos(o.vertex);
COMPUTE_EYEDEPTH(o.projPos.z);
//o.viewNormal = COMPUTE_VIEW_NORMAL;
// work out camera position to vert position
float3 normalDir = UnityObjectToWorldNormal(v.normal);
float3 viewDir = normalize(WorldSpaceViewDir(v.vertex));
float3 upDir = float3(0.0, 1.0, 0.0);
float3 rightDir = normalize(cross(viewDir, upDir));
upDir = cross(rightDir, viewDir);
o.convertedNormal.x = dot(rightDir, normalDir);
o.convertedNormal.y = dot(upDir, normalDir);
return o;
}
sampler2D _NoiseTex;
half4 _NoiseTex_ST;
sampler2D_float _CameraDepthTexture;
float4 _CameraDepthTexture_TexelSize;
fixed4 frag (v2f i) : SV_Target
{
float sceneZ = LinearEyeDepth(SAMPLE_DEPTH_TEXTURE_PROJ(_CameraDepthTexture, UNITY_PROJ_COORD(i.projPos)));
float vertZ = i.projPos.z;
float size = sqrt(i.convertedNormal.x * i.convertedNormal.x + i.convertedNormal.y * i.convertedNormal.y);
float2 normalDir = normalize(i.convertedNormal);
// Noise
//float noisefactor = 0;// noise(1000.0 * (atan2(normalDir.x, normalDir.y) + _Time));
float2 noise_uv = 4.0 * normalDir + _Time * 0.5;
float noisefactor = tex2D(_NoiseTex, UnityStereoScreenSpaceUVAdjust(noise_uv, _NoiseTex_ST)).y;
// Scale alpha based on size of noise * viewNormal
//float alpha = 1.0 - saturate(scale * (i.convertedNormal.x * i.convertedNormal.x + i.convertedNormal.y * i.convertedNormal.y));
float alpha = size > 0.5 ? lerp(1.0, 0.0, (size * noisefactor - 0.5) * 2.0) : 1.0;
//return (vertZ < sceneZ) ? fixed4(0.5 * (1.0 + i.convertedNormal.x), 0.5 * (1.0 + i.convertedNormal.y), 0.0, alpha) : fixed4(0.0, 0.0, 0.0, 0.0); // Encode the view normal in the colour, we use alpha for mask0
return (vertZ < sceneZ) ? fixed4(1.0, 1.0, 1.0, alpha) : fixed4(0.0, 0.0, 0.0, 0.0); // Encode the view normal in the colour, we use alpha for mask0
}
ENDCG
}
}
}

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: b6f59b34334a60a4c92aa01d6cbaa78e
timeCreated: 1525168299
licenseType: Pro
ShaderImporter:
defaultTextures:
- _NoiseTex: {fileID: 2800000, guid: 0f509b17d3f3c014494fb52c8a8762dd, type: 3}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,230 @@
Shader "Hidden/AlbertMemoryComposite"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
_EdgeTex ("Edge Texture", 2D) = "white" {}
}
SubShader
{
Cull Off ZWrite Off ZTest Always
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
};
struct v2f
{
float4 vertex : SV_POSITION;
float2 uv0 : TEXCOORD0;
float2 uv1 : TEXCOORD1;
};
/// <summary>
/// Computes the overlay between the source and destination colours.
/// <summary>
float3 Overlay(float3 src, float3 dst)
{
// if (dst <= O) then: 2 * src * dst
// if (dst > O) then: 1 - 2 * (1 - dst) * (1 - src)
return float3((dst.x <= 0.5) ? (2.0 * src.x * dst.x) : (1.0 - 2.0 * (1.0 - dst.x) * (1.0 - src.x)),
(dst.y <= 0.5) ? (2.0 * src.y * dst.y) : (1.0 - 2.0 * (1.0 - dst.y) * (1.0 - src.y)),
(dst.z <= 0.5) ? (2.0 * src.z * dst.z) : (1.0 - 2.0 * (1.0 - dst.z) * (1.0 - src.z)));
}
float3 mod289(float3 x) { return x - floor(x * (1.0 / 289.0)) * 289.0; }
float2 mod289(float2 x) { return x - floor(x * (1.0 / 289.0)) * 289.0; }
float3 permute(float3 x) { return mod289(((x*34.0) + 1.0)*x); }
float snoise(float2 v)
{
const float4 C = float4(0.211324865405187, // (3.0-sqrt(3.0))/6.0
0.366025403784439, // 0.5*(sqrt(3.0)-1.0)
-0.577350269189626, // -1.0 + 2.0 * C.x
0.024390243902439); // 1.0 / 41.0
// First corner
float2 i = floor(v + dot(v, C.yy));
float2 x0 = v - i + dot(i, C.xx);
// Other corners
float2 i1;
i1 = (x0.x > x0.y) ? float2(1.0, 0.0) : float2(0.0, 1.0);
float4 x12 = x0.xyxy + C.xxzz;
x12.xy -= i1;
// Permutations
i = mod289(i); // Avoid truncation effects in permutation
float3 p = permute(permute(i.y + float3(0.0, i1.y, 1.0))
+ i.x + float3(0.0, i1.x, 1.0));
float3 m = max(0.5 - float3(dot(x0, x0), dot(x12.xy, x12.xy), dot(x12.zw, x12.zw)), 0.0);
m = m*m;
m = m*m;
// Gradients: 41 points uniformly over a line, mapped onto a diamond.
// The ring size 17*17 = 289 is close to a multiple of 41 (41*7 = 287)
float3 x = 2.0 * frac(p * C.www) - 1.0;
float3 h = abs(x) - 0.5;
float3 ox = floor(x + 0.5);
float3 a0 = x - ox;
// Normalise gradients implicitly by scaling m
// Approximation of: m *= inversesqrt( a0*a0 + h*h );
m *= 1.79284291400159 - 0.85373472095314 * (a0*a0 + h*h);
// Compute final noise value at P
float3 g;
g.x = a0.x * x0.x + h.x * x0.y;
g.yz = a0.yz * x12.xz + h.yz * x12.yw;
return 130.0 * dot(m, g);
}
float2 _MainTex_TexelSize;
v2f vert (appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv0 = v.uv;
o.uv1 = v.uv;
#if UNITY_UV_STARTS_AT_TOP
if (_MainTex_TexelSize.y < 0)
o.uv1.y = 1 - o.uv1.y;
#endif
return o;
}
sampler2D _MainTex;
sampler2D _AlbertMemoryMaskTex;
sampler2D _AlbertMemoryBlurredTex;
sampler2D _TempTex0;
sampler2D _EdgeTex;
uniform float SepiaValue;
uniform float NoiseValue;
uniform float ScratchValue;
uniform float RandomValue;
uniform float TimeLapse;
uniform float EdgeValue;
uniform float ColourBleed;
uniform float OffsetX;
uniform float OffsetY;
uniform float OffsetRedX;
uniform float OffsetGreenX;
uniform float OffsetBlueX;
uniform float OffsetRedY;
uniform float OffsetGreenY;
uniform float OffsetBlueY;
uniform float Brightness;
uniform float Contrast;
half4 _MainTex_ST;
half4 _EdgeTex_ST;
fixed4 frag (v2f i) : SV_Target
{
float2 offset = float2(OffsetX, OffsetY);
fixed4 colour = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv0 + offset, _MainTex_ST));
fixed4 mask = tex2D(_AlbertMemoryBlurredTex, UnityStereoScreenSpaceUVAdjust(i.uv1, _MainTex_ST));
// Sepia RGB value
float3 sepia = float3(112.0 / 255.0, 66.0 / 255.0, 20.0 / 255.0);
// Step 0: Chromatic aberration
float3 finalColour;
float4 blue = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv0 + float2(OffsetBlueX, OffsetBlueY) + offset, _MainTex_ST));
float4 red = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv0 + float2(OffsetRedX, OffsetRedY) + offset, _MainTex_ST));
float4 green = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv0 + float2(OffsetGreenX, OffsetGreenY) + offset, _MainTex_ST));
finalColour.b = blue.b;
finalColour.r = red.r;
finalColour.g = green.g;
// Step 1: Convert to grayscale
float gray = (finalColour.x + finalColour.y + finalColour.z) / 3.0;
float3 grayscale = float3(gray, gray, gray);
// Step 2: Appy sepia overlay
//finalColour = Overlay(sepia, grayscale);
// Step 3: Lerp final sepia colour
finalColour = finalColour * ColourBleed + (1.0 - ColourBleed) * (grayscale + SepiaValue * (Overlay(sepia, grayscale) - grayscale));
// Step 3.5: Adjust brightness and contrast
finalColour.xyz = finalColour.xyz * Brightness;
finalColour.xyz = (finalColour.xyz - 0.5f) * Contrast + 0.5f;
// Step 4: Add noise
float noise = snoise(i.uv1.xy * float2(1024.0 + RandomValue * 512.0, 1024.0 + RandomValue * 512.0)) * 0.5;
finalColour += noise * NoiseValue;
// Step 5: Apply scratches
if (RandomValue < ScratchValue)
{
// Pick a random spot to show scratches
float dist = 1.0 / ScratchValue;
//RandomValue *= _Time.y*10;
float d = distance(i.uv1.xy, float2(RandomValue * dist, RandomValue * dist));
if (d < 0.4)
{
// Generate the scratch
float xPeriod = 8.0;
float yPeriod = 1.0;
float pi = 3.141592;
float phase = TimeLapse;
// float phase = _Time.x*TimeLapse;
// float phase = _Time.x;
float turbulence = snoise(i.uv1.xy * 2.5);
float vScratch = 0.5 + (sin(((i.uv1.x * xPeriod + i.uv1.y * yPeriod + turbulence)) * pi + phase) * 0.5);
vScratch = clamp((vScratch * 10000.0) + 0.35, 0.0, 1.0);
finalColour.xyz *= vScratch;
}
}
// Step 6: Apply vignetting
// Max distance from centre to corner is ~0.7. Scale that to 1.0.
// float d = distance(float2(0.5, 0.5), IN.uv_MainTex) * 1.414213;
// float vignetting = clamp((OuterVignetting - d) / (OuterVignetting - InnerVignetting), 0.0, 1.0);
// finalColour.xyz *= vignetting;
// Step 7: Edge effect
//float3 edgenoise = mask.a > 0.0 ? float3(1.0, 1.0, 1.0) * noise * EdgeValue * (1.0 - 2.0 * abs(0.5 - mask.a)) : float3(0.0, 0.0, 0.0);
if (mask.a > 0.0 && mask.a < 1.0)
{
finalColour.xyz = finalColour.xyz * (1.0 - EdgeValue) + EdgeValue * (finalColour.xyz * mask.a + (1.0 - mask.a) * tex2D(_EdgeTex, UnityStereoScreenSpaceUVAdjust(float2(mask.a, mask.a), _EdgeTex_ST)));
}
// Final Step: Mask
colour.xyz = mask.a * finalColour.xyz + (1.0 - mask.a) * colour.xyz;
//colour.xyz = mask.a * finalColour.xyz + (1.0 - mask.a) * colour.xyz + edgenoise;
//colour.xyz = mask.x > 0.0 ? finalColour.xyz : colour.xyz;
// TEST MASK
//colour.xyz = mask.a * mask.xyz;
return colour;
}
ENDCG
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1eacac7eaecf027438e8188ca4370312
timeCreated: 1525168321
licenseType: Pro
ShaderImporter:
defaultTextures:
- _MainTex: {instanceID: 0}
- _EdgeTex: {fileID: 2800000, guid: 9eea88d77adc16e4abcf5e1d0c5a5dea, type: 3}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,173 @@
Shader "Hidden/AlbertMemoryPaintingComposite"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
}
SubShader
{
Cull Off ZWrite Off ZTest Always
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
};
struct v2f
{
float4 vertex : SV_POSITION;
float2 uv0 : TEXCOORD0;
float2 uv1 : TEXCOORD1;
};
float2 _MainTex_TexelSize;
v2f vert (appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv0 = v.uv;
o.uv1 = v.uv;
#if UNITY_UV_STARTS_AT_TOP
if (_MainTex_TexelSize.y < 0)
o.uv1.y = 1 - o.uv1.y;
#endif
return o;
}
sampler2D _MainTex;
sampler2D _AlbertMemoryMaskTex;
sampler2D _AlbertMemoryBlurredTex;
sampler2D _TempTex0;
uniform float SepiaValue;
uniform float NoiseValue;
uniform float ScratchValue;
uniform float RandomValue;
uniform float TimeLapse;
uniform float EdgeValue;
half4 _MainTex_ST;
fixed4 frag (v2f i) : SV_Target
{
fixed4 colour = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv0, _MainTex_ST));
fixed4 mask = tex2D(_AlbertMemoryBlurredTex, UnityStereoScreenSpaceUVAdjust(i.uv1, _MainTex_ST));
// Oil painting effect
int radius = 7;
float3 finalColour = float3(0.0, 0.0, 0.0);
float2 iResolution = float2(_MainTex_TexelSize.x, _MainTex_TexelSize.y); // 1/x?
float2 src_size = float2(_MainTex_TexelSize.x, _MainTex_TexelSize.y);
float2 uv = i.uv0.xy / iResolution.xy;
float n = float((radius + 1) * (radius + 1));
int k;
int j;
float3 m0 = float3(0.0, 0.0, 0.0); float3 m1 = float3(0.0, 0.0, 0.0); float3 m2 = float3(0.0, 0.0, 0.0); float3 m3 = float3(0.0, 0.0, 0.0);
float3 s0 = float3(0.0, 0.0, 0.0); float3 s1 = float3(0.0, 0.0, 0.0); float3 s2 = float3(0.0, 0.0, 0.0); float3 s3 = float3(0.0, 0.0, 0.0);
float3 c;
for (int j = -radius; j <= 0; ++j)
{
for (int k = -radius; k <= 0; ++k)
{
c = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv0, _MainTex_ST) + float2(k, j) * src_size).rgb;
m0 += c;
s0 += c * c;
}
}
for (int j = -radius; j <= 0; ++j)
{
for (int k = 0; k <= radius; ++k)
{
c = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv0, _MainTex_ST) + float2(k, j) * src_size).rgb;
m1 += c;
s1 += c * c;
}
}
for (int j = 0; j <= radius; ++j)
{
for (int k = 0; k <= radius; ++k)
{
c = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv0, _MainTex_ST) + float2(k, j) * src_size).rgb;
m2 += c;
s2 += c * c;
}
}
for (int j = 0; j <= radius; ++j)
{
for (int k = -radius; k <= 0; ++k)
{
c = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv0, _MainTex_ST) + float2(k, j) * src_size).rgb;
m3 += c;
s3 += c * c;
}
}
float min_sigma2 = 1e+2;
m0 /= n;
s0 = abs(s0 / n - m0 * m0);
float sigma2 = s0.r + s0.g + s0.b;
if (sigma2 < min_sigma2)
{
min_sigma2 = sigma2;
finalColour = m0;
}
m1 /= n;
s1 = abs(s1 / n - m1 * m1);
sigma2 = s1.r + s1.g + s1.b;
if (sigma2 < min_sigma2)
{
min_sigma2 = sigma2;
finalColour = m1;
}
m2 /= n;
s2 = abs(s2 / n - m2 * m2);
sigma2 = s2.r + s2.g + s2.b;
if (sigma2 < min_sigma2)
{
min_sigma2 = sigma2;
finalColour = m2;
}
m3 /= n;
s3 = abs(s3 / n - m3 * m3);
sigma2 = s3.r + s3.g + s3.b;
if (sigma2 < min_sigma2)
{
min_sigma2 = sigma2;
finalColour = m3;
}
// Final Step: Mask
colour.xyz = mask.x * finalColour.xyz + (1.0 - mask.a) * colour.xyz;
//colour.xyz = mask.x > 0.0 ? finalColour.xyz : colour.xyz;
return colour;
}
ENDCG
}
}
}

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 57848ba46b5129447a04fc2fbf6449c2
timeCreated: 1524559081
licenseType: Pro
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
Shader "Golems/AlbertMemoryWindowObject"
{
SubShader
{
Colormask 0 Zwrite Off
Pass{}
}
}

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: f987f4f4ca52bc847a7a133da20aaba1
timeCreated: 1524733193
licenseType: Pro
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,99 @@
Shader "Custom/TestFakeAlvertGhostMemoryCmdShader"
{
Properties
{
// This alpha is per model
// NOTE: accessed via MaterialPropertyBlock
[PerRendererData]
_PerGhostAlpha("Per Ghost Alpha", Float) = 1.0
}
SubShader
{
Tags { "RenderType"="Opaque" }
LOD 100
ZWrite Off
Lighting Off
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;
float4 projPos : TEXCOORD0;
//float3 viewNormal : TEXCOORD1;
float2 convertedNormal : TEXCOORD1;
};
float rand(float2 co)
{
return frac(sin(dot(co.xy, float2(12.9898, 78.233))) * 43758.5453);
}
float rand1(float n)
{
return frac(sin(n) * 43758.5453123);
}
float noise(float p)
{
float fl = floor(p);
float fc = frac(p);
return lerp(rand1(fl), rand1(fl + 1.0), fc);
}
v2f vert (const appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.projPos = ComputeScreenPos(o.vertex);
COMPUTE_EYEDEPTH(o.projPos.z);
//o.viewNormal = COMPUTE_VIEW_NORMAL;
// work out camera position to vert position
float3 normalDir = UnityObjectToWorldNormal(v.normal);
float3 viewDir = normalize(WorldSpaceViewDir(v.vertex));
float3 upDir = float3(0.0, 1.0, 0.0);
float3 rightDir = normalize(cross(viewDir, upDir));
upDir = cross(rightDir, viewDir);
o.convertedNormal.x = dot(rightDir, normalDir);
o.convertedNormal.y = dot(upDir, normalDir);
return o;
}
float _PerGhostAlpha;
//sampler2D_float _CameraDepthTexture;
UNITY_DECLARE_DEPTH_TEXTURE(_CameraDepthTexture);
float4 _CameraDepthTexture_TexelSize;
fixed4 frag (v2f i) : SV_Target
{
float sceneZ = LinearEyeDepth(SAMPLE_DEPTH_TEXTURE_PROJ(_CameraDepthTexture, UNITY_PROJ_COORD(i.projPos)));
float vertZ = i.projPos.z;
float alpha = _PerGhostAlpha;
return (vertZ < sceneZ) ? fixed4(1.0, 0.0, 0.0, alpha) : fixed4(0.0, 0.0, 0.0, 0.0);
}
ENDCG
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 95d412e6c2704f07ab073b822a6d9eff
timeCreated: 1642433938