uhhh?????

This commit is contained in:
2025-11-07 01:21:11 +01:00
parent cc5001bbc6
commit 3e9afeeffa
+9 -55
View File
@@ -5,8 +5,6 @@
#include "include.glsl"
#include "implicit_include.glsl"
#define tau 6.28318530717958647692
layout(location = 0) in vec2 v_pos;
layout(input_attachment_index = 0, set = 2, binding = 0) uniform usubpassInput u_material;
@@ -52,60 +50,18 @@ vec3 getBiTangent(vec3 n, vec3 t) {
return normalize(cross(n, t));
}
uvec4 hash;
uvec4 pcg4d(uvec4 v) {
v = v * 1664525u + 1013904223u;
v.x += v.y * v.w;
v.y += v.z * v.x;
v.z += v.x * v.y;
v.w += v.y * v.z;
v ^= v >> 16u;
v.x += v.y * v.w;
v.y += v.z * v.x;
v.z += v.x * v.y;
v.w += v.y * v.z;
return v;
}
// Construct a float with half-open range [0:1] using low 23 bits.
// All zeroes yields 0.0, all ones yields the next smallest representable value below 1.0.
float floatConstruct(uint m) {
const uint ieeeMantissa = 0x007FFFFFu; // binary32 mantissa bitmask
const uint ieeeOne = 0x3F800000u; // 1.0 in IEEE binary32
m &= ieeeMantissa; // Keep only mantissa bits (fractional part)
m |= ieeeOne; // Add fractional part to 1.0
float f = uintBitsToFloat(m); // Range [1:2]
return f - 1.0; // Range [0:1]
}
vec3 getPointOnSphere(vec2 rv) {
float a = tau * rv.x;
float b = 2.0 * rv.y - 1.0;
float c = sqrt(1.0 - b * b);
vec3 h = vec3(c * cos(a), b, c * sin(a));
return h;
}
const float AO_INTENSITY = 0.1;
const float AO_STEP = 0.02;
const float AO_INSTENSITY = 0.1;
const float AO_STEP = 0.01;
const uint AO_MAX_ITER = 10;
float getOcclusion(vec3 p, vec3 n) {
float ao = 0.0;
//for (uint i = 1; i < AO_MAX_ITER; i++) {
// hash = pcg4d(hash);
// vec3 point = getPointOnSphere(vec2(floatConstruct(hash.x), floatConstruct(hash.y))) * AO_STEP;
// float dist = dot(point, n);
// if (dist < 0) {
// dist = abs(dist);
// point += n * dist * 2.0;
// }
// ao += max((dist - scene(vec4(p + point, camera_uniforms.campos_and_time.w))) / dist, 0.0);
//}
return 1.0 - ao * AO_INTENSITY;
float dist;
for (uint i = 1; i < AO_MAX_ITER; i++) {
dist = AO_STEP * i;
ao += max((dist - scene(vec4(p + n * dist, camera_uniforms.campos_and_time.w))) / dist, 0.0);
}
return 1.0 - ao * AO_INSTENSITY;
}
//Implicit Surface Entrypoint
@@ -114,8 +70,6 @@ void main() {
discard;
}
//hash = uvec4(v_pos.x * 374799253, v_pos.y * 615653626, camera_uniforms.campos_and_time.w * 626228781, 713668633);
float depth = subpassLoad(u_depth).x;
if (depth == 1.0) {
discard;
@@ -124,7 +78,7 @@ void main() {
vec3 n = getNormal(position);
f_color = vec4(object_uniforms.colour, 1.0);
f_color = vec4(1.0);
f_ao_r_m.y = object_uniforms.roughness;
f_ao_r_m.z = object_uniforms.metallic;