Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 34 additions & 25 deletions src/components/textures/shaders/pointVertex.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,16 @@ float sample1(vec3 p, int index) { // Shader doesn't support dynamic indexing so
else return 0.0;
}

bool boundsCheck(vec3 loc) {
vec3 scaledLoc = loc * 2.0 - 1.0; // scales texCoords/UV from [0 ,1] to [-1 - 1] of the sliders

bool xCheck = scaledLoc.x < flatBounds.x || scaledLoc.x > flatBounds.y;
bool yCheck = scaledLoc.y < vertBounds.x || scaledLoc.y > vertBounds.y;
bool zCheck = scaledLoc.z < flatBounds.z || scaledLoc.z > flatBounds.w;

return (xCheck || zCheck || yCheck);
}
Comment thread
TheJeran marked this conversation as resolved.

void main() {
vec3 texCoord = computeTexCoord(vertexIdx);
if (maskValue != 0 ){ // If using a mask, quick check if vertex is masked out before doing additional rendering
Expand All @@ -82,6 +92,24 @@ void main() {
return;
}
}
#ifdef REPROJECT
vec2 remap = texture(remapTexture, texCoord.xy).rg;
vec3 newCoord = vec3(remap, texCoord.z);
if (boundsCheck(newCoord)){
gl_Position = vec4(2.0, 2.0, 2.0, 1.0);
return;
}
vec3 position = givePosition(newCoord);
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
Comment thread
TheJeran marked this conversation as resolved.
#else
if (boundsCheck(texCoord)){
gl_Position = vec4(2.0, 2.0, 2.0, 1.0);
return;
}
vec3 position = givePosition(texCoord);
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
#endif

int zStepSize = int(textureDepths.y) * int(textureDepths.x);
int yStepSize = int(textureDepths.x);

Expand All @@ -92,41 +120,22 @@ void main() {
localCoord = fract(localCoord);
vValue = sample1(localCoord, textureIdx);

#ifdef REPROJECT
vec2 remap = texture(remapTexture, texCoord.xy).rg;
vec3 position = givePosition(vec3(remap, texCoord.z));
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
#else
vec3 position = givePosition(texCoord);
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
#endif

bool fillCheck = abs(vValue - fillValue) < 0.005;
if (vValue < valueRange.x || vValue > valueRange.y || fillCheck){ //Hide points that are outside of value range
gl_Position = vec4(2.0, 2.0, 2.0, 1.0);
return;
}
#ifndef NO_SCALE
float pointScale = pointSize/gl_Position.w;
pointScale = scalePoints ? pointScale*pow(vValue,scaleIntensity) : pointScale;

if (vValue == 1. || (pointScale*gl_Position.w < 0.75 && scalePoints)){ //Hide points that are invisible or get too small when scaled
gl_Position = vec4(2.0, 2.0, 2.0, 1.0);
return;
}
gl_PointSize = pointScale;
#else
gl_PointSize = 1.;
#endif
if (vValue < valueRange.x || vValue > valueRange.y){ //Hide points that are outside of value range
gl_Position = vec4(2.0, 2.0, 2.0, 1.0);
}

vec2 scaledXBounds = vec2(flatBounds.x, flatBounds.y) / 2. + 0.5; // Scale from [-1, 1] to [0, 1] to match texCoords
vec2 scaledZBounds = vec2(flatBounds.z, flatBounds.w) / 2. + 0.5;
vec2 scaledYBounds = vec2(vertBounds.x, vertBounds.y) / 2. + 0.5;

bool xCheck = texCoord.x < scaledXBounds.x || texCoord.x > scaledXBounds.y;
bool zCheck = texCoord.z < scaledZBounds.x || texCoord.z > scaledZBounds.y;
bool yCheck = texCoord.y < scaledYBounds.x || texCoord.y > scaledYBounds.y;
bool fillCheck = abs(vValue - fillValue) < 0.005;

if (xCheck || zCheck || yCheck || fillCheck){ //Hide points that are clipped
gl_Position = vec4(2.0, 2.0, 2.0, 1.0);
}

}
Loading