Skip to content

Commit 364cf7c

Browse files
committed
Use sign function
1 parent a6de40c commit 364cf7c

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

src/shader-chunks/shaders/normal-codec-pars.frag

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,10 @@
55
* @see https://aras-p.info/texts/CompactNormalStorage.html
66
*/
77

8-
vec2 pp_octWrap(vec2 v) {
9-
10-
return (1.0 - abs(v.yx)) * vec2(v.x >= 0.0 ? 1.0 : -1.0, v.y >= 0.0 ? 1.0 : -1.0);
11-
12-
}
13-
148
vec2 pp_encodeNormal(vec3 n) {
159

1610
n /= (abs(n.x) + abs(n.y) + abs(n.z));
17-
n.xy = (n.z >= 0.0) ? n.xy : pp_octWrap(n.xy);
11+
n.xy = (n.z >= 0.0) ? n.xy : (1.0 - abs(n.yx)) * sign(n.xy);
1812
return n.xy;
1913

2014
}

0 commit comments

Comments
 (0)