Mikko Rasa [Sat, 3 Apr 2021 16:33:29 +0000 (19:33 +0300)]
Add legacy conversion for binding layout qualifiers
These are not yet used by Program because there's no good way to detect
which uniforms had bindings in case the implementation does support the
qualifiers. Anything missing a binding gets assigned binding 0, which
is also a valid manually specified binding. Upcoming commits will move
bindings entirely to GLSL side.
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.