Commit Graph

366 Commits (b8953d8a097126d41c0da741a9aca7def98d9fde)

Author SHA1 Message Date
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
Nicolas Hake 5a9baeddbf C4FoWRegion: Turn some owned pointers into std::unique_ptr 2015-12-28 21:45:19 +01:00
Nicolas Hake 46abecded7 C4FoWRegion: Merge Clear() into dtor 2015-12-28 21:45:15 +01:00
Nicolas Hake b36a9ec5b5 C4Draw: Remove C4Draw::IsShaderific()
In a surprising touch, using shaders to affect pretty much every pixel
that gets drawn on screen means there is little reason for code to ask
the renderer if it knows about shaders.
2015-12-27 01:54:41 +01:00
Armin Burgmeier a487457563 Add a 4x4 matrix class (StdProjectionMatrix)
This makes it easier to convert the projection and modelview matrices
to GLSL uniforms.
2015-12-24 23:01:52 -08:00
Armin Burgmeier 43e50f9320 Drop usage of gluErrorString
There are only a couple of error values worth considering, so we can just
write out own function for it. Disable error checking in C4FoWRegion.cpp as
well, since we have the --debug-opengl flag now.

This should allow us to get rid of the GLU dependency soon.
2015-12-24 16:26:52 -08:00
Armin Burgmeier eab0f2850a Clear Relight markers in C4Landscape::Clear (#1510)
Otherwise, when starting the next scenario, random spots would be initially
re-lighted. That's not necessarily a problem, but unnecessary work, and it
triggered the assertion in C4FowAmbient::UpdateFromLandscape if the relight
was scheduled for a region that's outside of the landscape boundaries of the
second scenario.
2015-12-21 19:35:43 -08:00
Armin Burgmeier a9967e7b16 Avoid built-in GL matrices for sprite rendering
Instead, compute the projection, modelview and normal matrices explictly
and upload them as shader uniforms. This is one step towards using the
OpenGL 3 core profile.
2015-12-19 22:37:36 -08:00
Armin Burgmeier 609840fda0 Fix internalFormat parameter of glTexImage* calls 2015-12-19 17:20:11 -08:00
David Dormagen dcfb986e34 moved sounds into subfolders
This completes http://forum.openclonk.org/topic_show.pl?tid=3215
2015-12-13 22:14:55 +01:00
Sven Eberhardt 3174d0b156 Remove WindLoop sound from engine.
It was almost never appropriate (played underground etc.), could not be turned off and was very repetitive. Mountain scenarios with lots of wind may activate the sound.
2015-12-13 01:22:00 -05:00
David Dormagen fa10a214b5 replaced two missing sounds
..which were easy to find due to the new missing-sound-warning. Hah!
We have cool wind now.
2015-12-10 19:36:54 +01:00
Nicolas Hake 617a0828fb Aul: Throw exceptions by value, not by pointer
Throwing values instead of pointers simplifies memory management at the
catch site.
2015-12-08 13:17:40 +01:00
Sven Eberhardt d48f590dfb Fix conversion buffer access for DrawMaterialQuad with DMQ_Bridge (#1478). 2015-12-05 14:41:56 -05:00
Sven Eberhardt 46a7d653d8 Fix two typos in comments. 2015-12-02 20:27:39 -05:00
Nicolas Hake 871811eac8 Move some private shape calculating functions out of C4Landscape
None of these functions require access to any state of C4Landscape, and
they've only been used from within C4Landscape.cpp, so don't need to be
part of the header.
2015-12-02 01:48:13 +01:00
Nicolas Hake e8a90e7d23 Temporarily remove solid masks before clearing landscape (#1472)
When clearing parts of the landscape, solid masks must be disabled
beforehand because we don't want to remove the actual solid mask itself.
Theoretically we should also temp remove solid masks before DigFree,
ShakeFree, and all of the other landscape modifiers, just in case
someone overrides the Vehicle material with stupid values.
2015-12-02 01:41:47 +01: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
Sven Eberhardt 7f827d4b15 Add optional debug logging for shape texture loading.
Set Config.Developer.DebugShapeTextures to 1 for testing.
2015-11-20 20:35:05 -05: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
Nicolas Hake 8fc57b69c3 Don't ZeroMem non-POD types
Using memset to initialize non-POD types doesn't work. Or rather, it may
work right now, but will fail when somebody adds a member that relies on
its constructor doing something (like for example any STL container).
Either way it's undefined behavior and needs to go. Furthermore, using
it to reinitialize an object also prevents any dtors from doing their
work when needed.

A new helper function InplaceReconstruct will take an object of nothrow-
default-constructible type, and call the dtor to properly clean up
before placement-new reconstructing the object in the same location.
This is still bad design, but unfortunately removing the Default/Clear
functions from every object currently using them is a herculean task.
2015-11-14 16:43:19 +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
Armin Burgmeier 236759b1db Don't update relights array while relighting (#1371)
Removing solidmasks temporarily as part of the relighting procedure caused
a landscape update which modified the list of to-be-relighted regions that
is currently being iterated over. This could cause relighting of a region in
which solidmasks have not been removed, leading to vehicle pixels in the
landscape surface used by the landscape shader, which show up pink on the
screen.

Fixed this by introducing C4Landscape::_SetPix2Tmp, which changes a pixel
without causing relighting (or material count updates), and use that when
temporarily removing or putting solidmasks. This should also avoid unnecessary
computations (relighting, material count updates) when updating the landscape
or moving objects with solidmasks.
2015-11-08 13:48:19 -08:00
Sven Eberhardt 2a54409384 Fix PXS movement on moving SolidMasks (#862). 2015-10-17 22:26:34 -04: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
Sven Eberhardt b060874732 C4MapScriptMatTexMask: Rename fg_mask and bg_mask to sky_mask and tunnel_mask.
This gets closer to what they are representing.

More precise would be fg_mask_if_bg_is_sky and fg_mask_of_bg_is_not_sky. But fg_mask and bg_mask were terribly misleading, because sky background didn't mean the material was "in front".
2015-10-16 00:24:15 -04:00
Sven Eberhardt fe05fb5b1a Fix loading of shape textures from packed groups (#1421). 2015-10-15 20:29:56 -04:00
Sven Eberhardt d136dc22c0 Implement landscape inflammation.
It used to create the non-existent FLAM objects from the engine. Use a script callback to a global function that creates Flame objects instead.
2015-10-09 16:24:16 -04:00
Sven Eberhardt 675db52e38 Texture shape coverage fix and mape build fix. 2015-10-09 14:49:31 -04:00
Sven Eberhardt 47e422f452 Rework and document texture shapes.
* Renamed from material shapes to textures shapes
* No per-texture, so the same material can use different shapes with different textures
* Load a shape image instead of text file with vector components
* Allow texture sizes that are not multiple of the map zoom
* Add minimum overlap parameter to draw shapes only when the given overlap is reached.
2015-10-09 00:16:24 -04: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 df6d564d2d Remove "ColorAnimation"
Not used any more
2015-10-03 15:32:39 +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
Sven Eberhardt 5b47a26d30 Perform DugOut callback also on non-collectibles and on objects not created through Dig2Object mechanism. 2015-10-01 22:43:01 -04:00
Julius Michaelis ee859d85e0 Remove boost any usage of boost libraries 2015-09-30 00:16:12 +02:00
Sven Eberhardt 88167a03a8 Add support for hidden scenarios.
If C4S.Head.Secret is set and mission access to the scenario has not been gained, it is hidden in the scenario selection list.
2015-09-24 23:51:16 -04: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
Sven Eberhardt 3f100cffb0 Fix possible sync loss on seasonal temperature change. 2015-09-19 13:37:51 -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
Sven Eberhardt aac23e6bc7 Fix landscape renderer and ambience level on savegame resume (#1400). 2015-09-16 22:11:39 -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
Sven Eberhardt b683e47499 Add LightOffset property to allow light sources to origin from locations other than the object center. 2015-09-16 21:14:08 -04:00
Sven Eberhardt cc0a139ff9 Fix landscape reinitialization on saved section load (#1379). 2015-09-15 00:13:45 -04:00
Sven Eberhardt 73a42fef92 Suppress warning messages for undefined fields when returning to main section in LoadScenarioSection. 2015-09-14 23:01:09 -04:00
Armin Burgmeier dc38e61139 Fix rendering of colorfade (non-bitmap) sky 2015-09-13 16:46:27 -04:00