mirror of
https://github.com/storytold/spark.git
synced 2026-10-13 23:52:44 +00:00
Working prototype. Initialization not consistent.
This commit is contained in:
committed by
Andreas Sundquist
parent
df6b1d8f4a
commit
d707f283f5
@@ -28,6 +28,7 @@ out vec4 fragColor;
|
||||
in vec4 vRgba;
|
||||
in vec2 vSplatUv;
|
||||
in vec3 vNdc;
|
||||
flat in uint vSplatIndex;
|
||||
|
||||
void main() {
|
||||
vec4 rgba = vRgba;
|
||||
@@ -72,18 +73,16 @@ void main() {
|
||||
}
|
||||
|
||||
if (stochastic) {
|
||||
uint uTime = floatBitsToUint(time);
|
||||
const bool STEADY = false;
|
||||
uint uTime = STEADY ? 0u : floatBitsToUint(time);
|
||||
uvec2 coord = uvec2(gl_FragCoord.xy);
|
||||
uint state = uTime + 0x9e3779b9u * coord.x + 0x85ebca6bu * coord.y;
|
||||
uint state = uTime + 0x9e3779b9u * coord.x + 0x85ebca6bu * coord.y + 0xc2b2ae35u * uint(vSplatIndex);
|
||||
state = state * 747796405u + 2891336453u;
|
||||
uint hash = ((state >> ((state >> 28u) + 4u)) ^ state) * 277803737u;
|
||||
hash = (hash >> 22u) ^ hash;
|
||||
float rand = float(hash) / 4294967295.0;
|
||||
// rand *= 2.0;
|
||||
float rand = float(hash) / 4294967296.0;
|
||||
if (rand < rgba.a) {
|
||||
fragColor = vec4(rgba.rgb, 1.0);
|
||||
// gl_FragDepth = gl_FragCoord.z;
|
||||
// fragColor = vec4(rgba.r, 0.0, 0.0, 1.0);
|
||||
} else {
|
||||
discard;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ attribute uint splatIndex;
|
||||
out vec4 vRgba;
|
||||
out vec2 vSplatUv;
|
||||
out vec3 vNdc;
|
||||
flat out uint vSplatIndex;
|
||||
|
||||
uniform vec2 renderSize;
|
||||
uniform uint numSplats;
|
||||
@@ -21,6 +22,7 @@ uniform float time;
|
||||
uniform float deltaTime;
|
||||
uniform bool debugFlag;
|
||||
uniform float minAlpha;
|
||||
uniform bool stochastic;
|
||||
uniform bool enable2DGS;
|
||||
uniform float blurAmount;
|
||||
uniform float preBlurAmount;
|
||||
@@ -39,16 +41,25 @@ void main() {
|
||||
if (uint(gl_InstanceID) >= numSplats) {
|
||||
return;
|
||||
}
|
||||
if (splatIndex == 0xffffffffu) {
|
||||
// Special value reserved for "no splat"
|
||||
return;
|
||||
}
|
||||
|
||||
ivec3 texCoord = ivec3(
|
||||
splatIndex & SPLAT_TEX_WIDTH_MASK,
|
||||
(splatIndex >> SPLAT_TEX_WIDTH_BITS) & SPLAT_TEX_HEIGHT_MASK,
|
||||
splatIndex >> SPLAT_TEX_LAYER_BITS
|
||||
);
|
||||
ivec3 texCoord;
|
||||
if (stochastic) {
|
||||
texCoord = ivec3(
|
||||
uint(gl_InstanceID) & SPLAT_TEX_WIDTH_MASK,
|
||||
(uint(gl_InstanceID) >> SPLAT_TEX_WIDTH_BITS) & SPLAT_TEX_HEIGHT_MASK,
|
||||
(uint(gl_InstanceID) >> SPLAT_TEX_LAYER_BITS)
|
||||
);
|
||||
} else {
|
||||
if (splatIndex == 0xffffffffu) {
|
||||
// Special value reserved for "no splat"
|
||||
return;
|
||||
}
|
||||
texCoord = ivec3(
|
||||
splatIndex & SPLAT_TEX_WIDTH_MASK,
|
||||
(splatIndex >> SPLAT_TEX_WIDTH_BITS) & SPLAT_TEX_HEIGHT_MASK,
|
||||
splatIndex >> SPLAT_TEX_LAYER_BITS
|
||||
);
|
||||
}
|
||||
uvec4 packed = texelFetch(packedSplats, texCoord, 0);
|
||||
|
||||
vec3 center, scales;
|
||||
@@ -85,6 +96,9 @@ void main() {
|
||||
return;
|
||||
}
|
||||
|
||||
// Record the splat index for entropy
|
||||
vSplatIndex = splatIndex;
|
||||
|
||||
// Compute view space quaternion of splat
|
||||
vec4 viewQuaternion = quatQuat(renderToViewQuat, quaternion);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user