Skip to content

Commit

Permalink
refacto(points): remove compressed normal support in material
Browse files Browse the repository at this point in the history
  • Loading branch information
Desplandis committed Jul 9, 2024
1 parent 6e20fcb commit 24b3641
Showing 1 changed file with 0 additions and 47 deletions.
47 changes: 0 additions & 47 deletions src/Renderer/Shader/PointsVS.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -37,57 +37,10 @@ attribute float returnNumber;
attribute float numberOfReturns;
attribute float scanAngle;

#if defined(NORMAL_OCT16)
attribute vec2 oct16Normal;
#elif defined(NORMAL_SPHEREMAPPED)
attribute vec2 sphereMappedNormal;
#endif

varying vec4 vColor;

// see https://web.archive.org/web/20150303053317/http://lgdv.cs.fau.de/get/1602
// and implementation in PotreeConverter (BINPointReader.cpp) and potree (BinaryDecoderWorker.js)
#if defined(NORMAL_OCT16)
vec3 decodeOct16Normal(vec2 encodedNormal) {
vec2 nNorm = 2. * (encodedNormal / 255.) - 1.;
vec3 n;
n.z = 1. - abs(nNorm.x) - abs(nNorm.y);
if (n.z >= 0.) {
n.x = nNorm.x;
n.y = nNorm.y;
} else {
n.x = sign(nNorm.x) - sign(nNorm.x) * sign(nNorm.y) * nNorm.y;
n.y = sign(nNorm.y) - sign(nNorm.y) * sign(nNorm.x) * nNorm.x;
}
return normalize(n);
}
#elif defined(NORMAL_SPHEREMAPPED)
// see http://aras-p.info/texts/CompactNormalStorage.html method #4
// or see potree's implementation in BINPointReader.cpp
vec3 decodeSphereMappedNormal(vec2 encodedNormal) {
vec2 fenc = 2. * encodedNormal / 255. - 1.;
float f = dot(fenc,fenc);
float g = 2. * sqrt(1. - f);
vec3 n;
n.xy = fenc * g;
n.z = 1. - 2. * f;
return n;
}
#endif

void main() {

#if defined(NORMAL_OCT16)
vec3 normal = decodeOct16Normal(oct16Normal);
#elif defined(NORMAL_SPHEREMAPPED)
vec3 normal = decodeSphereMappedNormal(sphereMappedNormal);
#elif defined(NORMAL)
// nothing to do
#else
// default to color
vec3 normal = color;
#endif

if (picking) {
vColor = unique_id;
} else {
Expand Down

0 comments on commit 24b3641

Please sign in to comment.