Add WS3 detailed technique using the "6" slot. Port the ALS haze, lighting, and math parts of the detailed and ultra shaders. The texture lookups are left out.
Shader selection based on terrain quality setting:
- Ultra - ws30-ALS-ultra frag/vert.
- High and Medium - ws30-ALS-detailed frag/vert. The shaders switch code paths based on quality level uniform.
- Low - ws30-ALS frag/vert.
Changelog:
ws30-ALS vertex shaders:
- Ambient colour material colour doesn't seem to be used in the vertex shader, and isn't sent to fragment shaders currently. Regional materials only define non-default ambient colour of vec4(0.0) for water, ocean etc. Otherwise the default value of vec4(0.2, 0.2, 0.2, 1.0) is used.
ws30-ALS.frag:
- Set alpha of color to diffuse_term.a, to be consistent with WS2 implementation.
ws30-ALS-ultra.frag and ws30-ALS-detailed.frag
- World pos is assigned a value to allow noise functions to compile.
- Swatch_size is temporarily set to 2000m instead of the xsize texture dimension to allow noise math to run while landclass search and texture arrays are being looked up. Swatch_size is used to adjust the wavelength of multiple overlay mixing noise wavelengths based on how far the textures are stretched (WiP WS2 feature). There are some noise calculations that could run while the first landclass lookup happens. If this is not enough, the selection of calculated noise wavelengths to add could change based on how far the textures are stretched, instead of changing the wavelengths at calculation time.
- Move photoscenery technique no "4" after technique no "7" without changing the index (in case the low index is needed for photoscenery). This makes viewing a diff with the WS2 effect easier.
Performance: Currently there's only 1 ground texture lookup and landclass transitions for that texture. The ultra shader looks up 5 more textures. Probably transitions for 1 more texture need to be supported, as often a base and overlay texture are mixed contributing heavily to visible colour. The math overhead is mostly present, except for noise math being better hidden than in the eventual version. Some of the texture array lookups in the full version may be hidden by the math - depending on GPU memory handling compared to calculation speed.
Power users looking to profile on different GPUs: the controls and toggles, as well as a guide on how to get accurate results are now in: Shaders/ws30-ALS-landclass-search-functions.frag .
Changelog:
- Move landclass search functions in ws30-ALS-ultra.frag into a shader include: ws30-ALS-landclass-search-functions.frag . These controls should be removed when appropriate.
- 2 development controls to reduce haze and/or lighting are left at the top of ws30-ALS-ultra.frag .
(cherry picked from commit 5196dbd4ebd5f586a7261dc3ae46aa50218caf91)
commit e131ffaca7b2c934474f0e447b5852cb4c7c8d4a
Author: vs <vs2009@mail.com>
Date: Fri Oct 15 22:19:42 2021 +1000
WS30: landclass and texture lookups in fragment shader:
Changelog:
- Testing: Procedural random landclass function, get_random_landclass(). 1). Avoids a texture lookup for profiling. 2). Creates squares of configurable size with controllable random landclass ranges - to test landclass transition algorithms and quickly profile lots of landclasses in view. It's also possible to put pressure on GPU memory even with 1 lookup of ground textures per fragment, by reducing size to <20m and viewing from altitude.
- Add ALS ultra technique as no 5, move existing ALS technique to no. 6. Add WS30-ALS-ultra frag & vert in preparation for eventual ALS ultra port. Change comments/variables to match using a texture array instead of atlas. Sampler name: atlas -> textureArray.
- Testing/optimisation of de-tiling: WS30-ALS.frag: reorder perlin detiling to make noise source easier to switch. WS30-ALS-ultra.frag: Create alternative to perlin noise used for reducing tiling that avoids a texture lookup - to profile and optimise. This is commented out. The performance difference in the final version depends on memory pressure versus arithmetic load of the full shader. It varies by GPU and what's in view. In future, once a full ALS port is done, maybe it'll be more efficient to run a higher quality de-tiling algorithm all the time to avoid branching overhead due to effects like agriculture which need more de-tiling. De-tiling code in shaders should /eventually/ match CPU-side de-tiling of texture masks used for object and vegetation placement. De-tiling code in GPUs might be subject to precision and numerical artifacts, and if so maybe the texture lookup version would work better. The same applies to noise used for rendering WS3 water waves and collision queries. One option is to use exactly the same glsl code, with a C++ header to convert glsl syntax e.g. https://github.com/g-truc/glm .
The light sprite diminished to zero size as the FOV was decreased
(in sim zoom), and increased considerably as the FOV was increased.
This commit fixed this by taking the FOV into account to keep the light
sprite size roughly constant across the valid FOV range.
- model-combined-transparent is deprecated.
- model-transparent can be used to let some rendering pipelines know that
an object is transparent.
- In the case of Classic, model-transparent just inherits from model-default
and the object is rendered normally.
- The G-Buffer layout has been redesigned to be 96 bits per pixel. There are 24
unused bits that can be used for extra material parameters later (like
clearcoat).
- Add better debug views for the G-Buffer.
- Use octahedron normal encoding. This yields the same results as the previous
method but uses 16 bits less.
- Use rg11fb10f for the environment mapping cubemaps.
- Tweak the shadow mapping parameters and add a colored debug mode.
- Only render shadow maps for objects that inherit from model-default.eff or
model-pbr.eff instead of having a fallback Effect. Now transparent objects
should be ignored (if they are marked as such with model-transparent or
similar).
- Remove the separate occlusion texture. Now the PBR Effect expects a single
texture where R=occlusion, G=roughness and B=metallic.
- Add an utility linearizeDepth function to help visualize the depth buffer for debug purposes.
- Use 'color0' instead of 'color' for all color attachments.
- Do not write to the HDR buffer if a fragment doesn't need shading (depth = 1).
- water.eff: technique 2: air_pollution uniform is not used by water-ALS-base.frag
- water.eff: ocean_flag is now a parameter
- water-inland.eff now inherits from water.eff as it's a copy, except for ocean_flag value