Mikko Rasa [Sun, 28 Mar 2021 14:01:10 +0000 (17:01 +0300)]
Fix loading .tex2d files with ResourceManager
The texture's loader already informs the resource manager of the location
of the image, so it shouldn't be done here. There's also no need to load
the image first anymore.
Mikko Rasa [Sun, 28 Mar 2021 13:48:48 +0000 (16:48 +0300)]
Move checking of vertex attribute indices to VertexSetup
This avoids issues when loading meshes with ResourceManager, since it's
not possible to read the value of GL_MAX_VERTEX_ATTRIBS from the loading
thread.
Mikko Rasa [Sun, 28 Mar 2021 13:12:35 +0000 (16:12 +0300)]
Refactor lexical conversion of vertex attributes
There was an error in the size of the base string for the GENERIC
attribute, causing it to never match. Using a utility function makes
it less dependent on magic numbers.
Color is still handled specially because of the type suffix.
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.