Commit Graph

25 Commits (652c7e43e23652fb8bf05b4b57e6db36b0eb765c)

Author SHA1 Message Date
Nicolas Hake 652c7e43e2 Fix headless build
Several rendering changes have resulted in a non-rendering build that
failed to build from source. Dummy out all of these functions to make it
work again.

Cherry-picked.
Author:    Nicolas Hake <isilkor@openclonk.org>
Date:      Wed Jun 17 21:30:56 2015 +0200
Conflicts:
	src/lib/StdMesh.h
2015-09-23 21:12:56 +02:00
Nicolas Hake d2563fe345 Do skinning in hardware
Instead of transforming all vertices on the CPU every time an animation
progresses, we now only recalculate the skeleton, leaving the heavy
lifting for the GPU. This also means we no longer have to push all
vertices onto the bus every frame, because the mesh isn't changing and
can therefore be stored in a GL_STATIC_DRAW VBO when it's first loaded.
The downside of this approach is that there's only a limited number of
uniforms and vertex attributes we can pass to the shader. At the moment
these limits are a maximum of 128 bones per skeleton, and no vertex can
be influenced by more than 8 bones at once. So far this is no problem,
as the most complex skeleton in the base game uses less than 64 bones
and no more than 6 bone weights per vertex.
2015-02-27 21:51:58 +01:00
Sven Eberhardt 089b4794a8 Fix a few warnings in Win64 build. 2015-01-25 16:43:51 +01:00
Nicolas Hake fef96eca9c Replace C4Surface::ppTex by a vector
This should improve cache coherency by having all surface tiles adjacent
instead of strewn across the heap. This will also remove an indirection
in the common case of only using one tile.
2015-01-18 22:59:44 +01:00
Armin Burgmeier 8686441d45 Make mesh shaders use the C4Shader slice machinery 2014-12-22 22:56:30 +01:00
Armin Burgmeier db6df15377 Add SetAmbientBrightness and GetAmbientBrightness script functions 2014-11-20 17:07:31 -05:00
Armin Burgmeier 88f8f75441 Add ambient lighting
This introduces a new texture, an ambient light map, that is generated
automatically at the beginning of the round by the sky portion of the
landscape. This basically makes everything that is close to sky visible
by default.

The shaders have been adapted so that they deploy direction-independent
lighting for the ambient component, and the current (diffuse) behaviour
for the diffuse component. This makes the shaders use an additional
texture unit that represents the ambient light. We can think about merging
this information into the light texture, but the coordinate systems are
different at the moment, so this could be performed at the stage of light
texture generation.

For meshes, the ambient material is not actually used, but instead a
diffuse light from the front is used. This makes many meshes look more
interesting, maybe also because the ambient material setting of most
meshes are not set correctly at the moment.
2014-11-17 09:35:50 -05:00
Armin Burgmeier 219fa8597c Implement light calculations for meshes 2014-11-06 15:56:19 -05:00
Armin Burgmeier a34cd5711c Add support for custom shaders in mesh material scripts 2014-10-21 15:19:30 -04:00
Armin Burgmeier 2f6d1eaa1f Parse program definitions from the material file 2014-10-21 15:19:30 -04:00
Armin Burgmeier 99fe2eca4f Fix gcc warnings about missing initializers 2014-10-21 15:19:30 -04:00
Armin Burgmeier d47a416c0f Keep track of shaders in StdMeshMatManager
This replaces the fragile ShaderRef construction in StdMeshMaterialPass, and
it allows to re-use shaders and/or programs between different materials. This
is some more preparatory work for custom shaders.
2014-10-07 12:38:08 -04:00
Nicolas Hake e0dc30c59a Update copyright notices
As discussed in http://forum.openclonk.org/topic_show.pl?tid=2917, I
have merged all copyright notices into a single file and referenced that
merged file from each source file.

For the updated source files, the timeline has been split into three
parts:
 1. Pre-RWD code (before 2001)
 2. RWD code (2001 through 2009)
 3. OpenClonk code (2009 and later)
All pre-RWD copyright notices have been left intact, as have RWD-era
copyright notices where the file did not have a RedWolf design copyright
notice but only individual author ones. All copyright notices of the
OpenClonk era have been replaced by a single notice ranging from the
first recorded year to the current year (2013). Mape code did not get a
OpenClonk Team copyright notice because it is somewhat separate from the
main OpenClonk codebase and has only been touched by Armin Burgmeier.
2013-12-23 13:03:19 +01:00
Armin Burgmeier 90fbabd20f Implement depth_check for material scripts 2013-03-31 17:14:13 +02:00
Nicolas Hake 459fce0758 Replace std::auto_ptr with std::unique_ptr
std::auto_ptr has awkward copy semantics and is deprecated in C++11.
2013-03-26 15:43:01 +01:00
Armin Burgmeier 43a2836279 Implement texture unit blending in material scripts with a shader
This might make the rendering a bit quicker, since the whole texture
environment setup that we do every frame is no longer required --
instead only the shader is bound and a few variables uploaded. However,
this was not the main motivation behind this change.

It also simplifies the code a bit. The texture environment setup is
replaced by GLSL code generation. Another small benefit is that for
texture units in material scripts that do not use an actual texture
image no hardware TIU is being used. This reduces the number of hardware
TIUs required for rendering the Clonk from 3 to 2.

The main benefit of this change, however, is that material specific
and clonk specific color variations can be applied correctly. This mainly
concerns ClrModulation and MOD2 drawing. Before, the ClrModulation was
mixed with the material color, which could lead to incorrect results
depending on what the texture units were doing. Now it is being applied
by the shader after all texture units in the material scripts have been
processed.

Another motivation of this change is to implement support for custom
shaders, which is already foreseen by OGRE material scripts. The
specification has only to be implemented. With this change in place,
both custom shaders and "fixed" processing can share the same code in
the engine, since both end up using a shader for the mesh rendering.

The shader currently works only for directional lights, but should be
easy to extend to also support point lights.
2013-02-03 16:26:01 +01:00
Günther Brammer 864c5c7ea8 copyright notices update 2012 2013-01-12 16:31:40 +01:00
Günther Brammer 1a29f8625d Reorder engine source file organization a bit
This mostly consists of flattening the hierarchy, splitting the
graphics stuff out of platform, and a few smaller cleanups.
2012-04-27 19:04:43 +02:00
Armin Burgmeier 9dc9ad4ca7 Fix initialization of AlphaToCoverage material property 2012-02-19 17:45:01 +01:00
Armin Burgmeier e52d914638 Read but ignore some more "pass" options in material scripts
These are the ones that the blender 2.6 exporter sets automatically. We don't
support them yet but we want to be able to load the material script
nevertheless. Many of the additional options are set to their default values
anyway.
2012-02-13 23:40:47 +01:00
Günther Brammer 2b6f4432de Rename lpDDraw to pDraw 2011-10-03 16:30:18 +02:00
Armin Burgmeier e9415252bc Build fix
Apparently std::map::erase does not return an iterator for some STLs.
2011-08-18 00:17:43 +02:00
Armin Burgmeier 771163be4b Correctly reload mesh materials on definition reload
This does not fix #76 yet, but it's a first step.
2011-08-17 23:50:33 +02:00
Armin Burgmeier 41a1b5867d Change .c4g extension to .ocg 2011-03-13 16:16:45 +01:00
Günther Brammer 83322f596a Move Mesh loaders from src/platform to src/lib
They are entirely platform-independent.
2011-01-19 22:55:18 +01:00