Commit Graph

37 Commits (376ca5a9dfb6b51ad02253a429ef0bd935d85799)

Author SHA1 Message Date
Julius Michaelis 376ca5a9df Prevent using USE_CONSOLE in lib{misc,c4script} 2016-10-22 17:42:23 +02:00
Nicolas Hake eabca223f5 Update all copyright notices for 2016 2016-04-03 20:24:42 +02:00
Nicolas Hake 493c276126 Rewrite header inclusions to #include "path/to/file.h" style 2016-04-03 20:24:42 +02:00
Nicolas Hake ebfacb928d GLSL: Improve line information in error messages
Instead of making the user count lines from the shader log, we'll now
emit #line directives and a file number->name mapping to make it easier
to figure out which file and line the error message comes from.
2016-04-03 16:17:39 +02:00
Günther Brammer a1a6e36cde GL: Deduplicate the check for glObjectLabel 2016-01-29 18:37:32 +01:00
Armin Burgmeier 16d2eb5cb1 Use the core api for shaders instead of the ARB one 2016-01-17 11:37:17 -08:00
Armin Burgmeier d72b8cc385 Use generic vertex attributes for FoW rendering 2016-01-02 19:11:41 -08:00
Armin Burgmeier 95774e0e8f Use generic vertex attributes for sprites, meshes, particles 2016-01-02 13:10:03 -08:00
Armin Burgmeier c0844c10ff Add support for generic attributes to C4Shader
Replace the hardcoded VAI_ constants with that. The VAI constants are now
moved to C4DrawGL as C4SSA_ constants, similar to the C4SSU ones. This allows
to introduce other attributes to replace vertex positions, normals, colors
and texture coordinates with attributes in later commits. This, in turn, is
needed because the built-in attributes are no longer available in the OpenGL
core profile.

Also, while at it, cleanup C4Shader a bit. Use std::vector<> instead of
maintaining an own array of uniform names. Delete the vertex and fragment
objects after the full shader program has been linked. Make sure that
C4Shader::Init keeps the old program in place if the new one cannot be
compiled or linked.
2015-12-31 22:28:23 -08:00
Armin Burgmeier 8766f5123b Remove other usages of built-in GL matrices
Primarily for the FoW rendering, which now also uses (simple) shaders
without ftransform() everywhere. This also removes all GLU calls.
2015-12-31 17:30:21 -08:00
Nicolas Hake f0eeb3f6b3 Make headless build compile again 2015-12-15 19:45:32 +01:00
Nicolas Hake 24b54211c5 Drop Min, Max, Swap for std::min, std::max, std::swap
The C++ standard library comes with perfectly fine implementations of
these functions, so there's no point in reimplementing them just for the
hell of it.
2015-11-15 13:53:01 +01:00
Peter Wortmann 86679d2fb0 Allow all shaders to refresh
The solution is slightly hacky and not entirely stable, but for fine-
tuning this functionality is essential.

While I was at it, also reduced refresh interval so it doesn't have a
chance to lag the game.
2015-10-04 14:25:56 +01:00
Peter Wortmann f0030e33e0 Warning fixes
Actually pretty sure a few of them were bugs. Hopefully no new
ones were introduced here.
2015-10-03 15:32:39 +01:00
Armin Burgmeier 061305c0c7 Don't enable textures in C4ShaderCall::AllocTexUnit
This was only necessary with the fixed function pipeline, but not when
using shaders.
2015-09-16 21:45:30 -04:00
Nicolas Hake 5ef76d63a9 Log the same shader code as is actually compiled
For whatever reason, the shader code that was passed to the compiler was
different from the code that got written to the shader log. This is a
huge pain in the ass when trying to debug shader errors because the line
information is completely wrong. I assume this decision was a premature
optimization, so I've removed it and we'll now log the exact same code
as the shader compiler sees.
2015-08-16 14:20:50 +02:00
Nicolas Hake 9eb8eedf82 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.
2015-06-17 21:30:56 +02:00
Nicolas Hake 7381ef7df0 gl: Enable shader logging if DebugOpenGL is active 2015-03-31 17:57:59 +02:00
Nicolas Hake 22a838a0f3 Don't use formatting log function for fixed string (#1293) 2015-03-28 15:10:35 +01:00
Nicolas Hake b2f742f997 gl: Check glew for GL_KHR_debug support
Debian wheezy's glew doesn't support GL_KHR_debug yet, so make sure
we're only using it if we can.
2015-03-25 23:15:45 +01:00
Nicolas Hake cd266d2352 gl: Attach debug labels to objects
Doing GL debugging is way easier if your logs talk about "Clonk/VBO"
instead of "buffer object 21".
2015-03-25 22:00:36 +01:00
Nicolas Hake 5562b09dc4 Remove a lot of disabled legacy code, round 2
Maybe at some point we'll be rid of all the commented-out code that
nobody has looked at in years.
2015-03-25 20:02:53 +01:00
Nicolas Hake 4639ce1675 Merge GPU skinning
Doing skinning on the GPU shows a noticeable performance improvement in
pretty much any situation, but especially so in scenes with lots of
animated objects with high polygon counts.
2015-03-04 12:26:51 +01:00
Nicolas Hake 2db2992f85 Don't check for errors in C4ShaderCall::Finish
Calling CStdGL::CheckGLError calls glGetError, which is really, really
slow because it has to flush the pipeline to check whether there's an
error or not. Plus it's not like we can do anything about it anyway. If
you want to be notified when an error happens, pass --debug-opengl to
the executable.
2015-03-01 22:42:23 +01: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
Nicolas Hake 4db690b0c6 Add copyright header to files that were missing it 2015-02-16 18:40:52 +01:00
Nicolas Hake eed1c43b8a GL: Correctly encode error strings
gluErrorString returns latin-1 encoded strings. Our code expects to
receive UTF-8 encoded strings everywhere, so make sure that the strings
are converted before passing them on.
2015-02-16 15:39:05 +01:00
Sven Eberhardt 49f991c819 Move shader logging into separate file and log only in editor mode (#1209) 2015-01-03 17:53:59 +01:00
Armin Burgmeier 8686441d45 Make mesh shaders use the C4Shader slice machinery 2014-12-22 22:56:30 +01:00
Armin Burgmeier fdd94a3311 Add named slice positions for vertex shaders 2014-12-22 22:56:30 +01:00
Armin Burgmeier 574149e289 Pick up a shader slice only after a newline
Otherwise a workaround such as "#define slice(x)" would not work for non-OC
shader code.
2014-12-22 22:56:30 +01:00
Armin Burgmeier d6bdf9a6e0 Add possibility to add vertex slices from the parser 2014-12-22 22:56:30 +01:00
Armin Burgmeier 7f1cf15274 Change slice syntax such that positions appear in parentheses
This allows to ignore slice declarations using `#define slice(x)`, which
mill be useful for custom mesh material shaders, allowing to write them
such that they can be used standalone in a mesh viewer but also as slices
for OpenClonk, in which case lighting and color modulation will be applied
automatically.
2014-12-22 22:56:30 +01:00
Armin Burgmeier 5c6ed34a3a C4Shader: Deactivate shader units in reverse order
This makes sure that GL_TEXTURE0 is the active texture unit
after the shader call. Some parts of the engine such as the
particle system rely on that.
2014-11-24 14:51:08 -05:00
Armin Burgmeier 292f8e8191 Improve GL error outputs 2014-11-24 14:51:08 -05:00
Peter Wortmann 7fea618221 Collected trivial bug-fixes
Turns out we actually can't optimise out the second texture normal
lookup - it makes a noticeable difference in-game. Also there was
possible slice collision, it might be worth warning about this kind
of stuff.

Also removed unused variable, and made error messages more consistent
in terms of whitespace.
2014-11-20 21:44:11 +01:00
Peter Wortmann 72289713f9 Modular shader system
The idea here is that we compose shaders out of "slices", which can
come from the engine ("built-in"), from files or possibly even from
models. This should allow us to more easily share the code between
different rendering shaders (e.g. for lights / normals).

TODO: Workarounds not yet implemented, so this might degrade less
gracefully.
2014-11-20 11:52:14 +01:00