1
0
Fork 0
fgdata/Shaders
Fahim Imaduddin Dalvi c0e1e31674 Implement instancing for scenery objects
This commit implements instancing for scenery objects by introducing a
OBJECT_INSTANCED verb in stg files. Instances can be defined by their
positions, rotations and scales. The framework also supports extending
object instancing with custom effects, including an additional colorization
effect that allows for setting the colors for each instance of the same
model.

Detailed commit history can be found at [1], and mailing list discussions
at [2].

[1] https://sourceforge.net/u/fahimdalvi/fgdata/ci/feat/scenery-object-instancing/~/tree/
[2] https://sourceforge.net/p/flightgear/mailman/flightgear-devel/thread/7381A03F-BF5B-45E7-AAF3-5288B7DEDFFA%40gmail.com/#msg37617087

Squashed commit of the following:

commit 2af16b3dfa859eff8b9d96e1b9256e8d872d28c5
Author: Fahim Imaduddin Dalvi <dalvifahim@gmail.com>
Date:   Sat Feb 24 10:24:12 2024 +0300

    Update documentation for instancing

    Add details on optional parameters and the order of transformations.

commit f0fda25c196fbb46063abdd30be63ebbc4285841
Author: Fahim Imaduddin Dalvi <dalvifahim@gmail.com>
Date:   Sat Feb 24 10:15:17 2024 +0300

    Add low-spec shaders for object instancing.

commit bcf6e15523750ea9d1578a48de736073a37ea2bd
Author: Fahim Imaduddin Dalvi <dalvifahim@gmail.com>
Date:   Fri Feb 16 14:54:26 2024 +0300

    Add documentation

commit a4b889b40543f70c4e9c9d6002f853547c6fb373
Author: Fahim Imaduddin Dalvi <dalvifahim@gmail.com>
Date:   Tue Feb 13 17:32:11 2024 +0300

    Use header file defined indices for vertex attributes

    Vertex attributes were hardcoded across the code, this commit changes
    the implementation to use constants defined in the header file. Also
    change the indices used to be compatible with the future HDR pipeline.

commit 8120544e276161f57dd1aeda645ef52684eab7a7
Author: Fahim Imaduddin Dalvi <dalvifahim@gmail.com>
Date:   Sat Feb 10 22:26:55 2024 +0300

    Clean up shader code

    Use *.glsl library code to minimize duplication across object-instancing*
    shaders. Rename variables to follow Shader Style Guide:
    https://wiki.flightgear.org/Shader_Style_Guide

commit ed864379621c060860c68d46cab054f8f1161f25
Author: Fahim Imaduddin Dalvi <dalvifahim@gmail.com>
Date:   Sat Feb 3 22:23:11 2024 +0300

    Remove unused fragment shader.

commit be80516fff660764dad245cd6389e7616d8d807c
Author: Fahim Imaduddin Dalvi <dalvifahim@gmail.com>
Date:   Sat Feb 3 22:21:15 2024 +0300

    Add support for multiple effects and add a colored instancing effect.

    This commit adds shaders and a corresponding effect for colored
    instanced objects using the new custom attributes provided by the
    corresponding SimGear commit.

commit f758ad00b08578052b815bdf138dae5b3a0e026c
Author: Fahim Imaduddin Dalvi <dalvifahim@gmail.com>
Date:   Sat Feb 3 16:31:15 2024 +0300

    Remove unnecessary inclusion of vertex shader in inherited effect

commit 26fa5ecc8d825ed6902c6a6934a82749839cc9cc
Author: Fahim Imaduddin Dalvi <dalvifahim@gmail.com>
Date:   Wed Oct 18 21:14:18 2023 +0300

    Fix rotation to match normal scenery objects

commit 2a47c3164085d5821944f53a02a55c3bea9ca4ac
Author: Fahim Imaduddin Dalvi <dalvifahim@gmail.com>
Date:   Wed Oct 18 21:13:41 2023 +0300

    Reduce instancing effect to bare minimum

commit c24d4fdbfc295872ec6f47a8f8e002dfa301fd83
Author: Fahim Imaduddin Dalvi <dalvifahim@gmail.com>
Date:   Sat Oct 14 11:30:34 2023 +0300

    Properly handle model/texture/effects

    Simgear:
    Previously, the model was being loaded without any options, this is
    now fixed. *ac models have their effect instantiated manually, while
    *xml models require an explicit <effect> tags. Also, the already
    loaded model node is edited (for adding vertex attributes, statesets
    etc) instead of creating a new node (for deferred texture loading and
    other stuff to work).

    FGData:
    Reverted object-instancing effect to match model-default more closely
    to make texturing work.

commit 17e74fc4cc421c3aa9f08e5bbcd08d8a5b450655
Author: Fahim Imaduddin Dalvi <dalvifahim@gmail.com>
Date:   Sat Sep 9 14:07:35 2023 +0300

    Implement model-default effects for instanced objects.

    Not perfect yet, normal models are quite a bit darker, and we are loading
    the model using OSG directly, instead of SGModelLib.

commit d4734690745bde0652e578174e18ddf4fe799000
Author: Fahim Imaduddin Dalvi <dalvifahim@gmail.com>
Date:   Sat Apr 23 14:52:36 2022 +0300

    Implemented instance rotation and scaling

    This commit adds support for optional per-instance rotation and
    scaling, defaulting to no scaling and rotation if none is specified.

commit dd7256818becb21695487385fe5d4b7fcd33a61e
Author: Fahim Imaduddin Dalvi <dalvifahim@gmail.com>
Date:   Fri Mar 18 09:19:24 2022 +0300

    Implemented texture handling

    The code assumes there is a single texture, and this is applied
    to the single drawable geometry created for instancing. This commit
    breaks texture-less object support for instancing.

commit 547e051459c91ef0abe1b9fe583f0aed59720135
Author: Fahim Imaduddin Dalvi <dalvifahim@gmail.com>
Date:   Sat Feb 26 14:25:57 2022 +0300

    Moved random color generation to shader

commit ab927a8555ca615d2fe51c9fc87b9fb5f6198c3f
Author: Fahim Imaduddin Dalvi <dalvifahim@gmail.com>
Date:   Tue Feb 22 18:32:10 2022 +0300

    Proof of Concept instancing support for scenery objects.
2024-02-24 11:11:12 +03:00
..
Canvas Add Canvas shaders for the core profile 2024-02-09 14:32:24 +01:00
HDR HDR: WS 3.0 doesn't need a separate orthophoto texcoord 2024-02-10 00:12:59 +01:00
ShaderVG Fix ShaderVG transformation matrices 2024-02-08 19:59:21 +01:00
3dcloud-ALS-detailed.frag ALS: New cloud rendering detail level with more dramatic Mie scattering at cloud fringes done inside fragment shader 2018-08-30 09:17:36 +03:00
3dcloud-ALS-detailed.vert ALS: New cloud rendering detail level with more dramatic Mie scattering at cloud fringes done inside fragment shader 2018-08-30 09:17:36 +03:00
3dcloud-ALS.frag Add missing shader version tags for the other shaders too 2016-08-03 09:59:29 +02:00
3dcloud-ALS.vert More infrastructure for perception filtering of moonlight 2017-11-13 10:27:25 +02:00
3dcloud.frag Add missing shader version tags for the other shaders too 2016-08-03 09:59:29 +02:00
3dcloud.vert Fix for black clouds on ATI (bug 1160) 2013-12-25 23:14:04 +00:00
agriculture-ALS.frag Add clustered shading support to most Effects and shaders 2020-12-23 11:10:34 +01:00
airfield-ALS.frag Use different vertex attribute for orthoscenery 2023-04-05 23:13:51 +02:00
birds-ALS.frag Add missing shader version tags for the other shaders too 2016-08-03 09:59:29 +02:00
birds-ALS.vert ALS bird shader 2016-04-30 21:27:28 +03:00
bowwave-ALS.frag Filtering for most remaining ALS shaders 2016-04-06 09:26:49 +03:00
building-ALS.vert Fix random buildings shader errors 2021-04-16 07:46:35 +02:00
building-default.vert Fix random buildings shader errors 2021-04-16 07:46:35 +02:00
building-model-ALS-ultra.vert Fix shader-based buildings on AMD/macOS 2021-01-22 20:59:34 +00:00
chute-ALS.vert Add clustered shading support to most Effects and shaders 2020-12-23 11:10:34 +01:00
cliffs-ALS.frag Add clustered shading support to most Effects and shaders 2020-12-23 11:10:34 +01:00
cloud-impostor-ALS.vert More infrastructure for perception filtering of moonlight 2017-11-13 10:27:25 +02:00
cloud-noctilucent-ALS.vert More infrastructure for perception filtering of moonlight 2017-11-13 10:27:25 +02:00
cloud-shadowfunc.frag Some fixes for the ALS overlay shader 2017-09-18 12:47:21 +03:00
cloud-static-ALS-detailed.frag ALS: Fix rainbow fringing order in Cirrus clouds 2018-09-05 09:20:20 +03:00
cloud-static-ALS-detailed.vert ALS: Detailed scattering model for light on Cirrus clouds 2018-09-01 09:42:34 +03:00
cloud-static-ALS.frag Add missing shader version tags for the other shaders too 2016-08-03 09:59:29 +02:00
cloud-static-ALS.vert More infrastructure for perception filtering of moonlight 2017-11-13 10:27:25 +02:00
cloud-static.frag Add missing shader version tags for the other shaders too 2016-08-03 09:59:29 +02:00
cloud-static.vert Local Weather 1.4 by Thorsten Renk : fixes lots of graphical errors and transparency issues and provides a consistent GUI. 2012-01-03 20:21:34 +01:00
clouds-box.frag Add missing shader version tags for the other shaders too 2016-08-03 09:59:29 +02:00
clouds-box.vert Robert (dogg360): make shaders work for AMD/ATI graphics (#96,#335 related) 2011-07-04 20:20:26 +02:00
clouds-layered.frag Add missing shader version tags for the other shaders too 2016-08-03 09:59:29 +02:00
clouds-layered.vert Robert (dogg360): make shaders work for AMD/ATI graphics (#96,#335 related) 2011-07-04 20:20:26 +02:00
clouds-test.frag Add missing shader version tags for the other shaders too 2016-08-03 09:59:29 +02:00
clouds-test.vert Robert (dogg360): make shaders work for AMD/ATI graphics (#96,#335 related) 2011-07-04 20:20:26 +02:00
clouds-thick.frag Add missing shader version tags for the other shaders too 2016-08-03 09:59:29 +02:00
clouds-thick.vert Robert (dogg360): make shaders work for AMD/ATI graphics (#96,#335 related) 2011-07-04 20:20:26 +02:00
clouds-thin.frag Add missing shader version tags for the other shaders too 2016-08-03 09:59:29 +02:00
clouds-thin.vert Robert (dogg360): make shaders work for AMD/ATI graphics (#96,#335 related) 2011-07-04 20:20:26 +02:00
clouds-thinlayer.frag Add missing shader version tags for the other shaders too 2016-08-03 09:59:29 +02:00
clouds-thinlayer.vert Robert (dogg360): make shaders work for AMD/ATI graphics (#96,#335 related) 2011-07-04 20:20:26 +02:00
clustered-include.frag Add clustered shading support to most Effects and shaders 2020-12-23 11:10:34 +01:00
color_temperature.frag Changing file permissions to remove execute bit 2020-09-02 09:42:36 +02:00
default.frag Use different vertex attribute for orthoscenery 2023-04-05 23:13:51 +02:00
default.vert Use different vertex attribute for orthoscenery 2023-04-05 23:13:51 +02:00
drunway-ALS.frag Implement a simple snow shader for the low quality levels 2021-01-19 11:10:44 +01:00
filters-ALS.frag Added dithering as an ALS post-processing effect to prevent banding 2019-04-21 18:53:19 +02:00
filters-ALS.vert ALS - begin infrastructure for moonlight perception filtering 2017-06-18 10:08:39 +03:00
flutter-ALS.vert Add clustered shading support to most Effects and shaders 2020-12-23 11:10:34 +01:00
galaxy.frag MR269 - Added the Milky Way onto the night sky 2022-02-01 16:19:35 +00:00
galaxy.vert MR269 - Added the Milky Way onto the night sky 2022-02-01 16:19:35 +00:00
generic-ALS-base.vert Use different vertex attribute for orthoscenery 2023-04-05 23:13:51 +02:00
generic_ALS_base.glsl Implement instancing for scenery objects 2024-02-24 11:11:12 +03:00
glass-ALS.frag Fix incorrect lightmap intensity with lightmap-multi=0 2021-04-15 11:12:07 +02:00
glass-ALS.vert Add an appropriate version number to all vertex shaders 2016-08-05 13:16:23 +02:00
grass-ALS.frag Make Compositor default 2020-11-16 13:46:30 +01:00
grass-ALS.geom Make Compositor default 2020-11-16 13:46:30 +01:00
grass-ALS.vert Changing file permissions to remove execute bit 2020-09-02 09:42:36 +02:00
hazes.frag WS30: Separate out haze calculations 2022-01-18 21:13:29 +00:00
hud-ALS.frag Fix incorrect lightmap intensity with lightmap-multi=0 2021-04-15 11:12:07 +02:00
hud-ALS.vert ALS HUD effect approximating the appearance of light projected on the combiner 2017-02-24 09:28:54 +02:00
include_fog.frag Add missing shader version tags for the other shaders too 2016-08-03 09:59:29 +02:00
include_fog.vert Add an appropriate version number to all vertex shaders 2016-08-05 13:16:23 +02:00
light-ALS.frag Make ALS procedural light shader palatable to nouveau driver 2017-09-01 12:57:11 +03:00
light-ALS.vert Procedural aircraft lights for ALS - WIP 2016-02-03 09:13:30 +02:00
lightspot-ALS.frag ALS lightspot second projectable spot correction. 2016-10-05 14:47:44 -05:00
marker-pin.frag Marker-pins FGData changes 2022-01-27 12:11:24 +00:00
marker-pin.vert Marker-pins FGData changes 2022-01-27 12:11:24 +00:00
model-ALS-base.frag Add clustered shading support to most Effects and shaders 2020-12-23 11:10:34 +01:00
model-ALS-ultra.frag Fix too flat shadowing by not completely removing diffuse light but by toning it down instead. There's almost always reflective light bouncing around. 2022-05-15 10:41:37 +02:00
model-ALS-ultra.vert Make Compositor default 2020-11-16 13:46:30 +01:00
model-ALS-wingflex.vert Fix wingflex shader to use current effect code. A better way would probably be to just keep the wing flexing part there and then include model-combined, but I couldnt get that to work unfortunately 2023-02-10 10:40:36 +01:00
model-interior-ALS-base.frag Add clustered shading support to most Effects and shaders 2020-12-23 11:10:34 +01:00
model-interior-ALS-base.vert Add clustered shading support to most Effects and shaders 2020-12-23 11:10:34 +01:00
model-interior-ALS-detailed.frag Fix incorrect lightmap intensity with lightmap-multi=0 2021-04-15 11:12:07 +02:00
model-interior-ALS-detailed.vert Add clustered shading support to most Effects and shaders 2020-12-23 11:10:34 +01:00
model-interior-display-ALS.frag Fix incorrect lightmap intensity with lightmap-multi=0 2021-04-15 11:12:07 +02:00
model_ALS_base.glsl Implement instancing for scenery objects 2024-02-24 11:11:12 +03:00
night-vision.frag Add missing shader version tags for the other shaders too 2016-08-03 09:59:29 +02:00
noise.frag Interior glass effect with dynamic environment response for ALS 2015-03-10 13:43:08 +02:00
object_instancing.glsl Implement instancing for scenery objects 2024-02-24 11:11:12 +03:00
object_instancing.vert Implement instancing for scenery objects 2024-02-24 11:11:12 +03:00
object_instancing_colored.frag Implement instancing for scenery objects 2024-02-24 11:11:12 +03:00
object_instancing_colored.vert Implement instancing for scenery objects 2024-02-24 11:11:12 +03:00
object_instancing_colored_lowspec.frag Implement instancing for scenery objects 2024-02-24 11:11:12 +03:00
object_instancing_colored_lowspec.vert Implement instancing for scenery objects 2024-02-24 11:11:12 +03:00
object_instancing_lowspec.vert Implement instancing for scenery objects 2024-02-24 11:11:12 +03:00
planet-aurora.frag Earthview 2.1 - parallax mapping for cloud layer, lightning at night, Rayleigh scattering in atmosphere and minor bugfixes 2017-04-05 16:50:31 +03:00
planet-aurora.vert Earthview 2.1 - parallax mapping for cloud layer, lightning at night, Rayleigh scattering in atmosphere and minor bugfixes 2017-04-05 16:50:31 +03:00
planet-cloudlayer.frag Improvements to Earthview: enable changing cloud density, fix aurora z-ordering issue, let moonlight give a relief effect to clouds 2018-01-29 09:25:38 +02:00
planet-high.frag Remove rgb normalization and relax cut on NdotL to positive or null (fix visible redcuts) 2020-07-12 18:40:38 +02:00
planet.frag Remove rgb normalization and relax cut on NdotL to positive or null (fix visible redcuts) 2020-07-12 18:40:38 +02:00
planet.vert Improvements and bugfixes for orbital rendering 2015-03-29 13:16:19 +03:00
rain-layer-ALS.frag Add missing shader version tags for the other shaders too 2016-08-03 09:59:29 +02:00
rain-layer-ALS.vert Light scattering phenomena for ALS: rainbow, halo, sundogs and light pillar 2015-12-21 13:07:32 +02:00
rain-layer.frag Add missing shader version tags for the other shaders too 2016-08-03 09:59:29 +02:00
rain-layer.vert SHADERS:fix "unified" fog function. 2012-02-14 18:39:58 +02:00
road-ALS-ultra.frag Bugfix: Terrain quality taken into account in model shaders. 2022-04-02 21:20:20 +03:00
rock-ALS.frag Add clustered shading support to most Effects and shaders 2020-12-23 11:10:34 +01:00
runway-ALS.frag Implement a simple snow shader for the low quality levels 2021-01-19 11:10:44 +01:00
scenery-lights.frag Shader-based scenery lights. 2021-08-07 21:42:20 +03:00
scenery-lights.vert Fixed FOV side effect on light sprite size. 2021-09-04 13:41:02 +03:00
secondary_lights.frag Bugfixes for ALS light addition 2016-08-18 09:25:03 +03:00
shadows-include.frag Reorganize the shadow mapping functions 2021-06-17 18:18:27 +02:00
shadows-include.vert Tweak shadow offset parameters and cascade ranges 2021-01-05 11:24:19 +01:00
skydome-ALS.frag ALS: Detailed scattering model for light on Cirrus clouds 2018-09-01 09:42:34 +03:00
skydome-ALS.vert ALS: tentative fix for skydome monolith artifact - apparently this is a numerical accuracy issue (?) 2018-02-13 15:00:21 +02:00
space-ALS-base.frag Allows ALS filters for space shaders 2022-03-03 19:09:22 +00:00
space-ALS-base.vert Add an appropriate version number to all vertex shaders 2016-08-05 13:16:23 +02:00
space-ALS-ultra.frag Allows ALS filters for space shaders 2022-03-03 19:09:22 +00:00
space-ALS-ultra.vert Experimental additional lighting options for ALS model shaders 2016-07-31 10:29:02 +03:00
surface-light-ALS.frag Make ALS procedural light sprite more palatable to nouveau GPU driver 2017-03-04 10:01:45 +02:00
surface-light-ALS.vert Fix for light point sprite shader when light definition is initially small and creates nmerical issues 2019-10-06 11:26:42 +03:00
terrain-ALS-base.frag Use different vertex attribute for orthoscenery 2023-04-05 23:13:51 +02:00
terrain-ALS-detailed.frag Use different vertex attribute for orthoscenery 2023-04-05 23:13:51 +02:00
terrain-ALS-detailed.vert Use different vertex attribute for orthoscenery 2023-04-05 23:13:51 +02:00
terrain-ALS-ultra.frag Use different vertex attribute for orthoscenery 2023-04-05 23:13:51 +02:00
terrain-ALS-ultra.vert Use different vertex attribute for orthoscenery 2023-04-05 23:13:51 +02:00
terrain-nocolor.frag Add missing shader version tags for the other shaders too 2016-08-03 09:59:29 +02:00
terrain-overlay-ALS.frag Make Compositor default 2020-11-16 13:46:30 +01:00
terrain-overlay-ALS.geom Make Compositor default 2020-11-16 13:46:30 +01:00
text.frag Add shaders for osgText 2021-05-14 22:45:36 +02:00
text.vert Add shaders for osgText 2021-05-14 22:45:36 +02:00
thrustflame-ALS-detailed.frag Introduce detailed version of thruster flame 2016-08-01 11:47:44 +03:00
thrustflame-ALS.frag Bugfix and noise seed option for ALS thrust flame shader 2017-04-17 10:30:49 +03:00
thrustflame-ALS.vert Improvements to flame effect 2015-05-22 10:51:54 +03:00
tree-ALS-shadow.frag ALS: do not clamp haze color in object shaders, this leads to mismatch with terrain at high light intensity 2018-02-09 14:08:01 +02:00
tree-ALS-shadow.vert Add an appropriate version number to all vertex shaders 2016-08-05 13:16:23 +02:00
tree-ALS.frag ALS: do not clamp haze color in object shaders, this leads to mismatch with terrain at high light intensity 2018-02-09 14:08:01 +02:00
tree-ALS.vert Add an appropriate version number to all vertex shaders 2016-08-05 13:16:23 +02:00
tree.frag Standardized fog 2011-12-01 20:52:59 +00:00
tree.vert Speculative fix for shader cast issue on Mac. 2013-05-31 19:50:57 +01:00
trivial.frag Add missing shader version tags for the other shaders too 2016-08-03 09:59:29 +02:00
trivial.vert Procedural Texturing 2012-08-07 09:01:14 +02:00
wake-ALS.vert ALS maintenance - reworked light curves, streamlining, minor bugfixes,... 2014-12-15 15:50:47 +02:00
water-ALS-base.frag Add object shadows to water 2021-12-05 14:15:27 +00:00
water-ALS-high.frag Improved frozen-lake texture without snow 2021-12-25 10:55:09 +01:00
water-ALS.vert Prevent water ice-textures from moving around. 2021-12-23 14:22:48 +01:00
ws30-ALS-detailed.frag WS30: Improved shoreline rendering 2024-02-05 21:08:49 +00:00
ws30-ALS-detailed.vert Use different vertex attribute for orthoscenery 2023-04-05 23:13:51 +02:00
ws30-ALS-landclass-search-functions.frag WS30: Improved shoreline rendering 2024-02-05 21:08:49 +00:00
ws30-ALS-ultra.frag WS30: Improved shoreline rendering 2024-02-05 21:08:49 +00:00
ws30-ALS-ultra.vert WS30 - Improved coastline shader 2023-02-27 22:02:34 +00:00
ws30-ALS.frag WS30: Combined land and water shader 2022-02-05 15:24:02 +00:00
ws30-ALS.vert WS30: Combined land and water shader 2022-02-05 15:24:02 +00:00
ws30-overlay-ALS.geom WS30: MR #267: Improved texture lookups from VS 2022-01-03 15:43:29 +00:00
ws30-overlay-ALS.vert WS30: MR #267: Improved texture lookups from VS 2022-01-03 15:43:29 +00:00
ws30-q1.frag WS30: Revert to green channel for texture atlas 2021-12-18 21:55:17 +00:00
ws30-road-ALS-ultra.frag WS30: Road Shader porting from osm2city 2022-01-12 21:32:55 +00:00
ws30-water-ALS-detailed.frag Use different vertex attribute for orthoscenery 2023-04-05 23:13:51 +02:00
ws30-water-ALS-ultra.frag WS30: Improve water line features 2022-10-24 19:53:12 +01:00
ws30-water-ALS.frag WS30: Improve water line features 2022-10-24 19:53:12 +01:00
ws30-water-high.frag WS30 - Improved coastline shader 2023-02-27 22:02:34 +00:00
ws30-water-q1.frag WS30: Improve water line features 2022-10-24 19:53:12 +01:00
ws30-water.frag WS30: Clean up unused Uniforms 2022-04-09 17:17:15 +01:00
ws30.frag WS30: Revert to green channel for texture atlas 2021-12-18 21:55:17 +00:00
ws30.vert WS30 - Uniform Arrays and lighting model 2021-11-10 22:58:44 +00:00