Update Files

This commit is contained in:
2025-01-22 16:18:30 +01:00
parent ed4603cf95
commit a36294b518
16718 changed files with 2960346 additions and 0 deletions

View File

@ -0,0 +1,64 @@
// Alchemy AO / Scalable Ambient Obscurance
#version 450
#include "compiled.inc"
#include "std/gbuffer.glsl"
uniform sampler2D gbufferD;
uniform sampler2D gbuffer0;
uniform vec2 cameraProj;
uniform vec3 eye;
uniform vec3 eyeLook;
uniform vec2 screenSize;
uniform mat4 invVP;
#ifdef _CPostprocess
uniform vec3 PPComp12;
#endif
in vec2 texCoord;
in vec3 viewRay;
out float fragColor;
void main() {
float depth = textureLod(gbufferD, texCoord, 0.0).r * 2.0 - 1.0;
if (depth == 1.0) { fragColor = 1.0; return; }
vec2 enc = textureLod(gbuffer0, texCoord, 0.0).rg;
vec3 n;
n.z = 1.0 - abs(enc.x) - abs(enc.y);
n.xy = n.z >= 0.0 ? enc.xy : octahedronWrap(enc.xy);
n = normalize(n);
vec3 vray = normalize(viewRay);
vec3 currentPos = getPosNoEye(eyeLook, vray, depth, cameraProj);
// vec3 currentPos = getPos2NoEye(eye, invVP, depth, texCoord);
float currentDistance = length(currentPos);
#ifdef _CPostprocess
float currentDistanceA = currentDistance * PPComp12.z * (1.0 / PPComp12.y);
#else
float currentDistanceA = currentDistance * ssaoScale * (1.0 / ssaoRadius);
#endif
float currentDistanceB = currentDistance * 0.0005;
ivec2 px = ivec2(texCoord * screenSize);
float phi = (3 * px.x ^ px.y + px.x * px.y) * 10;
fragColor = 0;
const int samples = 8;
const float samplesInv = PI2 * (1.0 / samples);
for (int i = 0; i < samples; ++i) {
float theta = samplesInv * (i + 0.5) + phi;
vec2 k = vec2(cos(theta), sin(theta)) / currentDistanceA;
depth = textureLod(gbufferD, texCoord + k, 0.0).r * 2.0 - 1.0;
// vec3 pos = getPosNoEye(eyeLook, vray, depth, cameraProj) - currentPos;
vec3 pos = getPos2NoEye(eye, invVP, depth, texCoord + k) - currentPos;
fragColor += max(0, dot(pos, n) - currentDistanceB) / (dot(pos, pos) + 0.015);
}
#ifdef _CPostprocess
fragColor *= (PPComp12.x * 0.3) / samples;
#else
fragColor *= (ssaoStrength * 0.3) / samples;
#endif
fragColor = 1.0 - fragColor;
}

View File

@ -0,0 +1,40 @@
{
"contexts": [
{
"name": "ssao_pass",
"depth_write": false,
"compare_mode": "always",
"cull_mode": "none",
"links": [
{
"name": "invVP",
"link": "_inverseViewProjectionMatrix"
},
{
"name": "eye",
"link": "_cameraPosition"
},
{
"name": "eyeLook",
"link": "_cameraLook"
},
{
"name": "cameraProj",
"link": "_cameraPlaneProj"
},
{
"name": "screenSize",
"link": "_screenSize"
},
{
"name": "PPComp12",
"link": "_PPComp12",
"ifdef": ["_CPostprocess"]
}
],
"texture_params": [],
"vertex_shader": "../include/pass_viewray.vert.glsl",
"fragment_shader": "ssao_pass.frag.glsl"
}
]
}

View File

@ -0,0 +1,61 @@
// Alchemy AO / Scalable Ambient Obscurance
#version 450
#include "compiled.inc"
#include "std/gbuffer.glsl"
uniform sampler2D gbufferD;
uniform sampler2D gbuffer0;
uniform vec2 cameraProj;
uniform vec3 eye;
uniform vec3 eyeLook;
uniform vec2 screenSize;
uniform mat4 invVP;
in vec2 texCoord;
in vec3 viewRay;
out float fragColor;
void main() {
float depth = textureLod(gbufferD, texCoord, 0.0).r * 2.0 - 1.0;
if (depth == 1.0) { fragColor = 1.0; return; }
vec2 enc = textureLod(gbuffer0, texCoord, 0.0).rg;
vec3 n;
n.z = 1.0 - abs(enc.x) - abs(enc.y);
n.xy = n.z >= 0.0 ? enc.xy : octahedronWrap(enc.xy);
n = normalize(n);
vec3 vray = normalize(viewRay);
vec3 currentPos = getPosNoEye(eyeLook, vray, depth, cameraProj);
// vec3 currentPos = getPos2NoEye(eye, invVP, depth, texCoord);
float currentDistance = length(currentPos);
float currentDistanceA = currentDistance * ssaoScale * (1.0 / ssaoRadius);
float currentDistanceB = currentDistance * 0.0005;
float currentDistanceC = currentDistance * 5.0;
ivec2 px = ivec2(texCoord * screenSize);
float phi = (3 * px.x ^ px.y + px.x * px.y) * 10;
fragColor = 0;
const int samples = 8;
const float samplesInv = PI2 * (1.0 / samples);
for (int i = 0; i < samples; ++i) {
float theta = samplesInv * (i + 0.5) + phi;
vec2 k = vec2(cos(theta), sin(theta)) / currentDistanceA;
depth = textureLod(gbufferD, texCoord + k, 0.0).r * 2.0 - 1.0;
// vec3 pos = getPosNoEye(eyeLook, vray, depth, cameraProj) - currentPos;
vec3 pos = getPos2NoEye(eye, invVP, depth, texCoord + k) - currentPos;
fragColor += (max(0, dot(pos, n) - currentDistanceB) / (dot(pos, pos) + 0.015));
}
for (int i = 0; i < samples; ++i) {
float theta = samplesInv * (i + 0.5) + phi;
vec2 k = vec2(cos(theta), sin(theta)) / currentDistanceC;
depth = textureLod(gbufferD, texCoord + k, 0.0).r * 2.0 - 1.0;
vec3 pos = getPos2NoEye(eye, invVP, depth, texCoord + k) - currentPos;
fragColor += (max(0, dot(pos, n) - currentDistanceB) / (dot(pos, pos) + 0.015));
}
fragColor *= (ssaoStrength * 0.4) / samples;
fragColor = 1.0 - fragColor;
}

View File

@ -0,0 +1,35 @@
{
"contexts": [
{
"name": "ssgi_pass",
"depth_write": false,
"compare_mode": "always",
"cull_mode": "none",
"links": [
{
"name": "invVP",
"link": "_inverseViewProjectionMatrix"
},
{
"name": "eye",
"link": "_cameraPosition"
},
{
"name": "eyeLook",
"link": "_cameraLook"
},
{
"name": "cameraProj",
"link": "_cameraPlaneProj"
},
{
"name": "screenSize",
"link": "_screenSize"
}
],
"texture_params": [],
"vertex_shader": "../include/pass_viewray.vert.glsl",
"fragment_shader": "ssgi_pass.frag.glsl"
}
]
}