feat(render): SAGE water/ocean shaders, per-user logs, camera & culling
Terrain pass now ports the SAGE water model (Ocean.fx / OpenSAGE Water.frag): a de-gridded procedural wave normal combined with the retail ra3_deepocean flow and ra3_deepocean_nrm bump maps (appended as the last two terrain-atlas layers, no new backend binding), Schlick fresnel, sky reflection + depth-graded refraction, SAGE diffuse/specular lighting, depth-based transparency, and an underwater tint (UnderwaterDeferred.fx). Mirrored across terrain.frag / dx_terrain.hlsl / webgl_terrain_frag.glsl / webgpu_terrain.wgsl. Also: logs move to the per-user state dir (%LOCALAPPDATA%\\OpenRA3\\logs, else XDG) and archive as openra3.<stamp>.log; the FPS label shows the active backend; middle-drag camera reset; objects and roads below the water plane are culled.
This commit is contained in:
@@ -324,6 +324,48 @@ vertex color and `TintColor`; `basicw3d.fxo` instead modulates a single
|
||||
macro/lightmap with `(vertexColor + additive) * diffuse * 2` and has no normal
|
||||
map. (Recovered by disassembling the embedded `vs_3_0`/`ps_3_0` bytecode.)
|
||||
|
||||
### Water / ocean (`Ocean.fx`, `OceanDisplacement.fx`, `RiverWater.fx`, `UnderwaterDeferred.fx`)
|
||||
|
||||
The SAGE water surface is reconstructed by OpenSAGE as
|
||||
`Assets/Shaders/Water.vert`+`Water.frag` (same family as retail `Ocean.fx`). The
|
||||
surface is a world-space mesh drawn with alpha blending, fed by two render
|
||||
targets rendered before it: a **reflection** map (scene from the mirrored camera
|
||||
about `GlobalWaterSettings.ReflectionPlaneZ`) and a **refraction** map + depth.
|
||||
The fragment model (`Water.frag`) is:
|
||||
|
||||
- `waterUV = worldPos.xy / 320`; a scrolling `WaterTexture` supplies both a
|
||||
flow distortion (`(tex.xy*2-1)*0.05`) and the flow layer; a `BumpTexture`
|
||||
supplies the surface `worldNormal`.
|
||||
- `fresnelFactor = dot(viewVector, +Z)`; reflection/refraction are sampled in
|
||||
screen space (`gl_FragCoord / ViewportSize`), each displaced by the distortion.
|
||||
- `linearWaterDepth = linearize(RefractionDepth) - linearize(gl_FragCoord.z)`;
|
||||
`alpha = clamp((linearWaterDepth/2)/TransparentWaterDepth, 0, TransparentWaterMinOpacity)`.
|
||||
- `final = diffuseColor * textureColor * cloudColor`, then mixed with
|
||||
`mix(reflectionColor, refractionColor, fresnelFactor)` (both maps on) or just
|
||||
one of them, per `IsRenderReflection` / `IsRenderRefraction`.
|
||||
- Per-time-of-day `WaterSet`: `WaterTexture`, `UScrollPerMS`/`VScrollPerMS`,
|
||||
`DiffuseColor`, `TransparentDiffuseColor`; `WaterTransparency` supplies
|
||||
`TransparentWaterDepth`/`TransparentWaterMinOpacity`, the skybox faces,
|
||||
`RiverTransparencyMultiplier`, `ReflectionPlaneZ`/`ReflectionOn`.
|
||||
|
||||
OpenRA3 has no water mesh or reflection/refraction targets (its terrain is
|
||||
raymarched), so the model is folded into the terrain pass (`shaders/terrain.frag`
|
||||
and its HLSL/GLSL-ES/WGSL twins): the ray's water-plane hit takes a scrolling
|
||||
wave normal built from the retail bump map combined with a de-gridded procedural
|
||||
wave, Schlick fresnel (F0 = 0.02), a sky reflection and a depth-graded
|
||||
refraction, SAGE diffuse + specular lighting, a depth-based transparency fade,
|
||||
and — when the camera is below `ReflectionPlaneZ` — an underwater tint/fog
|
||||
(`UnderwaterDeferred.fx`). The two retail maps
|
||||
`art/terrain/ra3_deepocean.tga` (flow/distortion) and `ra3_deepocean_nrm.tga`
|
||||
(bump normal) are appended as the **last two layers of the terrain atlas**
|
||||
(`ra3::terrain::build_gpu_terrain`, `water_flow = layer_count - 2`,
|
||||
`water_normal = layer_count - 1`), so every backend samples them with the
|
||||
existing atlas binding; absent maps fall back to a neutral layer. True
|
||||
reflection/refraction render targets are still the next step.
|
||||
`GPUParticleOceanDisplacement.fx` drives wave displacement from a GPU particle
|
||||
buffer and has no analogue here.
|
||||
|
||||
|
||||
The map's `ObjectsList` chunk is a list of nested `Object` assets —
|
||||
`Coord3D`, Z `angle`, `RoadType` u32, a `u16`-prefixed type-name and a property
|
||||
list whose keys index the shared name table (`ra3.map::parse_objects`). Each
|
||||
|
||||
Reference in New Issue
Block a user