jitter dof (:

shadow jitter still not working
This commit is contained in:
Sasha
2023-07-07 22:58:36 +01:00
parent 35f8b6373b
commit 69b0be256e
10 changed files with 247 additions and 7 deletions

View File

@ -10,6 +10,7 @@ Read the terms of modification and sharing before changing something below pleas
*/
#include "/lib/settings.glsl"
#include "/lib/Shadow_Params.glsl"
#include "/lib/bokeh.glsl"
#define SHADOW_MAP_BIAS 0.5
const float PI = 3.1415927;
@ -21,8 +22,12 @@ uniform mat4 shadowModelView;
uniform mat4 gbufferModelView;
uniform mat4 gbufferModelViewInverse;
uniform mat4 gbufferProjection;
uniform mat4 gbufferProjectionInverse;
uniform int hideGUI;
uniform vec3 cameraPosition;
uniform float frameTimeCounter;
uniform int frameCounter;
uniform float screenBrightness;
uniform vec3 sunVec;
uniform float aspectRatio;
uniform float sunElevation;
@ -94,6 +99,41 @@ void main() {
vec3 position = mat3(gl_ModelViewMatrix) * vec3(gl_Vertex) + gl_ModelViewMatrix[3].xyz;
// HHHHHHHHH ITS THE JITTER DOF HERE TO SAY HELLO
// It turns out 'position' above is just viewPos lmao
// #ifdef DOF_JITTER_SHADOW
// // CLIP SPACE
// vec2 jitter = clamp(jitter_offsets[frameCounter % 64], -1.0, 1.0);
// jitter = rotate(radians(float(frameCounter))) * jitter;
// jitter.y *= aspectRatio;
// jitter.x *= DOF_ANAMORPHIC_RATIO;
// vec4 clipPos = gbufferProjection * vec4(position, 1.0);
// // CLIP SPACE -> VIEW SPACE
// vec3 viewPos = (gbufferProjectionInverse * clipPos).xyz;
// // Focus distance
// #if DOF_JITTER_FOCUS < 0
// float focusMul = clipPos.z - mix(pow(512.0, screenBrightness), 512.0 * screenBrightness, 0.25);
// #else
// float focusMul = clipPos.z - DOF_JITTER_FOCUS;
// #endif
// // CLIP SPACE -> SHADOW CLIP SPACE
// vec3 jitterViewPos = (gbufferProjectionInverse * vec4(jitter, 1.0, 1.0)).xyz;
// // vec3 jitterFeetPos = (gbufferModelViewInverse * vec4(jitterViewPos, 1.0)).xyz;
// // vec3 jitterShadowViewPos = (shadowModelView * vec4(jitterFeetPos, 1.0)).xyz;
// // vec4 jitterShadowClipPos = gl_ProjectionMatrix * vec4(jitterShadowViewPos, 1.0);
// // vec4 totalOffset = jitterShadowClipPos * JITTER_STRENGTH * focusMul * 1e-2;
// position += jitterViewPos * focusMul * 1e-2;
// if(focusMul < 10.0) {
// gl_Position = vec4(-1.0);
// return;
// }
// #endif
//Check if the vertice is going to cast shadows
// #ifdef SHADOW_FRUSTRUM_CULLING