1
0
Fork 0
Commit graph

684 commits

Author SHA1 Message Date
James Turner
2d17217a01 Marker-pins FGData changes
From Tobias Dammers
2022-01-27 12:11:24 +00:00
Stuart Buchanan
1bd128bb63 WS30: Clean-up of the WS30 ALS Ultra shader 2022-01-23 15:21:56 +00:00
Stuart Buchanan
49b1b83be2 WS30: Better edge-hardness implementation 2022-01-22 15:48:02 +00:00
Stuart Buchanan
1d76ced7c7 WS30: Fix snow on ALS detailed level (again?) 2022-01-20 22:24:30 +00:00
Stuart Buchanan
4564b30eac WS30: Separate out haze calculations
Previously haze calculations were performed
in the main body of the ws30 shaders (inherited
from the ALS terrain shaders).  This change creates
a common applyHaze function to consistently apply haze.

This is not ws30 specific, and could be used to replace the
haze calculations of all ALS shaders for improved consistency.
2022-01-18 21:13:29 +00:00
Stuart Buchanan
d8110f0b38 WS30: Shader refactoring: common get_material func 2022-01-18 16:57:39 +00:00
Stuart Buchanan
68df0191c0 WS30: add edge-hardness parameter for landclass transitions
Also new use_edge_hardness_with_large_scale_transition const
for testing
2022-01-15 15:04:54 +00:00
Stuart Buchanan
b35f5d6db2 WS30: Road Shader porting from osm2city 2022-01-12 21:32:55 +00:00
Stuart Buchanan
3261f4a97c WS30: MR #267: Improved texture lookups from VS
Squashed commit of the following:

commit 115511888c20c53670eba17a82c81c9af99d7302
Author: vs <vs2009@mail.com>
Date:   Mon Dec 6 18:52:06 2021 +1000

    WS30 effects and shaders:

    Changelog:

    ws30-ALS-ultra.frag:

    - Ground textures lookups use their own coordinates separate from the landclass  texture lookup.

    - Partial derivatives dFdx and Dfdy are packed together in a vec4, so simple   multiplication to scale can be done in 1 instruction. dFdx = s and t components. dFdy  = p and q components. These must be scaled properly for ground texture access as ground  texture stretching and detiling of tex coords mean textures are scaled differently.

    - Added calculation of partial derivatives for texture coordinates used by the 5 non- base textures. dFdx() and dFdy() were called for nontrivial texture coordinate manipulation.

    - New control randomise_texture_lookups added at top of ws30-ALS-ultra.frag, in the  development tools section. Setting this to 1 will do a stress test of ground texture  array lookups. A fast random number generation function is used to assign each  landclass 4 random textures from the ground texture array - this is done by .  Performance will not be as bad in the full ALS port as some texture slots will better caching in memory - e.g. have 1 or a few variants.

    - Possible optimisation: use a 2nd or 3rd texture array for some of the non-base  texture slots that typically have 256, 512, or 1024 textures. The resolutions of these  arrays should change based on the largest loaded texture size in the active regional  definitions - this will allow taking full advantage of smaller texture sizes in some  areas. The disadvantage is some texture duplication with more slots.

    - Possible optimisation: offer the option to shrink textures by 50% or 25% - for  texture slots that use large textures like base or mix slots.

    - Very temporary - reduce procedural normal map features with photoscenery active  without breaking profiling, as the inputs to shaders are effect defaults or  placeholder (by request on ML).

    ----

    ws30-ALS-ultra.vert:
    - Start of conversion of geocentic world space xyz into lat/lon coords used for ground  texture lookups. Currently commented out as it's unknown what model space coords are  in (not geocentric it seems).

    ws20-ALS-landclass-search-functions.frag:

    - Add control for changing the ground texture array lookup function for debugging in  case old compilers/GPUs have issues. tex_lookup_type: 0: normal( textureGrad(), 1:  textureLod (manual Lod calculation), 2: texture() with no partial derivative  adjustment.

    - New get6_random_integers() will extract 6 limited random values from the full  precision of a 32 bit random value.

    - Old landclass_texel_size_m references are removed since textureSize() is used. There  are no 'const in float' arguments that may cause issues on AMD compilers.

    ----

    WS30-overlay effect (Inactive):

    - ws30-overlay.eff (derived from terrain-overlay.eff). Technique no "4" is used for two passes. The 1st pass is a copy of the ALS ultra pass (technique no "5") from ws30.eff.  The 2nd pass is the same as terrain-overlay.eff. The 2nd pass uses terrain- overlay.frag from WS2.

    - grass-ALS.vert copied to ws30-ovelay-ALS.vert. To do: needs texture coords that  don't change with tiles.

    - terrain-overlay-ALS.geom copied to ws30-overlay-ALS.geom. To do: uses gl_PositionIn [i].xy for position in the horizontal plane - assumes z is vertical. Tile model space  doesn't seem to match this.

    - WS3 doesn't seem to have a way of switching references to terrain-overlay.eff (which  inherits from terrain-default.eff) to the new ws3-overlay.eff (which needs to inherit  from ws30.eff). The ws3-overlay.eff included /might/ just work without any other changes: the first pass is the WS3 als ultra settings pass, and the second overlay pass is unchanged from WS2 (the same terrain overlay shaders should probably work apart from texcoords and rawpos not being correct).

    - Materials/base/materials-base.xml: ws30Road material: uncomment line declaring terrain-default as the effect. The target effect for ws30 roads is road-*.eff and it's added to ws30Road and ws30Freeway but commented out as it's not working currently.

    - Misc: large scale transitions are turned on in ws30-ALS-landclass-search-functions.frag by default. Grow landclass borders with large scale transitions is now on by default.

    ----

    Changes after the multi-texture support commit:

    ws30-ALS-ultra.vert

    - Added documentation: WS30 model space and z up space - for future people working on WS30, and people looking through shaders to rule out possibilities e.g. when fixing bugs, or interpreting visual bug reports.

    ws30-ALS-landclass-search-functions.frag:

    - For now, lookup_ground_texture_array() also looks up the relevant texture's index  based on an integer.

    - Add get_mixed_texel() - looks up texel for this fragment and any neighbors before mixing. Moves currently shared mixing code out of 3 fragment shaders.

    Misc: changed indentation from mixed tabs/spaces to spaces in ws30-ALS-ultra frag and vert. The indentation can be changed again when the porting is complete.

    ws30-ALS vert/frag and ws30-ALS-detailed vert/frag:

    - Add varying for ground texture coordiante, currently set to gl_TexCoord[0]. Apply texture stretching dimensions in fragment shaders.

    - Misc: varying rawPos is set to vec2 for now, as relPos.z+eye_alt might be faster. Misc: keep WS2 mixing logic for now , including turning off mixing via the alpha channel of the textures

    ----

    Changes after sending material parameters in uniform arrays commit:

    - Materials parameter for rock_strata is cast into an int so rock_strata==1 should work. Misc: Left over uniform for rock strata cleaned up.

    - ws30-ALS-ultra.frag and ws30-ALS-detailed.frag: Add missing mat_shininess for photoscenery case .
2022-01-03 15:43:29 +00:00
Erik Hofman
d240a9b138 Improved frozen-lake texture without snow 2021-12-25 10:55:09 +01:00
Erik Hofman
a36a7c96ac Make a distinction between ocean and non-ocean, for which a flag was already available, when animating moving ice-texures. 2021-12-23 14:50:26 +01:00
Erik Hofman
b43a04895c Prevent water ice-textures from moving around. 2021-12-23 14:22:48 +01:00
Stuart Buchanan
6a917a68b3 WS30: Revert to green channel for texture atlas 2021-12-18 21:55:17 +00:00
Stuart Buchanan
eaf03b6005 Add object shadows to water
commit 918aa4402143638133153dff722ef3a6b4feead7
Author: vs <vs2009@mail.com>
Date:   Sat Nov 20 23:38:52 2021 +1000

    ALS water effect & shaders:

    Add object shadows for water in a similar fashion to terrain.

    Add commented out code of what should be the shader part of clustered lighting for the compositor. getClusteredLightsContribution() normally multiplies the texel by light contributions. It is fed input such that the light contribution term is similar to secondary lights in the water lighting equation, and both are added together.
2021-12-05 14:15:27 +00:00
Stuart Buchanan
dcf8641329 WS30: Full ALS Detailed and Ultra implementation
Including mix, detailed, grain, dot, gradient textures
2021-12-05 13:45:46 +00:00
Stuart Buchanan
d4bd49f5f9 WS30: Multi-texture support, global coordinates
- Use fixed fg_modelOffset for global coordinates.  Fixes haze, snow,
noise
- Use updated texture atlas for mix, deetail, frain, dot, gradient
textures
- Hack transition_model until it is added as Uniform.
2021-11-28 19:31:07 +00:00
Stuart Buchanan
688bbbc167 WS30: Add zUpTransform and modelOffset, fix snow 2021-11-19 22:06:34 +00:00
Stuart Buchanan
d723b0b518 WS30 - Uniform Arrays and lighting model
Use Uniform Arrays instead of Texture1D.

Use ambient/diffuse/specular/shininess material
properties consistently across all WS30 shaders.

Use consistent shading model for photoscenery vs.
landclass to minimize visual difference.
2021-11-10 22:58:44 +00:00
Stuart Buchanan
6b943c5e5c WS30: Photoscenery shaders 2021-11-09 20:27:23 +00:00
vs
64e5abda41 WS30 shaders:
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.
2021-11-10 00:25:09 +10:00
Stuart Buchanan
851f47f576 WS30: Fix errors on AMD 2021-11-07 18:08:49 +00:00
Stuart Buchanan
f53283be12 WS30: Correct orthophoto texture coordinates 2021-11-06 15:29:22 +00:00
vs
78df0cb68c WS30 shaders:
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)
2021-11-06 19:12:04 +10:00
Stuart Buchanan
aaa6c3ff42 WS30: Fix merge markers. 2021-11-05 20:03:51 +00:00
Stuart Buchanan
e5123eeb46 WS30 : terrain shaders from vs
Squashed commit of the following:

commit e7c89ffb600d1bf5cee2936b7dbff31089452745
Author: vs <vs2009@mail.com>
Date:   Fri Nov 5 23:44:35 2021 +1000

    WS30 shaders:

    - WS30-ALS and WS30-ALS-ultra fargment and vertex shaders: Fix NDotL being used before it is initialised. Rename varying diffuse_term from WS2 terrain shaders to light_diffuse_comp as the full diffuse term is not calculated until the fragment shader.
    - WS30-ALS-ultra.frag: Enable haze and lighting by default.

commit 9b55ad051a8d7f3568dfdcd6890655942999e8d0
Author: vs <vs2009@mail.com>
Date:   Wed Nov 3 22:50:29 2021 +1000

    WS30 terrain shaders: ws30-ALS-ultra.frag

    - For power users looking to profile transitions on different GPUs: The test phase toggles and settings for different transition options are available at the start of ws30-ALS-ultra.frag, along with explanations, and how to get accurate profile results on different GPUs. Just need to change a few numbers, save, and debug menu > configure dev extensions > reload shaders to activate.

    - Note: at a minimum, small scale transitions to remove the 'squareness' due to the landclass texture need to be used even on old GPUs.

    - All transition options are off by default. ws30-ALS-ultra.frag is active when the terrain quality slider is set to Ultra. Start by turning one of small or large scale transitions.

    - Texture mixing for small and large scale transitions don't work together, to reduce texture lookups. Turn one off when using the other.

    - Landclasses with contrasting colours make transition issues more visble. The driver control panel texture filtering settings reduces issues with seams at landclass borders.

    - ws30-ALS.frag is left untouched in this commit, for comparison and reviewing. ws30-ALS.frag is active when terrain quality slider is set High to Low.

    Changes:

    - Implement large scale transitions and small scale de-pixelisation of landclasses by searching the landclass texture. Several options and quality levels are available for profiling on different GPUs.
    - There are fixes for multiple issues dealing with texture rendering.

    Changelog:

    1.0 - Small-scale transitions:
    -- a) Remove squareness due to landclass texture by growing neighbour landclasses onto others depending on a growth priority. This feature uses 2 landclass texture lookups, 1 noise lookup, and only 1 ground texture lookup per point. For now the growth priority is simply the landclass id number. If this approach is used, growth priority would be a materials parameter. A way to set default growth priority by landclass via an xml file would be needed. There is flickering noise at long ranges due to small scale detail in the noise function used for growing landclasses. Partial derivative are used to turn off the feature, but turning off the feature too quickly still shows some square ness in distant landclasses.
    -- b) Reduce squareness due to landclass texture by mixing base textures of neighbouring landclasses. This is not perfect, as perfectly square shapes turn into perfectly square shapes with perfectly smudged edges. This uses 2 landclass texture lookups, and 2-3 ground texture lookups.
    -- c) - a) and b) can be run at once. This option will also fade the growths  gradually with distance. This uses 2 landclass texture lookups, 1 noise lookup, and 2-3 ground texture lookups.

    2.0 - Large scale transitions:
    -- a) Implemented by searching the landclass texture. The search pattern is current landlcass for the fragment at the center, and n search points in four directions along the s and t axes forming a cross. The search directions are configurable in the code, adn a minimum of 3 directions are needed. The step size is configurable. The fewer the steps, the larger the bands formed in the transitions. There are 1+4*n landclass lookups per n search points. e.g. 1 search point: 5 lookups, 4 search points:17 lookups, 10 search points: 41 lookups.
    -- b) An option to dither the transition bands by adding mixing noise is availble. This breaks up the visual impact of bands.
    -- c) There is some functionality to grow neighbours on a large scale. No growth priority is used - bothe neighbours will lose definition. A more advanced implementation can use several material parameters to define the nature of the transition: some transitions are very sharp in nature like with agriculture, other transitions can be very gradual, some transitions are patchy. Materials can have competing parameters, to determine which neighbour grows or has a shorter transition on one side. These parameters will need a way of specifying defaults by landclass.

    3.0 - Fixes
    -- a) - Fix seams at landclass borders. These are caused by different ground textures being stretched by different amounts. At the border, an incorrect mip-map level is looked up, causing a colour disontinuity in addition to the difference between landclasses. The reason the mip-map LoD is incorrect is because GPUs use 4 neighbouring pixels to figure out how fast texture coordinates change with respect to screenspace x and y (i.e. partial derivaitves), and use that information to pick a mip-map level. At a landlcass border, this calculation is incorrect.
    -- b) Fix seams at borders caused by the current detiling function. This is due to the detiling function changing the amount textures are stretched, as well as messing with coordinates.
    -- c) The solution to a) and b) is to use textureGrad() to lookup textures. It allows specifying partial derivatives. The partial derivatives for the normal texture coordinates are obtained by built-in funcions, and these need to be multiplied by each stretching factor, including different stretching inside conditionals. All future texture lookups that use custom coordinate scaling/manipulation need to use textureGrad. This fixes various signs of incorrect mip-map lod with distance and view angle (textures look stable/solid).
    -- d) Fix ground textures being stretched out of proportion in the detiling function. This is caused by tile dimensions not being unequal and texture stretching.
2021-11-05 19:59:32 +00:00
Stuart Buchanan
bf55997a56 WS30: Improved ambient color
Previous we just applied gl_LightSource[0].ambient without
multiplying it by the texture itself, so it just lightened
everything.

This fixes that.  (ws30-ALS-detailed.frag still to do)
2021-11-05 19:55:05 +00:00
Stuart Buchanan
63487bbe7b WS30 ultra shader - port ambient lighting fix
commit aca259acaccffbaf1cb264be423dda72c106150e
Author: vs <vs2009@mail.com>
Date:   Sat Oct 23 22:55:56 2021 +1000

    WS30 shaders: varying fix

commit 91b194f6766d432206cb013d99e0a96cd34ff33b
Author: vs <vs2009@mail.com>
Date:   Sat Oct 23 22:17:03 2021 +1000

    WS30 ultra shader: port the ambient lighting fix.
2021-10-24 21:36:39 +01:00
Stuart Buchanan
fc42ef3fe4 WS30: Include ambient light in ALS fragment shader
Previously only the diffuse term was considered in the fragment
shader, leading to very dark scenery and deep shadows.

Now the ambient light term is also included making the scenery
much closer to the way it should be lit.
2021-10-21 21:34:53 +01:00
Stuart Buchanan
0bce3c966f WS30: landclass and texture lookups in fragment shader
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 .
2021-10-21 21:31:03 +01:00
Fahim Imaduddin Dalvi
ae119f29cf Fixed FOV side effect on light sprite size.
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.
2021-09-04 13:41:02 +03:00
Fernando García Liñán
96a6e6c9bf HDR: Implement GTAO (Ground Truth Ambient Occlusion) 2021-09-01 04:26:03 +02:00
Fernando García Liñán
3459e7ddfe HDR: Use gl_VertexID instead of the MVP matrix in fullscreen passes 2021-08-31 18:02:38 +02:00
Fernando García Liñán
9f39644199 HDR: Optimize the G-Buffer and do not separate the occlusion texture
- 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.
2021-08-27 00:03:43 +02:00
Fernando García Liñán
a789c24209 HDR: Fix model-combined when not using a normal map 2021-08-25 16:49:08 +02:00
Fernando García Liñán
beb4381ad1 HDR: Fix model-combined objects without normal maps 2021-08-25 15:16:38 +02:00
Fernando García Liñán
aaf6bb9309 HDR: Improve ACES tone mapping curve
The previous one tended to over-expose the final image.
2021-08-25 15:15:57 +02:00
Fernando García Liñán
55410e9d35 HDR: Port chrome.eff 2021-08-25 14:32:22 +02:00
Fernando García Liñán
356ff8ff34 Fix indentation 2021-08-25 04:25:09 +02:00
Fernando García Liñán
9983a0c68c HDR: Water rendering 2021-08-25 04:17:09 +02:00
Fernando García Liñán
eea955168e HDR: Organize shadow-related files and add screen space shadows 2021-08-24 23:38:56 +02:00
Fernando García Liñán
eed433ce9f HDR: Use stencil buffer for optimization purposes 2021-08-23 12:44:26 +02:00
Fernando García Liñán
8662ce0a86 HDR: Add SMAA as the default antialiasing technique 2021-08-23 01:05:41 +02:00
Fernando García Liñán
b79d09d45f HDR: Prevent materials with roughness=0 from blowing out the lighting 2021-08-22 18:01:30 +02:00
Stuart Buchanan
a442615c68 WS30: Fix WS30 fragment shaders 2021-08-21 17:15:15 +01:00
Fernando García Liñán
b52fe3bf34 HDR: Remove glass.eff minimum alpha hack 2021-08-19 20:19:55 +02:00
Fernando García Liñán
7ff31e9004 HDR: Properly handle AC3D transparent materials 2021-08-19 18:20:37 +02:00
Fernando García Liñán
765a7d88f5 HDR: Use precomputed uniforms in the skydome shader 2021-08-19 14:06:25 +02:00
Fernando García Liñán
94f4007793 HDR: Use precomputed uniforms for atmospheric scattering 2021-08-19 12:50:16 +02:00
Fernando García Liñán
212f8fdab9 HDR: Add support for glTF transparent objects 2021-08-19 01:42:32 +02:00
Fernando García Liñán
05994100ea HDR: Better handling of model-combined for backwards compatibility 2021-08-18 12:27:03 +02:00