Read the buildings and props a map places from its compiled art (the uncompressed worldbuilder stream + embedded DDS textures): - ra3.models: BAB asset-stream parser (lazy slices), W3DMesh + D3DHierarchy decode, DDS (DXT1/3/5 + uncompressed) decode, per-mesh bone remap and bind-pose single-joint skinning, flattened to one world-space triangle soup. - ra3.map: parse the ObjectsList chunk into (type, x, y, z, angle). - ra3.terrain: render3d rasterises the scene over the raymarched terrain with a z-buffer; gpu_terrain carries the scene for the GPU backends. - ra3.vulkan: second pipeline + depth attachment, terrain.frag writes gl_FragDepth, and a small depth bias keeps ground decals from z-fighting. - objects.fx shaders (compiled to SPIR-V), embedded like scene/terrain. Only opaque parts are drawn: FX-light billboards (DefaultW3D.fx / BasicW3D.fx) and damage-fill shells (BuildingsGenericDamageFill.fx) are skipped, since the latter paint the wrecked interior (e.g. orange CBBuilding_Wood) over the shell. Ground-decal meshes with no diffuse role and the Road templates themselves are still not drawn.
37 lines
1.1 KiB
GLSL
37 lines
1.1 KiB
GLSL
#version 450
|
|
|
|
// Static-map model fragment stage: sample the shared texture array and apply
|
|
// the same directional sun the terrain uses. Cut-out props (trees, fences)
|
|
// carry an alpha mask in their diffuse texture; discard the transparent texels
|
|
// so the ground shows through.
|
|
|
|
layout(binding = 0) uniform sampler2DArray atlas;
|
|
|
|
layout(push_constant) uniform Push {
|
|
vec4 cam_pos;
|
|
vec4 fwd;
|
|
vec4 right;
|
|
vec4 up;
|
|
vec4 sun;
|
|
} pc;
|
|
|
|
layout(location = 0) in vec2 in_uv;
|
|
layout(location = 1) in vec3 in_normal;
|
|
layout(location = 2) flat in float in_layer;
|
|
|
|
layout(location = 0) out vec4 out_color;
|
|
|
|
void main() {
|
|
int layers = textureSize(atlas, 0).z;
|
|
int layer = clamp(int(in_layer + 0.5), 0, layers - 1);
|
|
vec4 tex = texture(atlas, vec3(in_uv, float(layer)));
|
|
if (tex.a < 0.5) discard;
|
|
|
|
vec3 n = normalize(in_normal);
|
|
if (!gl_FrontFacing) n = -n;
|
|
float lambert = max(0.0, dot(n, normalize(pc.sun.xyz)));
|
|
float ambient = pc.sun.w;
|
|
vec3 lit = tex.rgb * (ambient + (1.0 - ambient) * lambert);
|
|
out_color = vec4(lit, 1.0);
|
|
}
|