Mikko Rasa [Sun, 28 Mar 2021 09:47:29 +0000 (12:47 +0300)]
Fix exporting of materials without any textures
If a generator expression produces no items, trying to access __next__()
produces a StopIteration exception. It's better to create a list so we
can check if it's empty.
Mikko Rasa [Sun, 28 Mar 2021 09:46:33 +0000 (12:46 +0300)]
Fix and improve vertex group support
Some parts of the export code had gotten out of sync in 306be12.
Groups and weights now have dedicated attributes instead of using an
arbitrary generic attribute. They're also separate attributes,
allowing up to four groups per vertex.
Mikko Rasa [Sun, 21 Mar 2021 16:11:14 +0000 (18:11 +0200)]
Fix suspicious code in the mesh exporter
The pivot_vertices function was expecting a list of vertices, but only
one vertex was passed in. In fact the entire function seemed rather
useless now that the mesh is triangulated at an early stage.
Mikko Rasa [Sun, 21 Mar 2021 15:28:59 +0000 (17:28 +0200)]
Rearrange vertex attributes
Since fixed function is no longer supported, I don't have to care what
attribute number Nvidia gives the fixed function attributes. The old
layout had weird holes and made custom attributes hard to add; now the
free attributes are neatly at the end.
The duality between standard and generic attributes has been removed.
User-defined attributes now have their own range. No deprecated
versions have been kept since they would be difficult to support
properly.
Mikko Rasa [Sun, 21 Mar 2021 09:40:30 +0000 (11:40 +0200)]
Rename VertexComponent to VertexAttribute
Also rename the related functions. Get_component_type and
get_component_size in particular were problematic since pixelformat.h
uses the same names, and the ones in vertexformat.h don't take an enum
type.
Mikko Rasa [Sat, 20 Mar 2021 15:33:40 +0000 (17:33 +0200)]
Support exporting unlit materials
These use the emission surface type in Blender. While that may seem
strange at first, it's actually a good match to how unlit materials
behave in a realtime scene.
Mikko Rasa [Sat, 20 Mar 2021 13:37:12 +0000 (15:37 +0200)]
Adjust uniform organization for UnlitMaterial
Its only property are now stored in a struct to match other material
types. This allows using the name "color" without conflicting with the
vertex attribute. The texture uniform was also renamed in order to
avoid clashing with the texture() function.
Mikko Rasa [Sat, 20 Mar 2021 11:44:09 +0000 (13:44 +0200)]
Decouple DataType from the OpenGL constants
This allows defining the values so that manipulation of related types is
easier. And I can't keep relying on the GL values anyway, with the goal
of adding a Vulkan backend.
Mikko Rasa [Tue, 16 Mar 2021 09:38:55 +0000 (11:38 +0200)]
Don't modify the target block's variable map from InlineContentInjector
This felt hacky, and also seemed wrong since the variable map contains
the original names of the variables, not new ones. Instead avoid
inlining more than one function per pass into any given function.
Mikko Rasa [Mon, 15 Mar 2021 09:05:12 +0000 (11:05 +0200)]
Implement constant folding in the GLSL compiler
This replaces the old expression evaluator with a more comprehensive
solution. Folding constant expressions may open up further possibilities
for inlining.
Mikko Rasa [Sat, 13 Mar 2021 11:38:26 +0000 (13:38 +0200)]
Make it deprecated to redeclare non-builtin variables
This is no longer necessary now that specialization constants are
supported. There's some additional rules for declaring builtins too,
but I'll get back to those later.
Mikko Rasa [Fri, 12 Mar 2021 09:53:11 +0000 (11:53 +0200)]
Limit GLSL passthrough statement to variables declared by that point
This fixes an issue where a base module's passthrough statement would
generate references to inputs declared in an importing module, resulting
in a compile error.
Mikko Rasa [Wed, 10 Mar 2021 11:01:12 +0000 (13:01 +0200)]
Rewrite UnusedVariableRemover
The old implementation was getting too complex with its multitude of
flags. The new one is based on the idea of reaching definition analysis
and is much more straightforward.
Mikko Rasa [Wed, 10 Mar 2021 10:12:26 +0000 (12:12 +0200)]
Make ConstantConditionEliminator less trigger-happy
Since I removed the variable value tracking in 1cd0ea7 it started
optimizing conditions on specialization constants, even when they
had not been specialized yet.
Mikko Rasa [Tue, 9 Mar 2021 10:05:29 +0000 (12:05 +0200)]
Handle expression replacement through TraversingVisitor
There were several cases missing, like VariableResolver not handling
replacement of swizzles in return statements. This way each of the
visitors can just concentrate on what they're actually doing.
Mikko Rasa [Tue, 9 Mar 2021 07:43:08 +0000 (09:43 +0200)]
Record assignment targets more precisely
If the assignment is to a structure or vector field or an array element,
it's recorded to the node so optimizers can better match assignments and
references (they don't do that yet).