]> git.tdb.fi Git - libs/gl.git/log
libs/gl.git
2 years agoAdd inline data items to the collection
Mikko Rasa [Sun, 9 May 2021 10:53:13 +0000 (13:53 +0300)]
Add inline data items to the collection

This simplifies the internals of various objects and does away with
the special keep() semantic of RefPtr.

Blend and DepthTest will be handled separately as part of rendering
state rework.

2 years agoAdd OccludedScene to the registered scene types
Mikko Rasa [Sun, 9 May 2021 08:22:19 +0000 (11:22 +0300)]
Add OccludedScene to the registered scene types

2 years agoDeprecate the old skylight properties in Lighting
Mikko Rasa [Sat, 8 May 2021 19:43:43 +0000 (22:43 +0300)]
Deprecate the old skylight properties in Lighting

It's no longer supported by the standard shaders, and IBL is a superior
solution.

2 years agoFix the name of the PBR fresnel lookup texture
Mikko Rasa [Sat, 8 May 2021 18:44:15 +0000 (21:44 +0300)]
Fix the name of the PBR fresnel lookup texture

2 years agoIncrease ambient occlusion max samples to 128
Mikko Rasa [Sat, 8 May 2021 17:37:50 +0000 (20:37 +0300)]
Increase ambient occlusion max samples to 128

2 years agoTake ambient occlusion samples only from the forward hemisphere
Mikko Rasa [Sat, 8 May 2021 17:33:57 +0000 (20:33 +0300)]
Take ambient occlusion samples only from the forward hemisphere

This requires a few more samples from the depth buffer to determine the
normal, but that should not be an issue with today's GPUs.

Also generate the sample points for cosine-weighted importance sampling
to obtain physically correct occlusion values.

2 years agoUse non-random sequences to initialize ambient occlusion data
Mikko Rasa [Sat, 8 May 2021 17:31:42 +0000 (20:31 +0300)]
Use non-random sequences to initialize ambient occlusion data

This allows selecting the formulas to obtain a better distribution of
values.

2 years agoStore the ambient occlusion rotate lookup texture in resources
Mikko Rasa [Sat, 8 May 2021 15:41:28 +0000 (18:41 +0300)]
Store the ambient occlusion rotate lookup texture in resources

2 years agoUse correct sampler for the ambient occlusion rotate lookup
Mikko Rasa [Sat, 8 May 2021 15:36:40 +0000 (18:36 +0300)]
Use correct sampler for the ambient occlusion rotate lookup

2 years agoFix use of camera matrices in the ambient occlusion effect
Mikko Rasa [Sat, 8 May 2021 15:10:53 +0000 (18:10 +0300)]
Fix use of camera matrices in the ambient occlusion effect

2 years agoAdd inverse view and projection matrices to camera transform uniforms
Mikko Rasa [Sat, 8 May 2021 15:09:31 +0000 (18:09 +0300)]
Add inverse view and projection matrices to camera transform uniforms

2 years agoUse persistent uniform blocks for Camera, Lighting and Clipping
Mikko Rasa [Sat, 8 May 2021 14:58:11 +0000 (17:58 +0300)]
Use persistent uniform blocks for Camera, Lighting and Clipping

Now that the relevant calculations are done in world space, the values
of these uniforms don't need to be calculated on a per-frame basis.

2 years agoChange Clipping to use index-less attaching
Mikko Rasa [Sat, 8 May 2021 13:40:23 +0000 (16:40 +0300)]
Change Clipping to use index-less attaching

2 years agoUse PBR with IBL for the sphere in desert pillars
Mikko Rasa [Sat, 8 May 2021 11:45:28 +0000 (14:45 +0300)]
Use PBR with IBL for the sphere in desert pillars

2 years agoAdd a property in Blender for a custom shadow shader
Mikko Rasa [Thu, 6 May 2021 10:20:24 +0000 (13:20 +0300)]
Add a property in Blender for a custom shadow shader

Since a shadow map doesn't have color output, it's useful to specify a
cheaper shader which only does vertex transformations.

2 years agoPut the PI constant in builtins
Mikko Rasa [Thu, 6 May 2021 10:15:40 +0000 (13:15 +0300)]
Put the PI constant in builtins

It's needed in several places so this is easier than defining it
separately everywhere.

2 years agoImplement image-based lighting in PbrMaterial
Mikko Rasa [Thu, 6 May 2021 08:16:05 +0000 (11:16 +0300)]
Implement image-based lighting in PbrMaterial

EnvironmentMap now has a constructor with an extra parameter indicating
the number of mipmap levels to use for prefiltering with varying amounts
of roughness.

2 years agoSupport layered framebuffer attachments
Mikko Rasa [Thu, 6 May 2021 08:14:47 +0000 (11:14 +0300)]
Support layered framebuffer attachments

2 years agoModify sunlight color based on transmittance of the atmosphere
Mikko Rasa [Wed, 5 May 2021 15:35:34 +0000 (18:35 +0300)]
Modify sunlight color based on transmittance of the atmosphere

2 years agoRe-export desert pillars data with ambient light
Mikko Rasa [Wed, 5 May 2021 15:04:51 +0000 (18:04 +0300)]
Re-export desert pillars data with ambient light

2 years agoSet shadowmap darkness to 1.0 by default
Mikko Rasa [Wed, 5 May 2021 12:30:51 +0000 (15:30 +0300)]
Set shadowmap darkness to 1.0 by default

It's not physically correct for lights to affect shadowed areas.

2 years agoExport the scene's background color as ambient light color
Mikko Rasa [Wed, 5 May 2021 12:29:05 +0000 (15:29 +0300)]
Export the scene's background color as ambient light color

2 years agoMinor refactoring of the Blender exporter
Mikko Rasa [Wed, 5 May 2021 11:22:53 +0000 (14:22 +0300)]
Minor refactoring of the Blender exporter

2 years agoImplement ambient lighting in the Cook-Torrance shader
Mikko Rasa [Wed, 5 May 2021 09:10:13 +0000 (12:10 +0300)]
Implement ambient lighting in the Cook-Torrance shader

The fresnel lookup texture used here is the same that will be needed for
image-based lighting.

2 years agoFix an incorrect include in the desertpillars demo
Mikko Rasa [Wed, 5 May 2021 08:26:41 +0000 (11:26 +0300)]
Fix an incorrect include in the desertpillars demo

2 years agoMark shaders created by materials as kept
Mikko Rasa [Tue, 4 May 2021 21:41:22 +0000 (00:41 +0300)]
Mark shaders created by materials as kept

Since they're stored in resources, it's not appropriate to delete them
outside of it.

2 years agoAccess builtin resources through a global instance
Mikko Rasa [Tue, 4 May 2021 20:13:33 +0000 (23:13 +0300)]
Access builtin resources through a global instance

Explicitly passing the Resources reference causes problems when some
classes in a hierarchy need it and others don't.  It's also awkward in
RenderPass::set_material and PostProcessor templates.  It doesn't even
matter which instance is passed in since the data is builtin anyway.

The first created Resources instance is now registered as the one to use
for builtin data, unless suppressed by a constructor parameter.

2 years agoFix brokenness from EnvironmentMap changes
Mikko Rasa [Wed, 28 Apr 2021 21:52:46 +0000 (00:52 +0300)]
Fix brokenness from EnvironmentMap changes

Commit fea00ed accidentally included some stuff that wasn't finished yet.

2 years agoMove lighting calculations to world space
Mikko Rasa [Wed, 28 Apr 2021 21:18:54 +0000 (00:18 +0300)]
Move lighting calculations to world space

Eye space lighting was a holdover from legacy OpenGL.  TBN space lighting
was similarly a kludge from old dot3 bump mapping.  Using world space
makes everything a lot simpler and allows some additional optimizations.

2 years agoThe load cache still needs to be pruned after the loop too
Mikko Rasa [Wed, 28 Apr 2021 11:44:00 +0000 (14:44 +0300)]
The load cache still needs to be pruned after the loop too

Under SPIR-V's structured flow control rules it's not permissible to use
a result from inside the loop except with OpPhi.

2 years agoImplement other texture query functions for GLSL
Mikko Rasa [Wed, 28 Apr 2021 11:43:33 +0000 (14:43 +0300)]
Implement other texture query functions for GLSL

2 years agoImplement textureSize as a visitor function in the SPIR-V generator
Mikko Rasa [Wed, 28 Apr 2021 11:38:55 +0000 (14:38 +0300)]
Implement textureSize as a visitor function in the SPIR-V generator

It requires an image as an operand, not a sampled image.

2 years agoStore required capabilities for SPIR-V builtin functions
Mikko Rasa [Wed, 28 Apr 2021 11:04:49 +0000 (14:04 +0300)]
Store required capabilities for SPIR-V builtin functions

2 years agoCheck if any shader data has changed when applying Renderer state
Mikko Rasa [Tue, 27 Apr 2021 10:28:04 +0000 (13:28 +0300)]
Check if any shader data has changed when applying Renderer state

2 years agoActually update the shdata generation numbers in Renderer
Mikko Rasa [Tue, 27 Apr 2021 10:27:11 +0000 (13:27 +0300)]
Actually update the shdata generation numbers in Renderer

2 years agoSet OpenGL debug labels on various objects loaded from Resources
Mikko Rasa [Sun, 25 Apr 2021 11:28:17 +0000 (14:28 +0300)]
Set OpenGL debug labels on various objects loaded from Resources

2 years agoRefactor program stage management
Mikko Rasa [Sun, 25 Apr 2021 11:13:16 +0000 (14:13 +0300)]
Refactor program stage management

There can't bee a huge number of stages in a program so a fixed-size
array takes less space than a vector.  It also allows accessing ids of
specific stages if needed.

2 years agoUse seamless cube map filtering if available
Mikko Rasa [Sat, 24 Apr 2021 21:32:45 +0000 (00:32 +0300)]
Use seamless cube map filtering if available

2 years agoUse a HDR environment map in desertpillars
Mikko Rasa [Sat, 24 Apr 2021 20:28:38 +0000 (23:28 +0300)]
Use a HDR environment map in desertpillars

2 years agoMake EnvironmentMap's pixel format configurable
Mikko Rasa [Sat, 24 Apr 2021 20:18:51 +0000 (23:18 +0300)]
Make EnvironmentMap's pixel format configurable

2 years agoUse RenderTargets in the Sky effect
Mikko Rasa [Sat, 24 Apr 2021 20:11:26 +0000 (23:11 +0300)]
Use RenderTargets in the Sky effect

2 years agoCosmetic fixes
Mikko Rasa [Sat, 24 Apr 2021 19:44:34 +0000 (22:44 +0300)]
Cosmetic fixes

2 years agoMake ShadowMap's finish_frame run only once per frame
Mikko Rasa [Sat, 24 Apr 2021 19:41:39 +0000 (22:41 +0300)]
Make ShadowMap's finish_frame run only once per frame

2 years agoRemove a now-unnecessary flush_shader_data call
Mikko Rasa [Sat, 24 Apr 2021 19:36:38 +0000 (22:36 +0300)]
Remove a now-unnecessary flush_shader_data call

This got missed in bb386d8.

2 years agoCompile SPIR-V modules from GLSL if needed
Mikko Rasa [Sat, 24 Apr 2021 19:35:30 +0000 (22:35 +0300)]
Compile SPIR-V modules from GLSL if needed

2 years agoFix opcode for matrix inverse
Mikko Rasa [Sat, 24 Apr 2021 19:31:41 +0000 (22:31 +0300)]
Fix opcode for matrix inverse

2 years agoAdd a cached load when initializing a variable
Mikko Rasa [Sat, 24 Apr 2021 19:31:31 +0000 (22:31 +0300)]
Add a cached load when initializing a variable

2 years agoClear variable load cache before a loop in the SPIR-V generator
Mikko Rasa [Sat, 24 Apr 2021 18:04:10 +0000 (21:04 +0300)]
Clear variable load cache before a loop in the SPIR-V generator

Variables may get assigned in the loop and the next iteration needs to
read those values, not the cached pre-loop values.

This could be done better by only clearing loads for the variables which
are actually assigned in the loop, but I'm not sure how exactly I want
to do that.

2 years agoHandle SPIR-V arrays with specialization constant for size
Mikko Rasa [Sat, 24 Apr 2021 16:19:35 +0000 (19:19 +0300)]
Handle SPIR-V arrays with specialization constant for size

2 years agoUnify handling of constants in SpirVModule
Mikko Rasa [Sat, 24 Apr 2021 16:18:42 +0000 (19:18 +0300)]
Unify handling of constants in SpirVModule

2 years agoGive Program::Bindings a more generic name
Mikko Rasa [Sat, 24 Apr 2021 15:58:53 +0000 (18:58 +0300)]
Give Program::Bindings a more generic name

2 years agoRecord texture bindings from SPIR-V modules
Mikko Rasa [Sat, 24 Apr 2021 14:57:19 +0000 (17:57 +0300)]
Record texture bindings from SPIR-V modules

2 years agoEnable creation of SPIR-V modules from GLSL source code
Mikko Rasa [Sat, 24 Apr 2021 14:57:04 +0000 (17:57 +0300)]
Enable creation of SPIR-V modules from GLSL source code

2 years agoVisit function definitions while collection dependencies
Mikko Rasa [Sat, 24 Apr 2021 14:55:49 +0000 (17:55 +0300)]
Visit function definitions while collection dependencies

Visiting just the declaration won't do much good.

2 years agoHandle function forward declarations in the SPIR-V generator
Mikko Rasa [Sat, 24 Apr 2021 14:55:14 +0000 (17:55 +0300)]
Handle function forward declarations in the SPIR-V generator

2 years agoRemake the desertpillars demo using modern techniques
Mikko Rasa [Sat, 24 Apr 2021 13:33:52 +0000 (16:33 +0300)]
Remake the desertpillars demo using modern techniques

2 years agoExport exposure value from Blender's render settings
Mikko Rasa [Sat, 24 Apr 2021 12:44:43 +0000 (15:44 +0300)]
Export exposure value from Blender's render settings

2 years agoAdd an effect for rendering a procedurally generated sky
Mikko Rasa [Sat, 24 Apr 2021 12:30:52 +0000 (15:30 +0300)]
Add an effect for rendering a procedurally generated sky

2 years agoDon't apply shadows outside the shadowmap's range
Mikko Rasa [Sat, 24 Apr 2021 12:12:50 +0000 (15:12 +0300)]
Don't apply shadows outside the shadowmap's range

2 years agoRedesign Light to only have a single color
Mikko Rasa [Sat, 24 Apr 2021 11:59:22 +0000 (14:59 +0300)]
Redesign Light to only have a single color

It makes little sense physically to have different diffuse and specular
colors.  The light exporter for Blender was already committed with this
new parameter name.

2 years agoRemove the deprecated singlepass shader
Mikko Rasa [Sat, 24 Apr 2021 11:54:49 +0000 (14:54 +0300)]
Remove the deprecated singlepass shader

It's become broken to the extent that it isn't worth fixing.

2 years agoDon't use "sample" as variable name in GLSL
Mikko Rasa [Sat, 24 Apr 2021 11:45:32 +0000 (14:45 +0300)]
Don't use "sample" as variable name in GLSL

In later versions it's a keyword.

2 years agoRearrange postprocessing shaders
Mikko Rasa [Sat, 24 Apr 2021 11:31:11 +0000 (14:31 +0300)]
Rearrange postprocessing shaders

Postprocess.glsl has been renamed to flat_effect.glsl and made more
generic so it can be used in non-postprocessing effects too.

2 years agoRefactor creation of builtin GLSL types
Mikko Rasa [Fri, 23 Apr 2021 22:40:30 +0000 (01:40 +0300)]
Refactor creation of builtin GLSL types

2 years agoImprove handling of types in GLSL parser
Mikko Rasa [Fri, 23 Apr 2021 22:34:14 +0000 (01:34 +0300)]
Improve handling of types in GLSL parser

Types defined in imported modules are now recognized.

2 years agoRedesign loading of GLSL sources
Mikko Rasa [Fri, 23 Apr 2021 21:43:56 +0000 (00:43 +0300)]
Redesign loading of GLSL sources

There's now a new class which holds parsed modules.  Parser no longer
creates modules and the parse functions take the target module as a
parameter.

2 years agoClear r_constant_result for a function call by default
Mikko Rasa [Thu, 22 Apr 2021 12:30:41 +0000 (15:30 +0300)]
Clear r_constant_result for a function call by default

Also clear it before processing a variable initializer, just in case.

2 years agoFix an issue with folding the sole argument of a conversion
Mikko Rasa [Thu, 22 Apr 2021 12:20:49 +0000 (15:20 +0300)]
Fix an issue with folding the sole argument of a conversion

2 years agoRedesign ExpressionInliner
Mikko Rasa [Thu, 22 Apr 2021 12:10:21 +0000 (15:10 +0300)]
Redesign ExpressionInliner

Similarly to the rewrite of UnusedVariableRemover from d230392, it now
analyzes the entire stage before inlining anything.  This approach is
more robust and easier to debug.

The inliner can now inline into the right side of an assignment even if
the left side references the same variable.

2 years agoFix an incorrect loop in UnusedVariableRemover
Mikko Rasa [Thu, 22 Apr 2021 10:58:57 +0000 (13:58 +0300)]
Fix an incorrect loop in UnusedVariableRemover

2 years agoEven better formatting of folded literals
Mikko Rasa [Thu, 22 Apr 2021 10:57:22 +0000 (13:57 +0300)]
Even better formatting of folded literals

A negative value does not consist entirely of digits yet may lack a
decimal point.  But a point must not be added after an exponent.

2 years agoFix the return value of ConstantFolder::apply
Mikko Rasa [Thu, 22 Apr 2021 10:50:11 +0000 (13:50 +0300)]
Fix the return value of ConstantFolder::apply

This was causing the folded literals to be left without a type in some
specific situations, since a resolve pass did not get run.

2 years agoRecognize backwards dependencies in GLSL loops
Mikko Rasa [Thu, 22 Apr 2021 10:38:08 +0000 (13:38 +0300)]
Recognize backwards dependencies in GLSL loops

Assignments at the end of a loop may get used by references earlier in
the same loop and should not be removed.

The added testcase also triggers some other bugs which will be fixed
over the next few commits.

2 years agoUse a generation number to track if ProgramData has changed
Mikko Rasa [Wed, 21 Apr 2021 14:06:18 +0000 (17:06 +0300)]
Use a generation number to track if ProgramData has changed

This avoids the need for an application to call flush_shader_data after
a change to uniform values in some cases.

2 years agoSupport nested scenes in datafiles
Mikko Rasa [Wed, 21 Apr 2021 13:43:33 +0000 (16:43 +0300)]
Support nested scenes in datafiles

This was supposed to be added before 7ae4af7.

2 years agoUse template functions for setting vector and matrix uniforms
Mikko Rasa [Wed, 21 Apr 2021 13:39:40 +0000 (16:39 +0300)]
Use template functions for setting vector and matrix uniforms

These work automatically for all sizes.  Type-safe overloads for arrays
were also added for convenience.

2 years agoRefactor texture attachment management in Framebuffer
Mikko Rasa [Wed, 21 Apr 2021 10:09:03 +0000 (13:09 +0300)]
Refactor texture attachment management in Framebuffer

Duplicated code from the attach functions has been collapsed into a
helper function.

Attaching a texture does not need binding it, so there's little point
in deferring the allocation to update_attachment.  By calling the type-
specific allocate function in attach, update_attachment can be simpler.

3 years agoAdd support for uint types in GLSL
Mikko Rasa [Tue, 20 Apr 2021 16:26:16 +0000 (19:26 +0300)]
Add support for uint types in GLSL

3 years agoRecognize the 'f' suffix for float literals in GLSL
Mikko Rasa [Tue, 20 Apr 2021 16:21:06 +0000 (19:21 +0300)]
Recognize the 'f' suffix for float literals in GLSL

3 years agoRecognize composite constants when generating SPIR-V
Mikko Rasa [Tue, 20 Apr 2021 15:32:22 +0000 (18:32 +0300)]
Recognize composite constants when generating SPIR-V

3 years agoPut specialization constant instructions in the right section in SPIR-V
Mikko Rasa [Tue, 20 Apr 2021 15:28:23 +0000 (18:28 +0300)]
Put specialization constant instructions in the right section in SPIR-V

3 years agoFold type conversions of constants
Mikko Rasa [Tue, 20 Apr 2021 15:21:35 +0000 (18:21 +0300)]
Fold type conversions of constants

3 years agoRefactor handling of %, << and >> in ConstantFolder
Mikko Rasa [Tue, 20 Apr 2021 15:18:25 +0000 (18:18 +0300)]
Refactor handling of %, << and >> in ConstantFolder

This is in line with the other operators and makes adding unsigned
types easier.

3 years agoMake sure folded float constants appear as correct type
Mikko Rasa [Tue, 20 Apr 2021 15:15:08 +0000 (18:15 +0300)]
Make sure folded float constants appear as correct type

If the value has no fractional part, the default conversion will not
add a decimal point.

3 years agoMake ConstantFolder check the type of the value directly
Mikko Rasa [Tue, 20 Apr 2021 15:14:20 +0000 (18:14 +0300)]
Make ConstantFolder check the type of the value directly

3 years agoResolve function calls where argument types need to be converted
Mikko Rasa [Tue, 20 Apr 2021 12:16:30 +0000 (15:16 +0300)]
Resolve function calls where argument types need to be converted

This is a rather basic implementation and will reject a call if there's
multiple candidates, without considering conversion ranks.

3 years agoMove some type information functions to glsl/reflect.cpp
Mikko Rasa [Tue, 20 Apr 2021 11:09:27 +0000 (14:09 +0300)]
Move some type information functions to glsl/reflect.cpp

3 years agoExport shadow settings from Blender
Mikko Rasa [Mon, 19 Apr 2021 08:29:03 +0000 (11:29 +0300)]
Export shadow settings from Blender

3 years agoAdd missing implementation of RenderPass::set_back_faces
Mikko Rasa [Mon, 19 Apr 2021 08:26:55 +0000 (11:26 +0300)]
Add missing implementation of RenderPass::set_back_faces

3 years agoMove the receive_shadows flag to RenderPass
Mikko Rasa [Mon, 19 Apr 2021 08:25:20 +0000 (11:25 +0300)]
Move the receive_shadows flag to RenderPass

It doesn't seem so much a property of the surface itself as the
environment it's rendered in.

3 years agoRearrange material-related state management in RenderPass
Mikko Rasa [Mon, 19 Apr 2021 08:14:51 +0000 (11:14 +0300)]
Rearrange material-related state management in RenderPass

The change in texture handling allows some simplifications here since
material textures no longer need to set any uniforms.  Creation of
material shader while loading is deferred to finish() so it isn't done
needlessly.

3 years agoDisallow loading uniforms without a custom shader
Mikko Rasa [Mon, 19 Apr 2021 07:54:17 +0000 (10:54 +0300)]
Disallow loading uniforms without a custom shader

3 years agoConvert Technique and RenderPass loaders to use shared actions
Mikko Rasa [Sun, 18 Apr 2021 22:43:58 +0000 (01:43 +0300)]
Convert Technique and RenderPass loaders to use shared actions

3 years agoAllow repeated storage calls with the same parameters
Mikko Rasa [Sun, 18 Apr 2021 18:59:46 +0000 (21:59 +0300)]
Allow repeated storage calls with the same parameters

3 years agoUse a separate shadow caster renderable for ShadowMap
Mikko Rasa [Sun, 18 Apr 2021 17:21:54 +0000 (20:21 +0300)]
Use a separate shadow caster renderable for ShadowMap

This makes the configuration more flexible.  For example it's possible
to use a Sequence to define which tag to use for the shadow pass.

3 years agoUse persistent cameras in effects
Mikko Rasa [Sun, 18 Apr 2021 07:23:04 +0000 (10:23 +0300)]
Use persistent cameras in effects

This allows implementing per-camera caching of culling and sorting in
scenes, and is also required for some Vulkan-related things.

3 years agoAdd a HDR option in Blender
Mikko Rasa [Sat, 17 Apr 2021 22:07:31 +0000 (01:07 +0300)]
Add a HDR option in Blender

3 years agoUnmanage texture if loading data directly
Mikko Rasa [Sat, 17 Apr 2021 22:05:20 +0000 (01:05 +0300)]
Unmanage texture if loading data directly

Otherwise the resource manager won't have a load location for the texture
and will throw an exception.

Also generate ID if it hasn't been done yet.

3 years agoRefactor texture ID generation into a function
Mikko Rasa [Sat, 17 Apr 2021 22:04:53 +0000 (01:04 +0300)]
Refactor texture ID generation into a function

3 years agoImprove error reporting in the Blender exporter
Mikko Rasa [Sat, 17 Apr 2021 19:38:43 +0000 (22:38 +0300)]
Improve error reporting in the Blender exporter

Exceptions now include information identifying the thing which could not
be processed.