-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #126 from Themaister/meshlet-cull
Iterate further on meshlet encoding scheme
- Loading branch information
Showing
37 changed files
with
3,184 additions
and
1,715 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,33 @@ | ||
#ifndef MESHLET_ATTRIBUTE_DECODE_H_ | ||
#define MESHLET_ATTRIBUTE_DECODE_H_ | ||
|
||
vec3 attribute_decode_snorm_exp_position(uvec2 payload) | ||
vec3 attribute_decode_snorm_exp_position(i16vec3 payload, int exponent) | ||
{ | ||
ivec3 sint_value = ivec3( | ||
bitfieldExtract(int(payload.x), 0, 16), | ||
bitfieldExtract(int(payload.x), 16, 16), | ||
bitfieldExtract(int(payload.y), 0, 16)); | ||
int exp = bitfieldExtract(int(payload.y), 16, 16); | ||
return vec3( | ||
ldexp(float(sint_value.x), exp), | ||
ldexp(float(sint_value.y), exp), | ||
ldexp(float(sint_value.z), exp)); | ||
vec3 fp_pos = ldexp(vec3(payload), ivec3(exponent)); | ||
return fp_pos; | ||
} | ||
|
||
vec2 attribute_decode_snorm_exp_uv(uvec2 payload) | ||
vec2 attribute_decode_snorm_exp_uv(i16vec2 payload, int exponent) | ||
{ | ||
ivec2 sint_value = ivec2( | ||
bitfieldExtract(int(payload.x), 0, 16), | ||
bitfieldExtract(int(payload.x), 16, 16)); | ||
int exp = bitfieldExtract(int(payload.y), 0, 16); | ||
return 0.5 * vec2( | ||
ldexp(float(sint_value.x), exp), | ||
ldexp(float(sint_value.y), exp)) + 0.5; | ||
return 0.5 * ldexp(vec2(payload), ivec2(exponent)) + 0.5; | ||
} | ||
|
||
// Adapted from: https://knarkowicz.wordpress.com/2014/04/16/octahedron-normal-vector-encoding/ | ||
// https://twitter.com/Stubbesaurus/status/9379947905532272640 | ||
mediump vec4 attribute_decode_oct8_normal_tangent(uint payload) | ||
mediump vec3 attribute_decode_oct_normal(mediump vec2 f) | ||
{ | ||
mediump vec4 f = unpackSnorm4x8(payload); | ||
mediump vec3 n = vec3(f.x, f.y, 1.0 - abs(f.x) - abs(f.y)); | ||
mediump float t = max(-n.z, 0.0); | ||
n.xy += mix(vec2(t), vec2(-t), greaterThanEqual(n.xy, vec2(0.0))); | ||
return vec4(normalize(n), f.w != 0.0 ? -1.0 : 1.0); | ||
return normalize(n); | ||
} | ||
|
||
// Adapted from: https://knarkowicz.wordpress.com/2014/04/16/octahedron-normal-vector-encoding/ | ||
// https://twitter.com/Stubbesaurus/status/9379947905532272640 | ||
mediump mat2x4 attribute_decode_oct8_normal_tangent(u8vec4 payload, bool t_sign) | ||
{ | ||
mediump vec4 f = vec4(i8vec4(payload)) / 127.0; | ||
mediump vec3 N = attribute_decode_oct_normal(f.xy); | ||
mediump vec3 T = attribute_decode_oct_normal(f.zw); | ||
return mat2x4(vec4(N, 0.0), vec4(T, t_sign ? -1.0 : 1.0)); | ||
} | ||
|
||
#endif | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.