Commit Graph

75 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
Lukas Werling 19395b23ae Fix SetMatAdjust() (for kenny) 2016-06-18 17:17:43 +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 bfd9989fc6 Landscape Renderer: Create and bind 1D mat map texture before using
The landscape renderer used to store texture data into the default 1D
texture, which works but is a bad idea for several reasons (and would
have broken if we had a reason to use another 1D texture anywhere else).
2016-02-24 19:18:27 +01:00
Nicolas Hake 64a5388d4d C4Surface: Remove broken "support" for split textures
Most code already didn't handle textures larger than GL_MAX_TEXTURE_SIZE
and only used the first one in case of a split texture.
2016-02-08 17:36:50 +01:00
Nicolas Hake e9cf0f6fdc Stop pretending we support 16 bit color
The GTK and OS X platforms already ignored the requested bit depth and
always used 32 bit. Windows and SDL would set a 16 bit color depth for
the screen, but still did all of the rendering short of the final
present in 32 bit.
2016-02-02 00:00:23 +01:00
Günther Brammer fd61ac7ebe Remove unused IsRenderTarget and MaxTextureSize C4Surface options
They were always false and 0.
2016-01-17 11:37:17 -08:00
Armin Burgmeier d7d24ca36a Enable OGL core profile for linux 2016-01-17 11:37:17 -08:00
Armin Burgmeier 28aa1d1812 For each VBO, use a VAO to render it
For OpenGL 3.2 core compatibility, and to reduce the number of state
changes during rendering.
2016-01-17 11:37:17 -08:00
Armin Burgmeier fa9f4c6356 Replace GL_GENERATE_MIPMAP flag by glGenerateMipmap call
The former is not available in a OpenGL 3 core profile, but glGenerateMipmap
is available since OpenGL 3.0, and so is always available when we have a
core profile.
2016-01-17 11:37:17 -08:00
Armin Burgmeier bb8b933417 Revert "Revert "Replace 3D texture in landscape shader by a 2D texture array""
This reverts commit 4a02d3c77b.

This was merged into master even though I only wanted it in stable-7.0.
Oh well, let's just revert it again.
2016-01-17 11:37:17 -08:00
Armin Burgmeier 4a02d3c77b Revert "Replace 3D texture in landscape shader by a 2D texture array"
This reverts commit 790219ac7e.

This commit broke support for Mac OS X since Apple only supports OpenGL 3.0
with a core profile, not a compatibility profile. Revert this commit
temporarily for the 7.0 release, until we port all OpenGL usage to the core
profile with 8.0.

This fixes #1495.
2016-01-04 18:27:44 -08:00
Armin Burgmeier 96c8b51eac Use generic vertex attributes for landscape rendering 2016-01-02 17:20:24 -08:00
Armin Burgmeier b407558d7a Use a VBO to render the landscape 2016-01-01 22:28:22 -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 90293d019d C4FoWRegion: Make more private
Code outside of C4FoWRegion should not care about the internals of the
class. Therefore, we remove direct access to the backing surface (and
secondary buffer surface) and replace it instead with accessors that
return those few values that are required by outside code.
2015-12-28 21:45:21 +01:00
Armin Burgmeier 609840fda0 Fix internalFormat parameter of glTexImage* calls 2015-12-19 17:20:11 -08:00
Nicolas Hake f6efb9d219 Landscape renderer: make sure pixel accesses are within bounds
The landscape renderer didn't check that the material pixel it was
getting placement information about wasn't outside the left landscape
border.
2015-11-22 13:38:12 +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
Armin Burgmeier 6af3e4e639 Fix one-pixel edge at bottom or right of landscape (#771)
The problem comes from the fact that the landscape texture can be larger
than the actual landscape, and that for the last row or column of pixels
drawn at the edge of the landscape, the shader might access a texel that's
beyond the landscape boundaries, at least as part of its interpolation
when accessing a texture.

This patch fixes this by always making the landscape surface the same size
as the landscape, and then GL_CLAMP_TO_EDGE behaviour will prevent access to
pixels beyond the edge of the landscape. Modern hardware should handle
NPOT textures just fine, and they are already used in other places in Clonk.

If this becomes a problem and needs to be reverted, we could instead upload
the "real" landscape size to the shader, and clamp the texture coordinates
there to make sure to not read beyond the actually filled landscape surface.
2015-11-13 15:05:26 -08:00
Peter Wortmann b2150234d0 Smoother material border calculation
Before, material normal bias was calculated only from a column/row of pixels right
next to the pixel in question. This sometimes led to "lines" appearing in edge cases.
The new code modified this approach to look at a whole rectangle instead, which
gives a *lot* smoother results and is only marginally more expensive.
2015-11-12 22:18:53 +00:00
Peter Wortmann f0561cc150 Generate sensible normals for textures with them
Using (0,0,0) violates normalisation assumptions, which shifts the weight
between landscape and texture normals quite massively. The new normal
code should represent a "flat" texture properly.
2015-10-17 09:30:36 +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 cf4ed1b0b7 Shiny materials, shader reorganisation
This implements the proposal made in the forum for "shiny" materials -
material can now determine the angle at which the most light is reflected.
Shiny materials might set this lower to approximate a "reflection" effect,
and increase the "spottiness" at the same time. To compensate for the
lack of brightness without light, "emittance" can be used.

Not sure this is the most elegant way to model this - the "proper" way
here would be to have emittance, shading and specular as three separate
light parameters instead of molding one into the other and using the third
to compensate.

Furthermore, this reorganises shaders in a major way: We reduce the
number of shader files down to three, pushing a number of possible
configurations into preprocessor. I believe this should be easier to
understand, which for the moment trumps theoretical extensibility
benefits.
2015-10-03 15:32:39 +01:00
Armin Burgmeier 653680b296 Revert "Add Scale parameter in materials"
This reverts commit 8ef1f908cc. This seems to be
a performance bottleneck on some graphics cards and/or drivers. Clonkonaut
reports issues with a Radeon HD 7800.

This feature is not vital since textures can always be drawn such that they
tile properly at 512x512. While that particular problem with the Radeon card
could probably be worked around, it's just not worth it.
2015-09-19 17:26:46 -04:00
Armin Burgmeier 8ef1f908cc Add Scale parameter in materials
This allows to scale textures up or down from their initial size, allowing
them to tile at intervals other than 512x512.
2015-09-19 10:48:28 -04:00
Armin Burgmeier fd285f6656 Create mipmaps only for static textures that are expected to be zoomed
Hopefully fixes #1403.
2015-09-18 21:10:39 -04:00
Armin Burgmeier 5d2e36149b Don't warn if a smaller material texture is perfectly tileable 2015-09-17 18:55:41 -04:00
Armin Burgmeier c28c63ce0d Remove some now unused code in C4LandscapeRender.cpp 2015-09-16 22:01:51 -04:00
Armin Burgmeier 790219ac7e Replace 3D texture in landscape shader by a 2D texture array
A texture array is conceptionally what should be used in this case. One
advantage of this is that we don't have to generate mipmaps ourselves but can
let the graphics driver take care of it. Same for selection of the mipmap
level. This would even allow to choose different mipmap levels for different
textures.

This is a somewhat experimental change since it makes OpenGL 3.0 a hard
requirement for OpenClonk. I expect that this is fine, but if this causes
failures during landscape creation on common hardware/drivers we should
revisit.
2015-09-16 21:45:30 -04: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
Armin Burgmeier f3da8525d0 Prefix most shader defines with "OC_" 2015-09-10 19:45:43 -04:00
Peter Wortmann 30857e835e Shader gamma implementation
In comparison to the old system, this is a downgrade - instead of being
able to set a full color mapping by gamma ramp, we now get just a value
per colour channel.

Upside is that we do not need to play around with the global gamma ramps
any more, which was arguably the wrong way to do it.

This commit will likely break everything that has been using gamma so far.
2015-08-31 17:35:08 +01:00
Peter Wortmann 65d9953d32 Some clean-ups
Nothing spectacular. Main thing is that the light debug view is now even
more colourful.
2015-02-23 11:54:41 +01:00
Nicolas Hake 4db690b0c6 Add copyright header to files that were missing it 2015-02-16 18:40:52 +01:00
Nicolas Hake c809ab4ae3 gl: Use glDeleteTextures instead of glDeleteObject to delete textures
glDeleteObject doesn't delete textures, it deletes shader objects.
2015-02-16 18:07:03 +01:00
Nicolas Hake 50a81a8dc7 gl: Don't call glDeleteObjectARB on null objects
glDeleteObjectARB will flag GL_INVALID_PARAMETER when it's called with a
null parameter. Avoid this so the error list doesn't get tainted.
2015-02-16 17:45:17 +01:00
Nicolas Hake e21a5bdd44 Rename BoundBy to Clamp
"BoundBy" sounds like a predicate. "Clamp" is a common function name for
the operation in graphics processing, so it should be familiar to users.
2015-02-12 23:05:55 +01:00
Sven Eberhardt cd3b969fc4 Silence a few warnings in render and SolidMask code. 2015-02-08 12:37:00 +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 e1d1d540c7 Allow independent viewport and light regions in C4FoWRegion (#1211)
With this change, an additional rectangle is stored in C4FoWRegion that
represents the area covered by the viewport in fractional floating point
coordinates. This allows the light texture to be created for an arbitrary
portion of the landscape, and the coordinate transformations for the
shaders will still work.

Also, since the additional rectangle uses floating point precision, the
computed coordinate transformations do now give the exact same result as for
the landscape pixel-by-pixel, and there should not be any offsets left.

I also hope that this change improves or fixes the single-pixel-lines of sky
that are sometimes seen at the edges of the viewport.
2015-01-07 19:44:31 +01:00
Tobias Zwick 3e307fc843 fix previous commit 2015-01-01 17:27:41 +01:00
Tobias Zwick 2a4b268087 fix the same bug as Sven2 10 minutes ago, but also clean up the update function, rename variables, add comments, etc. 2015-01-01 16:08:32 +01:00
Sven Eberhardt 9a87240d47 Fix off-by-one error in landscape X bias calculation. 2015-01-01 15:52:15 +01:00
Armin Burgmeier a3049207c9 Use full ambient lighting in global viewports
This allows to see the whole landscape without any areas covered by FoW
in the global viewport. Basically the ambient lighting is set to 1.0
independent of the ambient light map. In the course of this, a second
shader for the landscape has been introduced.
2014-12-28 15:07:42 +01:00
Armin Burgmeier 8116a96ed4 Fix fragment coordinate transforms (#1192)
There were two problems with the previous transforms:
  1) For inverting the Y axis for the ambient map, the total height of the
     output window is needed, not only the viewport region.
  2) The Y offset to only use the part of the light texture that is being
     rendered to was not applied.

In order to keep the transformations more readable, a new lightweight class
C4FragTransform has been introduced which can only handle translations
and scales in x and y.
2014-12-26 16:16:09 +01:00
Armin Burgmeier 8c42704181 Rename some shader files and add basic shader for meshes 2014-12-22 22:56:30 +01:00
Armin Burgmeier e58b62920c Change extension of shader files from .c to .glsl 2014-11-25 11:54:36 -05:00