mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-01 02:19:05 +01:00
WIP: TIN terrain system - 95% complete
Replaces heightfield with Cesium Quantized Mesh format (TIN).
Full replacement, not hybrid - TIN is the only terrain format.
Implemented:
- Format: quantizedmeshformat.h, quantizedmeshreader.h
- Triangulator: terraincooker_tin.{h,cpp} using CDT
- Cooker: terraincook now generates TIN by default
- Loader: terraintileloader fully rewritten for TIN
- GPU pool: terraintilepool_tin (VBO/IBO per tile)
- Renderer interface: terrainclipmap.cppm updated
- Shaders: terrainclipmap_tin.{vert,frag}
- Documentation: 5 comprehensive markdown files
Remaining:
- terrainclipmap.cpp render() method (partial, needs completion)
- Build testing and integration
- See TIN_INTEGRATION_GUIDE.md for next steps
Stats: 2700+ lines new code, ~50% vertex reduction expected
This commit is contained in:
23
shaders/terrainclipmap_tin.frag
Normal file
23
shaders/terrainclipmap_tin.frag
Normal file
@@ -0,0 +1,23 @@
|
||||
// TIN Terrain Fragment Shader
|
||||
// Minimal material lookup, no blending for now
|
||||
|
||||
#version 330 core
|
||||
|
||||
// Input from vertex shader
|
||||
in vec2 vUV;
|
||||
flat in uint vMaterial;
|
||||
|
||||
// Uniforms
|
||||
uniform sampler2DArray ground; // Material texture array
|
||||
|
||||
// Output
|
||||
out vec4 fragColor;
|
||||
|
||||
void main() {
|
||||
// Sample material texture
|
||||
// TODO: Add blending between materials for smooth transitions
|
||||
vec3 texCoord = vec3(vUV, float(vMaterial));
|
||||
vec4 color = texture(ground, texCoord);
|
||||
|
||||
fragColor = color;
|
||||
}
|
||||
30
shaders/terrainclipmap_tin.vert
Normal file
30
shaders/terrainclipmap_tin.vert
Normal file
@@ -0,0 +1,30 @@
|
||||
// TIN Terrain Vertex Shader
|
||||
// Replaces texture-based heightfield with vertex attributes
|
||||
|
||||
#version 330 core
|
||||
|
||||
// Vertex attributes from VBO
|
||||
layout(location = 0) in vec3 aPosition; // Relative to tile origin
|
||||
layout(location = 1) in vec2 aUV;
|
||||
layout(location = 2) in uint aMaterial;
|
||||
|
||||
// Uniforms
|
||||
uniform vec3 tile_offset; // Tile origin relative to camera
|
||||
uniform mat4 projectionMatrix;
|
||||
uniform mat4 modelViewMatrix;
|
||||
|
||||
// Output to fragment shader
|
||||
out vec2 vUV;
|
||||
flat out uint vMaterial;
|
||||
|
||||
void main() {
|
||||
// Position is tile-relative, add offset to get camera-relative
|
||||
vec3 worldPos = aPosition + tile_offset;
|
||||
|
||||
// Transform to clip space
|
||||
gl_Position = projectionMatrix * modelViewMatrix * vec4(worldPos, 1.0);
|
||||
|
||||
// Pass through to fragment shader
|
||||
vUV = aUV;
|
||||
vMaterial = aMaterial;
|
||||
}
|
||||
Reference in New Issue
Block a user