libs/gl.git
16 months agoAdd a function to flush shader data in Renderer master
Mikko Rasa [Sun, 28 Jul 2019 00:03:58 +0000 (03:03 +0300)]
Add a function to flush shader data in Renderer

Necessary if the same shader data object is used in successive draw
commands but the contained uniform values are changed.

16 months agoAdd an object LoD bias parameter to Renderer
Mikko Rasa [Sat, 27 Jul 2019 23:05:55 +0000 (02:05 +0300)]
Add an object LoD bias parameter to Renderer

This could be used by environment map and similar effects to render the
scene at lower detail.

16 months agoAdd an alpha channel flag to Pipeline
Mikko Rasa [Sat, 27 Jul 2019 23:05:05 +0000 (02:05 +0300)]
Add an alpha channel flag to Pipeline

16 months agoDon't add externally specified postprocessors as owned
Mikko Rasa [Fri, 26 Jul 2019 17:02:58 +0000 (20:02 +0300)]
Don't add externally specified postprocessors as owned

16 months agoRecognize the samplerCubeArray type in shaders
Mikko Rasa [Tue, 23 Jul 2019 08:07:29 +0000 (11:07 +0300)]
Recognize the samplerCubeArray type in shaders

The actual extension will be added a bit later.

16 months agoSupport named postprocessor slots in pipeline templates
Mikko Rasa [Tue, 23 Jul 2019 07:07:40 +0000 (10:07 +0300)]
Support named postprocessor slots in pipeline templates

This can be useful if a postprocessor in the middle of the chain needs to
be created at runtime due to data dependencies.

16 months agoAllow access to ShadowMap's texture and matrix from outside
Mikko Rasa [Tue, 23 Jul 2019 07:04:00 +0000 (10:04 +0300)]
Allow access to ShadowMap's texture and matrix from outside

This is necessary if a postprocessor wants to access the shadow map for
deferred shading.

16 months agoRecognize #version directive in GLSL
Mikko Rasa [Thu, 11 Jul 2019 22:22:59 +0000 (01:22 +0300)]
Recognize #version directive in GLSL

This allows shaders to explicitly specify the required version in
case there's a feature which is not detected by the program compiler
framework.

16 months agoAdd feature check for array texture samplers
Mikko Rasa [Thu, 11 Jul 2019 22:22:02 +0000 (01:22 +0300)]
Add feature check for array texture samplers

16 months agoTranslate cube map sampling function for old GLSL versions
Mikko Rasa [Thu, 11 Jul 2019 12:34:30 +0000 (15:34 +0300)]
Translate cube map sampling function for old GLSL versions

16 months agoAdd functions for setting arrays of 2x2 and 3x3 matrix uniforms
Mikko Rasa [Tue, 9 Jul 2019 22:51:37 +0000 (01:51 +0300)]
Add functions for setting arrays of 2x2 and 3x3 matrix uniforms

16 months agoMake explicit mipmap generation public
Mikko Rasa [Mon, 8 Jul 2019 16:24:02 +0000 (19:24 +0300)]
Make explicit mipmap generation public

Also changed set_generate_mipmap to set_auto_generate_mipmap to clarify
that it concerns automatic mipmap generation.

17 months agoGuard against sample points behind the camera in ambient occlusion
Mikko Rasa [Wed, 3 Jul 2019 21:06:00 +0000 (00:06 +0300)]
Guard against sample points behind the camera in ambient occlusion

17 months agoSort things by name when exporting
Mikko Rasa [Wed, 3 Jul 2019 17:26:03 +0000 (20:26 +0300)]
Sort things by name when exporting

This keeps them in deterministic order and produces cleaner diffs.

17 months agoRemove a stray debug print
Mikko Rasa [Wed, 3 Jul 2019 17:04:33 +0000 (20:04 +0300)]
Remove a stray debug print

17 months agoAdd an option to skip existing resources when exporting a scene
Mikko Rasa [Wed, 3 Jul 2019 17:01:03 +0000 (20:01 +0300)]
Add an option to skip existing resources when exporting a scene

This can be helpful when exporting multiple scenes, to avoid certain
auto-generated resources being exported multiple times.

17 months agoCorrectly process meshes with empty material slots
Mikko Rasa [Wed, 3 Jul 2019 16:35:05 +0000 (19:35 +0300)]
Correctly process meshes with empty material slots

This may happen if materials are defined on the object rather than on
the mesh.

17 months agoChange AnimationPlayer::stop to take a Placeable
Mikko Rasa [Sun, 23 Jun 2019 21:25:26 +0000 (00:25 +0300)]
Change AnimationPlayer::stop to take a Placeable

17 months agoExport the entire scene by default
Mikko Rasa [Sun, 23 Jun 2019 20:02:41 +0000 (23:02 +0300)]
Export the entire scene by default

Options have been added to export only selected object or limit the
export to active layers.

17 months agoUse double for animation curves
Mikko Rasa [Sun, 23 Jun 2019 19:38:23 +0000 (22:38 +0300)]
Use double for animation curves

Since the t value is raised to the third power, floats with their 24-bit
mantissa started to run out of precision around 30 seconds.  Doubles
should be good for several hours.  If that somehow turns out to not be
enough I'll invent some way to chain animations.

17 months agoAdd public functions for adding owned keyframes to Animation
Mikko Rasa [Sun, 23 Jun 2019 19:37:22 +0000 (22:37 +0300)]
Add public functions for adding owned keyframes to Animation

This is useful when constructing animations in code, to avoid the need
of storing pointers to the keyframes.

17 months agoRetain assignment location when moving out variables to global scope
Mikko Rasa [Fri, 21 Jun 2019 12:13:27 +0000 (15:13 +0300)]
Retain assignment location when moving out variables to global scope

17 months agoTranslate shader compile errors to actual source file names
Mikko Rasa [Fri, 21 Jun 2019 11:46:34 +0000 (14:46 +0300)]
Translate shader compile errors to actual source file names

Intel drivers appear to process the #line directives incorrectly and
produce off-by-one line numbers.

17 months agoRecord statement source lines and emit #line directives to output
Mikko Rasa [Fri, 21 Jun 2019 11:27:32 +0000 (14:27 +0300)]
Record statement source lines and emit #line directives to output

17 months agoRefactor ProgramCompiler::Formatter
Mikko Rasa [Fri, 21 Jun 2019 11:24:56 +0000 (14:24 +0300)]
Refactor ProgramCompiler::Formatter

This is necessary for keeping track of output lines and translating error
locations.

17 months agoRequire import module names to be identifiers
Mikko Rasa [Fri, 21 Jun 2019 10:25:33 +0000 (13:25 +0300)]
Require import module names to be identifiers

17 months agoConsistently use the NodeList and NodeArray types
Mikko Rasa [Fri, 21 Jun 2019 10:24:01 +0000 (13:24 +0300)]
Consistently use the NodeList and NodeArray types

17 months agoAdd an intermediate node type for statements
Mikko Rasa [Fri, 21 Jun 2019 10:19:47 +0000 (13:19 +0300)]
Add an intermediate node type for statements

17 months agoObtain the instance transform location from shader program
Mikko Rasa [Fri, 21 Jun 2019 08:32:46 +0000 (11:32 +0300)]
Obtain the instance transform location from shader program

17 months agoMerge variable declaration layouts
Mikko Rasa [Fri, 21 Jun 2019 08:23:21 +0000 (11:23 +0300)]
Merge variable declaration layouts

17 months agoConsider extensions when checking GLSL features
Mikko Rasa [Fri, 21 Jun 2019 08:22:08 +0000 (11:22 +0300)]
Consider extensions when checking GLSL features

17 months agoStore information about attributes in Program
Mikko Rasa [Thu, 20 Jun 2019 21:50:41 +0000 (00:50 +0300)]
Store information about attributes in Program

17 months agoSplit the interface queries from Program::link into separate functions
Mikko Rasa [Thu, 20 Jun 2019 08:38:11 +0000 (11:38 +0300)]
Split the interface queries from Program::link into separate functions

17 months agoInitial support for instanced rendering
Mikko Rasa [Wed, 19 Jun 2019 23:22:12 +0000 (02:22 +0300)]
Initial support for instanced rendering

This is still a bit rough and does not support things like LoDs or custom
instance attributes.

17 months agoSome refactoring of the draw code path
Mikko Rasa [Wed, 19 Jun 2019 23:01:43 +0000 (02:01 +0300)]
Some refactoring of the draw code path

These changes make it easier to add instanced versions of the draw calls.

17 months agoExpose world-to-eye matrix in Renderer's standard shdata
Mikko Rasa [Wed, 19 Jun 2019 22:55:27 +0000 (01:55 +0300)]
Expose world-to-eye matrix in Renderer's standard shdata

17 months agoAdd vertex setup state to Renderer
Mikko Rasa [Wed, 19 Jun 2019 22:54:57 +0000 (01:54 +0300)]
Add vertex setup state to Renderer

17 months agoUse direct state access for updating VertexSetup
Mikko Rasa [Tue, 18 Jun 2019 10:34:01 +0000 (13:34 +0300)]
Use direct state access for updating VertexSetup

17 months agoOnly update the changed parts of VertexSetup
Mikko Rasa [Tue, 18 Jun 2019 10:28:04 +0000 (13:28 +0300)]
Only update the changed parts of VertexSetup

Besides being a minor optimization, this fixes a crash if update gets
called before both vertex array and index buffer are set.

17 months agoMove vertex array object management out of Mesh
Mikko Rasa [Tue, 18 Jun 2019 08:42:22 +0000 (11:42 +0300)]
Move vertex array object management out of Mesh

It's called VertexSetup because VertexArray was already in use.  On the
other hand I don't want to tie VAOs with the VertexArray class because
instanced rendering will need two VertexArrays in a single VAO.

17 months agoChange the return type of Renderable::get_instance_key to IntPtr
Mikko Rasa [Mon, 17 Jun 2019 22:12:35 +0000 (01:12 +0300)]
Change the return type of Renderable::get_instance_key to IntPtr

17 months agoMake a const pointer to a Bufferable's buffer publicly accessible
Mikko Rasa [Mon, 17 Jun 2019 20:29:59 +0000 (23:29 +0300)]
Make a const pointer to a Bufferable's buffer publicly accessible

17 months agoUse linear filtering when rendering bloom
Mikko Rasa [Mon, 17 Jun 2019 20:25:49 +0000 (23:25 +0300)]
Use linear filtering when rendering bloom

This postprocessor is often rendered at a reduced resolution, and nearest
filtering causes the output to appear blocky.

17 months agoBetter checking of the existence of image filepath
Mikko Rasa [Sun, 16 Jun 2019 10:15:32 +0000 (13:15 +0300)]
Better checking of the existence of image filepath

Apparently packed images can get funny filepaths like "//../../../../"
in autosaves.  Best to check only the basename so there won't be empty
filenames in datafiles.

17 months agoCheck the result of open_raw
Mikko Rasa [Sun, 16 Jun 2019 10:14:55 +0000 (13:14 +0300)]
Check the result of open_raw

17 months agoAdd simple ligature support to Font
Mikko Rasa [Sun, 16 Jun 2019 08:54:18 +0000 (11:54 +0300)]
Add simple ligature support to Font

Currently only two-character ligatures are supported.

17 months agoAdd looping detection to animation exporter
Mikko Rasa [Sun, 16 Jun 2019 08:52:27 +0000 (11:52 +0300)]
Add looping detection to animation exporter

Since Blender's actions do not have a looping property, detect looping by
comparing the first and last keyframes of each curve.

17 months agoSet both min and mag filters when exporting textures
Mikko Rasa [Sun, 16 Jun 2019 08:48:52 +0000 (11:48 +0300)]
Set both min and mag filters when exporting textures

17 months agoImport fixes for exporter
Mikko Rasa [Sun, 16 Jun 2019 08:48:32 +0000 (11:48 +0300)]
Import fixes for exporter

17 months agoMake ambient occlusion edge detection threshold adjustable
Mikko Rasa [Sat, 15 Jun 2019 12:23:02 +0000 (15:23 +0300)]
Make ambient occlusion edge detection threshold adjustable

This may be necessary to avoid artifacts when running the postprocessor
at a reduced resolution.

17 months agoUse RED format for ambient occlusion render target
Mikko Rasa [Sat, 15 Jun 2019 12:20:44 +0000 (15:20 +0300)]
Use RED format for ambient occlusion render target

17 months agoImprove ambient occlusion edge detection
Mikko Rasa [Sat, 15 Jun 2019 12:18:09 +0000 (15:18 +0300)]
Improve ambient occlusion edge detection

The depth thresholds are now based on the distance of the sample from the
center, which works better in the presence of sloped flat surfaces.

17 months agoUse mspdatatool to generate the builtin resources file
Mikko Rasa [Wed, 12 Jun 2019 17:08:38 +0000 (20:08 +0300)]
Use mspdatatool to generate the builtin resources file

17 months agoUse a type registry to manage postprocessor types for pipeline templates
Mikko Rasa [Wed, 12 Jun 2019 17:07:00 +0000 (20:07 +0300)]
Use a type registry to manage postprocessor types for pipeline templates

17 months agoAdd overloads of keyframe uniform statements without size suffixes
Mikko Rasa [Tue, 11 Jun 2019 21:19:10 +0000 (00:19 +0300)]
Add overloads of keyframe uniform statements without size suffixes

17 months agoFix a data corruption issue in mesh exporter
Mikko Rasa [Tue, 11 Jun 2019 21:07:38 +0000 (00:07 +0300)]
Fix a data corruption issue in mesh exporter

Apparently mathutils.Vector can refer to external data, in this case the
mesh's UV coordinates, which gets deleted with the mesh.  Copy the values
to make sure they are retained.

17 months agoRemove an incorrect and unnecessary check in scene exporter
Mikko Rasa [Tue, 11 Jun 2019 21:06:28 +0000 (00:06 +0300)]
Remove an incorrect and unnecessary check in scene exporter

Technique was moved from Object to Material.

17 months agoAdd an option to export all animations for all selected objects
Mikko Rasa [Tue, 11 Jun 2019 16:50:14 +0000 (19:50 +0300)]
Add an option to export all animations for all selected objects

17 months agoAdjust exported animation keyframes to start from zero time
Mikko Rasa [Tue, 11 Jun 2019 16:49:01 +0000 (19:49 +0300)]
Adjust exported animation keyframes to start from zero time

17 months agoAdd exporter for animations
Mikko Rasa [Tue, 11 Jun 2019 08:31:44 +0000 (11:31 +0300)]
Add exporter for animations

17 months agoAnimate only those components which are present in Transforms
Mikko Rasa [Tue, 11 Jun 2019 08:15:09 +0000 (11:15 +0300)]
Animate only those components which are present in Transforms

This allows different components to have different keyframes, matching
the functionality of various animation software packages.

17 months agoKeep track of which components have been set in Transform
Mikko Rasa [Tue, 11 Jun 2019 08:03:24 +0000 (11:03 +0300)]
Keep track of which components have been set in Transform

Also allow individual vector elements to be specified in datafiles.

17 months agoFix a copypaste error in AnimationPlayer uniform setting code
Mikko Rasa [Sat, 8 Jun 2019 18:08:00 +0000 (21:08 +0300)]
Fix a copypaste error in AnimationPlayer uniform setting code

17 months agoFix the keyword of the uniform scaling statement in Transform loader
Mikko Rasa [Sat, 8 Jun 2019 11:26:52 +0000 (14:26 +0300)]
Fix the keyword of the uniform scaling statement in Transform loader

17 months agoAdd getter for Animation::looping
Mikko Rasa [Sat, 8 Jun 2019 07:16:27 +0000 (10:16 +0300)]
Add getter for Animation::looping

17 months agoMerge branch 'animation-rework'
Mikko Rasa [Sat, 8 Jun 2019 06:50:02 +0000 (09:50 +0300)]
Merge branch 'animation-rework'

17 months agoAdd compatibility support for slope-based animation interpolation
Mikko Rasa [Sat, 8 Jun 2019 06:47:24 +0000 (09:47 +0300)]
Add compatibility support for slope-based animation interpolation

17 months agoAdd a setter for KeyFrame uniforms
Mikko Rasa [Sat, 8 Jun 2019 06:47:00 +0000 (09:47 +0300)]
Add a setter for KeyFrame uniforms

17 months agoRefactor KeyFrame ownership management in Animation
Mikko Rasa [Sat, 8 Jun 2019 06:17:51 +0000 (09:17 +0300)]
Refactor KeyFrame ownership management in Animation

The public add_keyframe functions no longer provide a convenient single
place to set the RefPtr keep flag, so move it into the private function.

17 months agoUse bezier splines in Animation
Mikko Rasa [Fri, 7 Jun 2019 23:17:43 +0000 (02:17 +0300)]
Use bezier splines in Animation

Control keyframes can now be added to affect the shape of curves.  Zero,
one or two control keyframes can be present between any two regular
keyframes, resulting in a linear, quadratic or cubic segment.

17 months agoMake animation curve creation more generic
Mikko Rasa [Fri, 7 Jun 2019 22:30:11 +0000 (01:30 +0300)]
Make animation curve creation more generic

17 months agoDo not clear previous assignments on assignment to array subscript
Mikko Rasa [Fri, 7 Jun 2019 19:18:05 +0000 (22:18 +0300)]
Do not clear previous assignments on assignment to array subscript

It makes manual array impossible if the previous elements are thrown
away.

17 months agoVisit the rest of an iteration statement in NodeRemover
Mikko Rasa [Fri, 7 Jun 2019 17:27:57 +0000 (20:27 +0300)]
Visit the rest of an iteration statement in NodeRemover

17 months agoAvoid some brain damage from Windows headers
Mikko Rasa [Thu, 6 Jun 2019 12:57:11 +0000 (15:57 +0300)]
Avoid some brain damage from Windows headers

17 months agoReimplement Animation using splines
Mikko Rasa [Wed, 5 Jun 2019 22:02:41 +0000 (01:02 +0300)]
Reimplement Animation using splines

Transform interpolation is now performed on individual components rather
than entire matrices.  This produces more accurate rotations and later
will allow animations to only affect some components of the transform.

Currently linear splines are used and the slope parameters are ignored.
Pose matrices are also disabled for now because I don't have any suitable
data for testing them.  The old implementation was broken in various ways
anyway.

17 months agoCheck for armature mismatches in Animation
Mikko Rasa [Tue, 4 Jun 2019 22:42:49 +0000 (01:42 +0300)]
Check for armature mismatches in Animation

Also set the armature if a keyframe with a pose is added and there is no
armature yet.

17 months agoStore a Transform in keyframes instead of a Matrix
Mikko Rasa [Tue, 4 Jun 2019 14:13:59 +0000 (17:13 +0300)]
Store a Transform in keyframes instead of a Matrix

This is the first step towards curve-based animations and finer control
over which values are animated.

17 months agoAdd more public methods to Transform
Mikko Rasa [Tue, 4 Jun 2019 11:11:45 +0000 (14:11 +0300)]
Add more public methods to Transform

17 months agoExport world transforms for scene objects
Mikko Rasa [Tue, 4 Jun 2019 10:39:27 +0000 (13:39 +0300)]
Export world transforms for scene objects

The location, rotation and scale properties contain transform components
relative to the somewhat arbitrary basis matrix.  Obtain the values from
the world matrix instead.  A drawback is that nonuniform or negative
scaling can produce inconsistent results.

17 months agoUse transform blocks to specify object transforms in exported scenes
Mikko Rasa [Tue, 4 Jun 2019 10:00:07 +0000 (13:00 +0300)]
Use transform blocks to specify object transforms in exported scenes

17 months agoMove transform loading to ObjectInstance
Mikko Rasa [Tue, 4 Jun 2019 09:26:54 +0000 (12:26 +0300)]
Move transform loading to ObjectInstance

17 months agoAdd a class to unify loading coordinate transforms
Mikko Rasa [Tue, 4 Jun 2019 07:39:17 +0000 (10:39 +0300)]
Add a class to unify loading coordinate transforms

It will also be useful for animations.  Euler angles are not the ideal
way of storing rotations but they are relatively easy to understand and
work with.  Other rotation types will be added in the future.

17 months agoDo not use the srgb flag for textures that explicitly define storage
Mikko Rasa [Tue, 4 Jun 2019 07:23:39 +0000 (10:23 +0300)]
Do not use the srgb flag for textures that explicitly define storage

Presumably the texture author knows which colorspace the texture uses.
In particular this made it impossible to load non-color textures such
as normal maps which require a linear colorspace if the srgb flag was
set in the containing resource collection.

18 months agoUpdate deprecated things
Mikko Rasa [Mon, 3 Jun 2019 16:43:41 +0000 (19:43 +0300)]
Update deprecated things

18 months agoBetter naming algorithm for objects in scene export
Mikko Rasa [Sat, 1 Jun 2019 12:55:28 +0000 (15:55 +0300)]
Better naming algorithm for objects in scene export

Arbitrary prefixes can cut words or numbers in silly places.  Only allow
truncating at common separator characters.

18 months agoAdd getters for RenderTarget width and height
Mikko Rasa [Fri, 31 May 2019 19:30:20 +0000 (22:30 +0300)]
Add getters for RenderTarget width and height

18 months agoFix a texture data indexing bug in AmbientOcclusion
Mikko Rasa [Thu, 30 May 2019 10:54:42 +0000 (13:54 +0300)]
Fix a texture data indexing bug in AmbientOcclusion

18 months agoRecognize displacement map textures when exporting
Mikko Rasa [Wed, 29 May 2019 17:19:41 +0000 (20:19 +0300)]
Recognize displacement map textures when exporting

18 months agoAlways export texture data inline if there's no image file
Mikko Rasa [Wed, 29 May 2019 17:17:56 +0000 (20:17 +0300)]
Always export texture data inline if there's no image file

This allows exporting packed or baked textures.

18 months agoInline functions in variable initialization expressions
Mikko Rasa [Tue, 28 May 2019 08:59:45 +0000 (11:59 +0300)]
Inline functions in variable initialization expressions

If the entire expression was a function call, it didn't get inlined
because VariableDeclaration wasn't being handled separately.

18 months agoAdd an exporter for Blender cameras
Mikko Rasa [Sun, 26 May 2019 18:18:01 +0000 (21:18 +0300)]
Add an exporter for Blender cameras

18 months agoMark datafile tokens as such
Mikko Rasa [Sun, 26 May 2019 18:17:42 +0000 (21:17 +0300)]
Mark datafile tokens as such

18 months agoSupport while loops in GLSL
Mikko Rasa [Sat, 25 May 2019 21:58:17 +0000 (00:58 +0300)]
Support while loops in GLSL

Loops with only a condition expression present are now emitted as while
loops, even if they were originally for loops.

18 months agoImprove formatting of an empty loop body
Mikko Rasa [Sat, 25 May 2019 21:55:10 +0000 (00:55 +0300)]
Improve formatting of an empty loop body

18 months agoAllow removing the initialization statement of a for loop
Mikko Rasa [Sat, 25 May 2019 21:53:05 +0000 (00:53 +0300)]
Allow removing the initialization statement of a for loop

Previously the compiler would recognize it as unused but couldn't remove
it, leading it to repeat the optimizer endlessly.

18 months agoMake all components of a for loop optional
Mikko Rasa [Sat, 25 May 2019 21:52:33 +0000 (00:52 +0300)]
Make all components of a for loop optional

18 months agoRemove an XXX because I no longer remember how to reproduce the issue
Mikko Rasa [Sat, 25 May 2019 21:25:34 +0000 (00:25 +0300)]
Remove an XXX because I no longer remember how to reproduce the issue

Next time I should include a test case.

18 months agoFix various issues with constant condition elimination
Mikko Rasa [Sat, 25 May 2019 21:00:54 +0000 (00:00 +0300)]
Fix various issues with constant condition elimination

It used to optimize based on the initial values of variables, ignoring
the fact that they may change between loop iterations.  A stop-gap fix
was implemented in 8e14c29, but it prevented optimizations of some
conditionals that could safely have been removed.  It also caused the
optimizer to ignore any assignments made to any variables after
declaration when evaluating the loop condition, potentially causing
entire loops to be erroneously removed.  Finally, unary expressions were
not being handled so ++ and -- operators did not mark the variable as
modified.

18 months agoProcess MemberAccess nodes in FunctionInliner
Mikko Rasa [Fri, 24 May 2019 22:32:17 +0000 (01:32 +0300)]
Process MemberAccess nodes in FunctionInliner

18 months agoCorrectly parse consecutive *s in a comment
Mikko Rasa [Fri, 24 May 2019 22:07:03 +0000 (01:07 +0300)]
Correctly parse consecutive *s in a comment

Parsing state must not be reset at ** because there may be a / after.