mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-04-17 17:43:52 +00:00
Add normal mapping and parallax occlusion mapping for WMO surfaces
Generate normal+height maps from diffuse textures at load time using luminance-to-height and Sobel 3x3 filtering. Compute per-vertex tangents via Lengyel's method for TBN basis construction. Fragment shader uses screen-space UV derivatives (dFdx/dFdy) for smooth LOD crossfade and angle-adaptive POM sample counts. Flat textures naturally produce low height variance, causing POM to self-select off. Settings: Normal Mapping on by default, POM off by default with Low/Medium/High quality presets. Persisted across sessions.
This commit is contained in:
parent
1b16bcf71f
commit
eaceb58e77
8 changed files with 424 additions and 33 deletions
|
|
@ -21,17 +21,33 @@ layout(location = 0) in vec3 aPos;
|
|||
layout(location = 1) in vec3 aNormal;
|
||||
layout(location = 2) in vec2 aTexCoord;
|
||||
layout(location = 3) in vec4 aColor;
|
||||
layout(location = 4) in vec4 aTangent;
|
||||
|
||||
layout(location = 0) out vec3 FragPos;
|
||||
layout(location = 1) out vec3 Normal;
|
||||
layout(location = 2) out vec2 TexCoord;
|
||||
layout(location = 3) out vec4 VertColor;
|
||||
layout(location = 4) out vec3 Tangent;
|
||||
layout(location = 5) out vec3 Bitangent;
|
||||
|
||||
void main() {
|
||||
vec4 worldPos = push.model * vec4(aPos, 1.0);
|
||||
FragPos = worldPos.xyz;
|
||||
Normal = mat3(push.model) * aNormal;
|
||||
|
||||
mat3 normalMatrix = mat3(push.model);
|
||||
Normal = normalMatrix * aNormal;
|
||||
TexCoord = aTexCoord;
|
||||
VertColor = aColor;
|
||||
|
||||
// Compute TBN basis vectors for normal mapping
|
||||
vec3 T = normalize(normalMatrix * aTangent.xyz);
|
||||
vec3 N = normalize(Normal);
|
||||
// Gram-Schmidt re-orthogonalize
|
||||
T = normalize(T - dot(T, N) * N);
|
||||
vec3 B = cross(N, T) * aTangent.w;
|
||||
|
||||
Tangent = T;
|
||||
Bitangent = B;
|
||||
|
||||
gl_Position = projection * view * worldPos;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue