Mikko Rasa [Sat, 8 Sep 2012 14:16:55 +0000 (17:16 +0300)]
Notify Renderables about the start and end of a frame
This makes it possible for Renderables to do certain things only once per
frame. This is particularly useful for Effects which need expensive
preparation.
Mikko Rasa [Mon, 3 Sep 2012 19:06:25 +0000 (22:06 +0300)]
Fix vertex array offsets
Since array application order may now be different from the format order,
and VertexArrayBuilder stores components in the latter, calculating the
offsets while applying arrays gives wrong results.
Mikko Rasa [Sun, 2 Sep 2012 17:14:20 +0000 (20:14 +0300)]
Load VertexFormat for Mesh as an array of VertexComponents
The single-token approach made indexed attributes rather ugly. Loading
each component separately also gives better diagnostics in case of
erroneous tokens.
Mikko Rasa [Sun, 2 Sep 2012 14:50:48 +0000 (17:50 +0300)]
Rearrange vertex components
The first 16 component types are now reserved for the library. This
leaves room for adding standard generic attributes, such as TBN vectors.
To make further room, texcoords were limited to four indices.
Generic attributes are limited to 24. Current implementations seem to
only support 16 (the minimum allowed by the spec), so this is not a huge
problem. There's also exactly enough room for another set of 24 generic
integer attributes.
Mikko Rasa [Thu, 30 Aug 2012 19:35:55 +0000 (22:35 +0300)]
Move Batch members around
The helper functions for changing data type don't really need to be
members, so put them in a private namespace. Other functions rearranged
in a more sensible way.
Mikko Rasa [Wed, 29 Aug 2012 21:48:58 +0000 (00:48 +0300)]
Entirely new system for building standard shaders
The old one was becoming such a huge mess that I had to spend two minutes
doing boolean analysis to figure out the conditions for a multiplication
operator. The logic parser was also insufficient for expressing
sophisticated relationships between variables.
The new one operates with expression, starting from a target variable and
pulling in others to compute its value. The logic parser is still there,
buts its burden is greatly reduced, as most of the work is done by the
dependency resolver.
Reflections are missing at the moment, but will be added back soon. They
were pretty broken in the old system anyway, with the assumption that the
environment map is in eye space.
The generated shader code is rather verbose, containing a lot more local
variables than are needed. An optimizer will be implemented in the near
future.
Mikko Rasa [Tue, 28 Aug 2012 10:18:41 +0000 (13:18 +0300)]
Route rendering calls through Renderer and add an exclusion system
This is necessary for generating environment maps for an object, since
the object itself should not be included in the map. The alternative is
to create a separate Scene, but that's rather clumsy.
Mikko Rasa [Tue, 28 Aug 2012 09:10:38 +0000 (12:10 +0300)]
More efficient stack management
Vectors are better than lists, since they don't need to allocate new
memory for every element. A suitably sized reserve() does away with any
initial reallocations in most cases.
ProgramData in Renderer can be stored in a semi-independent stack as
well, since it can only be removed with a pop. State is now devoid of
dynamically allocated memory, making the stack operations even faster.
Mikko Rasa [Tue, 28 Aug 2012 08:30:30 +0000 (11:30 +0300)]
Fix color equations in the standard shaders
The generated shader code assigned a scalar to a vec3 if lighting was
enabled without texture or material. An unnecessary multiplication in
the alpha equation with texture but no material was removed.
Also fix texturing in the shader demo (Mesa does funny things with
uniforms).
Mikko Rasa [Tue, 28 Aug 2012 07:50:17 +0000 (10:50 +0300)]
Provide the necessary uniforms from ShadowMap
With the recent changes to the Effect and Renderer, it's finally possible
to avoid the need to specify the shadow map texture unit everywhere, and
get rid of the hardcoded gl_EyePlane* indices.
Mikko Rasa [Tue, 28 Aug 2012 07:39:19 +0000 (10:39 +0300)]
Tweak the shader functions in Renderer
Since ProgramData is no longer tied to a single Program, we can retain it
over program changes. This opens up some new possibilities, in
particular for Effects.
Mikko Rasa [Sun, 26 Aug 2012 21:38:08 +0000 (00:38 +0300)]
Pass the Renderer to ObjectInstance::get_level_of_detail
As I recall, the camera was put in renderer to allow view-dependent
rendering without the need to pass data outside the rendering pipeline.
This is one of the cases where it is needed.
Mikko Rasa [Sun, 26 Aug 2012 12:03:21 +0000 (15:03 +0300)]
Improve performance of Bufferable::update_buffer_data
... by avoiding the walk through the entire chain every time it is
called. It's not necessary to add up all the sizes either, since we can
just get the end of the last Bufferable.
Mikko Rasa [Sun, 26 Aug 2012 10:09:44 +0000 (13:09 +0300)]
Get all blocks for the program before applying them
This way, the correct size for the buffer can be determined right away,
rather than each block resizing it in turn. Binding the buffer before
applying the blocks also avoids some thrashing.
Mikko Rasa [Sun, 26 Aug 2012 07:53:56 +0000 (10:53 +0300)]
Alter the working logic of Bufferable to avoid some problems
It was possible for the buffer data to be updated without going through
the dirty check in UniformBlock::apply, leaving the UniformBlock with a
null buf_range and resulting in a segfault.
Mikko Rasa [Wed, 22 Aug 2012 13:17:34 +0000 (16:17 +0300)]
Remove the specialized setters from UniformBlock
They were not very useful and were also getting in the way of uniform
buffer support. UniformBlock also no longer clones the uniforms for
itself, reducing overhead.
Mikko Rasa [Wed, 22 Aug 2012 12:28:40 +0000 (15:28 +0300)]
Make RenderPass shprog and shdata settable from code
For consistency with other similar interfaces, the pointers are now
const. As a consequence, a uniforms statement in a datafile overrides
any previous uniforms.
Mikko Rasa [Mon, 20 Aug 2012 13:13:46 +0000 (16:13 +0300)]
Simplify Pipeline pass management
Originally I planned to use Pipelines to bundle objects with effects like
environmentally mapped reflection. However, that task was delegated to
effects themselves recently, so there's no longer need for passthrough
rendering in Pipeline. The render_all function was also a nuisance, as
it required Pipelines to be treated differently from other Renderables.
Passes are now stored in a list instead of a map. This allows multiple
passes with the same tag (think multipass lighting), and avoids the need
to store the pass order separately.