libs/gl.git
9 months agoRearrange postprocessor creation code in SequenceBuilder
Mikko Rasa [Tue, 19 Oct 2021 12:38:09 +0000 (15:38 +0300)]
Rearrange postprocessor creation code in SequenceBuilder

Previously it would have inadvertently deleted overridden postprocessors.

9 months agoRequire all renderables to be present when building a sequence
Mikko Rasa [Tue, 19 Oct 2021 12:00:38 +0000 (15:00 +0300)]
Require all renderables to be present when building a sequence

9 months agoUse shared actions in SequenceTemplate loaders
Mikko Rasa [Tue, 19 Oct 2021 09:46:39 +0000 (12:46 +0300)]
Use shared actions in SequenceTemplate loaders

9 months agoRefactor the structure of sequence template files
Mikko Rasa [Tue, 19 Oct 2021 09:36:53 +0000 (12:36 +0300)]
Refactor the structure of sequence template files

Renderables are now specified separately from steps.  Post-processors are
defined with a unified keyword, with the type determined by a statement
inside the block.

9 months agoAdd Renderable as base class for relevant types in Resources
Mikko Rasa [Tue, 19 Oct 2021 09:12:02 +0000 (12:12 +0300)]
Add Renderable as base class for relevant types in Resources

9 months agoRestore missing private access specifier
Mikko Rasa [Sun, 17 Oct 2021 20:18:36 +0000 (23:18 +0300)]
Restore missing private access specifier

It got accidentally removed in 9a63244.

9 months agoRefactor owned postprocessors in Sequence into a more generic mechanism
Mikko Rasa [Sun, 17 Oct 2021 08:26:13 +0000 (11:26 +0300)]
Refactor owned postprocessors in Sequence into a more generic mechanism

9 months agoSet a sane default value for ground albedo in Sky::Planet
Mikko Rasa [Sat, 16 Oct 2021 16:09:47 +0000 (19:09 +0300)]
Set a sane default value for ground albedo in Sky::Planet

9 months agoAdd a moving point light to the night phase of desertpillars
Mikko Rasa [Sat, 16 Oct 2021 16:01:44 +0000 (19:01 +0300)]
Add a moving point light to the night phase of desertpillars

9 months agoRe-export desertpillars data
Mikko Rasa [Sat, 16 Oct 2021 15:56:56 +0000 (18:56 +0300)]
Re-export desertpillars data

9 months agoAdd a day-night cycle to the desertpillars demo
Mikko Rasa [Sat, 16 Oct 2021 15:53:53 +0000 (18:53 +0300)]
Add a day-night cycle to the desertpillars demo

9 months agoTweak the logic in sky raymarching to avoid false shadowing
Mikko Rasa [Sat, 16 Oct 2021 15:34:15 +0000 (18:34 +0300)]
Tweak the logic in sky raymarching to avoid false shadowing

Ray_sphere_intersection now always returns the ingoing hit if radius is
positive or outgoing hit if radius is negative.  This avoids a ray
starting at ground level towards the sky immediately hitting the ground.

9 months agoAdjust function names in the GLSL compiler test runner
Mikko Rasa [Sat, 16 Oct 2021 13:55:38 +0000 (16:55 +0300)]
Adjust function names in the GLSL compiler test runner

Make them match the changes in d1e4737.

9 months agoDon't record references to null declarations
Mikko Rasa [Sat, 16 Oct 2021 13:53:21 +0000 (16:53 +0300)]
Don't record references to null declarations

9 months agoSave possible outer reference when entering subscript
Mikko Rasa [Sat, 16 Oct 2021 13:49:44 +0000 (16:49 +0300)]
Save possible outer reference when entering subscript

Otherwise it gets corrupted and the outer variable may be incorrectly
removed if nothing else refers to it.

9 months agoRecognize additional blend types in the Blender exporter
Mikko Rasa [Sat, 16 Oct 2021 12:54:11 +0000 (15:54 +0300)]
Recognize additional blend types in the Blender exporter

9 months agoAdd blend statement also with custom shaders
Mikko Rasa [Sat, 16 Oct 2021 12:51:11 +0000 (15:51 +0300)]
Add blend statement also with custom shaders

9 months agoRemove an unnecessary if
Mikko Rasa [Sat, 16 Oct 2021 12:43:38 +0000 (15:43 +0300)]
Remove an unnecessary if

The condition is already checked at the outer level

9 months agoRecognize transparent materials in Blender and export them accordingly
Mikko Rasa [Sat, 16 Oct 2021 10:11:49 +0000 (13:11 +0300)]
Recognize transparent materials in Blender and export them accordingly

Objects with transparency are exported into a separate, Z-sorted
sub-scene.

9 months agoRefactor scene export to use inline scenes instead of a wrapper scene
Mikko Rasa [Sat, 16 Oct 2021 09:29:32 +0000 (12:29 +0300)]
Refactor scene export to use inline scenes instead of a wrapper scene

9 months agoRemove the scene type property from Blender exporter
Mikko Rasa [Sat, 16 Oct 2021 09:10:20 +0000 (12:10 +0300)]
Remove the scene type property from Blender exporter

It's better managed automatically based on object transparency and other
factors.

9 months agoMove blend state from Sequence::Step to RenderMethod
Mikko Rasa [Sat, 16 Oct 2021 08:49:11 +0000 (11:49 +0300)]
Move blend state from Sequence::Step to RenderMethod

Even though all blended objects are typically rendered in a single step,
it may be desirable to use different blend modes for different objects.

9 months agoWrap material before passing it to create_technique_resource
Mikko Rasa [Sat, 16 Oct 2021 08:21:38 +0000 (11:21 +0300)]
Wrap material before passing it to create_technique_resource

9 months agoSimplify exporter creation
Mikko Rasa [Sat, 16 Oct 2021 08:12:29 +0000 (11:12 +0300)]
Simplify exporter creation

Since options are no longer set as instance variables, the helper
functions feel unnecessary.

9 months agoRecognize a node graph which gives transparency to unlit materials
Mikko Rasa [Fri, 15 Oct 2021 10:48:19 +0000 (13:48 +0300)]
Recognize a node graph which gives transparency to unlit materials

10 months agoSupport inline scenes within other scenes
Mikko Rasa [Thu, 14 Oct 2021 09:02:37 +0000 (12:02 +0300)]
Support inline scenes within other scenes

This is useful for creating scenes where transparent objects are rendered
after opaque ones, without the entire scene being Z-sorted.

10 months agoAdjust naming of instances in Scene loader
Mikko Rasa [Thu, 14 Oct 2021 09:00:27 +0000 (12:00 +0300)]
Adjust naming of instances in Scene loader

I'm going to add inline nested scenes so a per-loader counter would get
duplicates.

10 months agoReplace the instance variables of exporters by function parameters
Mikko Rasa [Wed, 13 Oct 2021 16:34:25 +0000 (19:34 +0300)]
Replace the instance variables of exporters by function parameters

This is more flexible when exporting a lot of data.  In almost all cases
the variables were only used by the export_to_file function anyway.

10 months agoRespect enabled_methods in the Sky effect
Mikko Rasa [Wed, 13 Oct 2021 09:28:10 +0000 (12:28 +0300)]
Respect enabled_methods in the Sky effect

10 months agoRename Effect::enabled_passes to enabled_methods
Mikko Rasa [Wed, 13 Oct 2021 09:26:36 +0000 (12:26 +0300)]
Rename Effect::enabled_passes to enabled_methods

10 months agoAdjust and re-export desertpillars data with new features
Mikko Rasa [Mon, 11 Oct 2021 13:52:11 +0000 (16:52 +0300)]
Adjust and re-export desertpillars data with new features

10 months agoChange default binding ranges to match lowest OpenGL standard
Mikko Rasa [Mon, 11 Oct 2021 13:45:10 +0000 (16:45 +0300)]
Change default binding ranges to match lowest OpenGL standard

10 months agoAdjust GLSL features factory function names
Mikko Rasa [Mon, 11 Oct 2021 13:27:46 +0000 (16:27 +0300)]
Adjust GLSL features factory function names

Make it clear these functions deal with OpenGL versions.

10 months agoFix incorrect exception messages
Mikko Rasa [Mon, 11 Oct 2021 13:25:41 +0000 (16:25 +0300)]
Fix incorrect exception messages

10 months agoFix export of the stub technique
Mikko Rasa [Mon, 11 Oct 2021 13:20:43 +0000 (16:20 +0300)]
Fix export of the stub technique

10 months agoMinor cleanups and tweaks
Mikko Rasa [Mon, 11 Oct 2021 13:20:11 +0000 (16:20 +0300)]
Minor cleanups and tweaks

10 months agoClear reflect data before adding shader stages
Mikko Rasa [Mon, 11 Oct 2021 13:17:27 +0000 (16:17 +0300)]
Clear reflect data before adding shader stages

Otherwise it prevents the number of clip distances from being recorded.

10 months agoAdd tetrahedron shadow maps for point lights
Mikko Rasa [Mon, 11 Oct 2021 13:14:00 +0000 (16:14 +0300)]
Add tetrahedron shadow maps for point lights

10 months agoApply shadow depth bias in a different way
Mikko Rasa [Mon, 11 Oct 2021 13:05:16 +0000 (16:05 +0300)]
Apply shadow depth bias in a different way

It cannot be properly applied through the matrix for perspective
projection.

10 months agoRefactor ShadowMap to allow different types of lights
Mikko Rasa [Mon, 11 Oct 2021 12:57:50 +0000 (15:57 +0300)]
Refactor ShadowMap to allow different types of lights

Omnidirectional lights will need more than one view per light.

10 months agoSuppoer per-light shadow casters in ShadowMap
Mikko Rasa [Mon, 11 Oct 2021 12:40:22 +0000 (15:40 +0300)]
Suppoer per-light shadow casters in ShadowMap

Different types of lights may require different shaders for rendering
shadow maps, or it may be desirable to use different occluder geometry
for far away lights than close ones.

10 months agoAllow suppressing clear in a sequence by passing in a special tag
Mikko Rasa [Mon, 11 Oct 2021 12:25:52 +0000 (15:25 +0300)]
Allow suppressing clear in a sequence by passing in a special tag

Sequence doesn't pass on the tag it receives, so it can be used to
control the sequence's own behaviour instead.

10 months agoSupport creating fully custom techniques in Blender
Mikko Rasa [Mon, 11 Oct 2021 11:55:02 +0000 (14:55 +0300)]
Support creating fully custom techniques in Blender

This replaces the custom shader, which was getting unwieldy with
different kinds of shadow maps needing different shaders.

10 months agoAllow redeclaring entire builtin interface blocks
Mikko Rasa [Sun, 10 Oct 2021 15:35:43 +0000 (18:35 +0300)]
Allow redeclaring entire builtin interface blocks

10 months agoRemove generic clipping state
Mikko Rasa [Sun, 10 Oct 2021 14:08:42 +0000 (17:08 +0300)]
Remove generic clipping state

Instead do things the Vulkan way and set the enabled clip planes based on
the declared size of the gl_ClipDistance array in the shader.

10 months agoReflect builtin decorators from SPIR-V modules
Mikko Rasa [Sun, 10 Oct 2021 14:03:02 +0000 (17:03 +0300)]
Reflect builtin decorators from SPIR-V modules

10 months agoRefactor the builtin occluder shader
Mikko Rasa [Sun, 10 Oct 2021 13:09:10 +0000 (16:09 +0300)]
Refactor the builtin occluder shader

It's now stored in shaderlib and considered available for custom shaders
to import.

10 months agoMove the frag_color output from msp_interface to common
Mikko Rasa [Sun, 10 Oct 2021 12:50:43 +0000 (15:50 +0300)]
Move the frag_color output from msp_interface to common

This allows creating shaders without a fragment stage which use the
interface.

10 months agoDecorate builtin variables in the global scope
Mikko Rasa [Sun, 10 Oct 2021 12:48:46 +0000 (15:48 +0300)]
Decorate builtin variables in the global scope

10 months agoRemove output variables which are not referenced
Mikko Rasa [Sun, 10 Oct 2021 12:37:07 +0000 (15:37 +0300)]
Remove output variables which are not referenced

10 months agoSupport redeclaring builtins defined in an interface block
Mikko Rasa [Sun, 10 Oct 2021 11:49:59 +0000 (14:49 +0300)]
Support redeclaring builtins defined in an interface block

10 months agoRemove support for redeclaring user-defined variables
Mikko Rasa [Sun, 10 Oct 2021 11:40:52 +0000 (14:40 +0300)]
Remove support for redeclaring user-defined variables

... with the exception of redeclaring a previously unsized array.
Builtin array sizes can also now be redeclared.

10 months agoRemove some unused code from UnusedVariableRemover
Mikko Rasa [Sun, 10 Oct 2021 11:14:54 +0000 (14:14 +0300)]
Remove some unused code from UnusedVariableRemover

The interface_block variable has always been null since dfcf8eb.

10 months agoOnly remove load IDs of variables actually assigned in a loop
Mikko Rasa [Sun, 10 Oct 2021 08:54:24 +0000 (11:54 +0300)]
Only remove load IDs of variables actually assigned in a loop

Some variables like function arguments are not pointers and can't be
loaded again.

10 months agoFix the type of a loop variable
Mikko Rasa [Sun, 10 Oct 2021 08:51:54 +0000 (11:51 +0300)]
Fix the type of a loop variable

This was a transcription error introduced in e9a898f.

10 months agoDon't dismantle aggregates which are function parameters
Mikko Rasa [Sun, 10 Oct 2021 08:51:04 +0000 (11:51 +0300)]
Don't dismantle aggregates which are function parameters

10 months agoDetermine the default uniform block size regardless of module format
Mikko Rasa [Sun, 10 Oct 2021 08:48:24 +0000 (11:48 +0300)]
Determine the default uniform block size regardless of module format

10 months agoChange various generated texture names to use the unified extension
Mikko Rasa [Sat, 9 Oct 2021 17:59:44 +0000 (20:59 +0300)]
Change various generated texture names to use the unified extension

10 months agoAdd attenuation calculations and related export code for point lights
Mikko Rasa [Sat, 9 Oct 2021 17:58:14 +0000 (20:58 +0300)]
Add attenuation calculations and related export code for point lights

10 months agoPass the queried position as an argument to get_shadow_factor
Mikko Rasa [Sat, 9 Oct 2021 17:54:27 +0000 (20:54 +0300)]
Pass the queried position as an argument to get_shadow_factor

10 months agoSome refactoring of light calculations in shaders
Mikko Rasa [Sat, 9 Oct 2021 17:47:39 +0000 (20:47 +0300)]
Some refactoring of light calculations in shaders

10 months agoAdd export_light to the list of reloadable files in the Blender exporter
Mikko Rasa [Sat, 9 Oct 2021 17:09:45 +0000 (20:09 +0300)]
Add export_light to the list of reloadable files in the Blender exporter

10 months agoAlso break up arrays which are only indexed by constants
Mikko Rasa [Sat, 9 Oct 2021 16:58:51 +0000 (19:58 +0300)]
Also break up arrays which are only indexed by constants

10 months agoRecognize unknown index as matching any index
Mikko Rasa [Sat, 9 Oct 2021 16:46:27 +0000 (19:46 +0300)]
Recognize unknown index as matching any index

If an array is accessed with an unknown index, all assignments to the
array must be kept.

10 months agoBreak up struct variables if they're not used as a whole
Mikko Rasa [Sat, 9 Oct 2021 16:44:06 +0000 (19:44 +0300)]
Break up struct variables if they're not used as a whole

This lets the optimizer inline or discard individual members depending
on how or if they're used.

10 months agoUse default member initializers for simple types
Mikko Rasa [Sat, 9 Oct 2021 11:11:09 +0000 (14:11 +0300)]
Use default member initializers for simple types

Also mark special member functions as defaulted instead of defining them
as empty.

10 months agoMake Light's constructor protected and add a virtual destructor
Mikko Rasa [Sat, 9 Oct 2021 10:24:37 +0000 (13:24 +0300)]
Make Light's constructor protected and add a virtual destructor

10 months agoAdd an option to use a fixed position in EnvironmentMap
Mikko Rasa [Sat, 9 Oct 2021 09:52:29 +0000 (12:52 +0300)]
Add an option to use a fixed position in EnvironmentMap

This allows environment maps which are not tied to a particular object.

It's required for 0b76663 but I forgot to commit it before that.

10 months agoConsider expressions in array sizes when comparing types for equality
Mikko Rasa [Fri, 8 Oct 2021 07:14:22 +0000 (10:14 +0300)]
Consider expressions in array sizes when comparing types for equality

10 months agoRemove unfinished light properties panel from the blender exporter
Mikko Rasa [Fri, 8 Oct 2021 06:53:56 +0000 (09:53 +0300)]
Remove unfinished light properties panel from the blender exporter

This was accidentally added in 7ae4af7 even though the things it's going
to be used with are not ready yet.  I will add it back later.

10 months agoUse image-based lighting in the entire desert pillars scene
Mikko Rasa [Fri, 8 Oct 2021 06:52:47 +0000 (09:52 +0300)]
Use image-based lighting in the entire desert pillars scene

10 months agoAdd a shadowing term from the planet to atmospheric transmittance
Mikko Rasa [Fri, 8 Oct 2021 06:16:41 +0000 (09:16 +0300)]
Add a shadowing term from the planet to atmospheric transmittance

This makes the sky properly dark if the sun is below the horizon.

10 months agoUse the shadow camera's projection matrix to form the shadow matrix
Mikko Rasa [Thu, 7 Oct 2021 15:04:19 +0000 (18:04 +0300)]
Use the shadow camera's projection matrix to form the shadow matrix

This makes it easier to support different types of projection, such as
perspective projection for point lights.

10 months agoRe-export desertpillars data to incorporate recent changes
Mikko Rasa [Thu, 7 Oct 2021 13:07:14 +0000 (16:07 +0300)]
Re-export desertpillars data to incorporate recent changes

10 months agoLoad textures in a type-generic way
Mikko Rasa [Thu, 7 Oct 2021 13:04:57 +0000 (16:04 +0300)]
Load textures in a type-generic way

10 months agoAdd keywords for light and material to Resources::Loader
Mikko Rasa [Thu, 7 Oct 2021 12:58:53 +0000 (15:58 +0300)]
Add keywords for light and material to Resources::Loader

Since they're loaded with a generic loader now, the standard keyword
mechanism can't handle them.

10 months agoUse set_manager instead of passing the manager to the constructor
Mikko Rasa [Thu, 7 Oct 2021 08:23:57 +0000 (11:23 +0300)]
Use set_manager instead of passing the manager to the constructor

This allows always using the parameterless constructor, making some
things easier.

10 months agoRename OpenGLTexture::generate_id to create
Mikko Rasa [Thu, 7 Oct 2021 08:22:00 +0000 (11:22 +0300)]
Rename OpenGLTexture::generate_id to create

10 months agoAlways delay texture creation until it is allocated
Mikko Rasa [Thu, 7 Oct 2021 08:19:44 +0000 (11:19 +0300)]
Always delay texture creation until it is allocated

This allows greateer flexibility with setting a resource manager.

10 months agoFix loading of inline materials and lights
Mikko Rasa [Wed, 6 Oct 2021 21:04:37 +0000 (00:04 +0300)]
Fix loading of inline materials and lights

10 months agoSplit the Light class into subclasses by light type
Mikko Rasa [Wed, 6 Oct 2021 08:15:42 +0000 (11:15 +0300)]
Split the Light class into subclasses by light type

There are some cases where it would be inconvenient for a light to
suddenly change type.

10 months agoStore materials and scenes using actual types
Mikko Rasa [Tue, 5 Oct 2021 22:19:53 +0000 (01:19 +0300)]
Store materials and scenes using actual types

10 months agoAdjust creator and notify functions in Resources
Mikko Rasa [Tue, 5 Oct 2021 21:05:53 +0000 (00:05 +0300)]
Adjust creator and notify functions in Resources

10 months agoUse DynamicObjectLoader for Material and Scene generic loaders
Mikko Rasa [Tue, 5 Oct 2021 11:49:25 +0000 (14:49 +0300)]
Use DynamicObjectLoader for Material and Scene generic loaders

10 months agoRemove collection-less constructor overloads from most loaders
Mikko Rasa [Tue, 5 Oct 2021 10:18:52 +0000 (13:18 +0300)]
Remove collection-less constructor overloads from most loaders

These classes are extremely likely to require references to other
objects, and requiring a collection makes the code more straightforward.

10 months agoUnify the loader wrappers for Material and Scene
Mikko Rasa [Mon, 4 Oct 2021 17:10:19 +0000 (20:10 +0300)]
Unify the loader wrappers for Material and Scene

10 months agoRefactor ShadowMap to support multiple lights
Mikko Rasa [Mon, 4 Oct 2021 17:09:08 +0000 (20:09 +0300)]
Refactor ShadowMap to support multiple lights

10 months agoSet viewport and scissor before clear commands
Mikko Rasa [Sun, 3 Oct 2021 18:39:33 +0000 (21:39 +0300)]
Set viewport and scissor before clear commands

Since this requires applying the pipeline state, using DSA for the clear
commands seems pointless and was removed to simplify the code.

10 months agoRemove conditional and iteration statements with no effect from GLSL
Mikko Rasa [Sun, 3 Oct 2021 13:15:05 +0000 (16:15 +0300)]
Remove conditional and iteration statements with no effect from GLSL

10 months agoFix a compile error in the GLSL compiler test runner
Mikko Rasa [Sun, 3 Oct 2021 11:47:16 +0000 (14:47 +0300)]
Fix a compile error in the GLSL compiler test runner

10 months agoSupport multiple lights in a single pass
Mikko Rasa [Sun, 3 Oct 2021 10:57:19 +0000 (13:57 +0300)]
Support multiple lights in a single pass

Light direction is now computed in fragment shader because interface
variable locations can't use specialization constants.

Shadow map currently only affects the first light but will be improved
soon.

10 months agoRemove unused world_halfway_dir variable from common.glsl
Mikko Rasa [Sun, 3 Oct 2021 10:44:15 +0000 (13:44 +0300)]
Remove unused world_halfway_dir variable from common.glsl

10 months agoRe-export desertpillars data
Mikko Rasa [Sun, 3 Oct 2021 00:13:02 +0000 (03:13 +0300)]
Re-export desertpillars data

10 months agoRename RenderPass to RenderMethod
Mikko Rasa [Sat, 2 Oct 2021 16:23:36 +0000 (19:23 +0300)]
Rename RenderPass to RenderMethod

This is mostly to avoid confusion with Vulkan's render passes, which are
an entirely different thing.

10 months agoRemove deprecated interfaces from material and lighting code
Mikko Rasa [Sat, 2 Oct 2021 11:05:00 +0000 (14:05 +0300)]
Remove deprecated interfaces from material and lighting code

10 months agoAccess the tag name map with a function
Mikko Rasa [Sat, 2 Oct 2021 10:57:01 +0000 (13:57 +0300)]
Access the tag name map with a function

Otherwise declaring tag constants as static members of classes is
unreliable because of the undefined initialization order of globals
in different translation units.

10 months agoUse constructor delegation instead of init functions when possible
Mikko Rasa [Fri, 1 Oct 2021 19:09:54 +0000 (22:09 +0300)]
Use constructor delegation instead of init functions when possible

10 months agoDon't use an internal depth test in ShadowMap
Mikko Rasa [Fri, 1 Oct 2021 18:22:18 +0000 (21:22 +0300)]
Don't use an internal depth test in ShadowMap

It's expected that the content renderable is a Sequence which supplies
the necessary state.

10 months agoSome more cleanup of includes and forward declarations
Mikko Rasa [Fri, 1 Oct 2021 18:03:34 +0000 (21:03 +0300)]
Some more cleanup of includes and forward declarations

10 months agoStore query pool size separately, in the common part of the class
Mikko Rasa [Fri, 1 Oct 2021 17:00:17 +0000 (20:00 +0300)]
Store query pool size separately, in the common part of the class