Commit Graph

32 Commits (92ed1537a0e79facded3c81f50f7767962d70d6f)

Author SHA1 Message Date
Nicolas Hake 92ed1537a0 Fix off-by-one error in FoW renderer (#1678)
The FoW renderer would try drawing to texture coordinates one pixel
too high (i.e. if the texture was 256 pixels high, it would draw to
pixels with 1 <= y <= 256 instead of 0..255).
2016-02-15 13:52:03 +01:00
Sven Eberhardt 4eddeba9aa Fix crash when drawing zero-sized viewports (may happen during editor viewport initialization) 2016-01-15 08:53:00 -05:00
Sven Eberhardt cd63c06aaf Fix crash when starting tabbed out. 2016-01-14 22:25:45 -05:00
Armin Burgmeier 5ecb393c71 Fix FoW flicker when resizing the FoW texture
We do this by copying the contents of the old texture when resizing it.
2016-01-05 20:23:15 -08:00
Armin Burgmeier d72b8cc385 Use generic vertex attributes for FoW rendering 2016-01-02 19:11:41 -08:00
Armin Burgmeier ecdcf5ac92 fow: Use a VBO to blit the framebuffer 2016-01-01 22:28:22 -08:00
Armin Burgmeier c043795552 Fix memory leak in FoW surfaces
Surfaces are initially created in locked state, and only when unlocked the
memory buffer with the surface data is uploaded to the GPU. The FoW code
however never unlocks the surface but instead operates on the OpenGL texture
directly. To fix this, introduce a new flag for C4Surface to create it in an
unlocked state.

This is not a memory leak in the traditional sense as a pointer to the buffer
is still available and is being freed when the surface is being destructed
at the end of the game. However, during the game there might be several
megabytes allocated that are never used.

I'm not really sold by this Lock/Unlock mechanism. Instead, there should
simply be a function to obtain the current texture data, and a function to
upload new texture data. That's for another time though...
2015-12-31 18:40:38 -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
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
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
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 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 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
Peter Wortmann 6a016f807d Alternate light drawing, v2
This is now a "mix" between the original and the alternate drawing
strategy, hopefully combining its strength. In detail:

1. Intensity of light sources aren't added together anymore. Instead,
   the brightest light source decides end brightness pre-smoothing.

2. For smoothing, we update normals more quickly than brightness. This is
   the main change relative to the first "alternate" version. Actually
   quite embarassing that I didn't think of this solution before %)

This is still a tad busier than what we have currently, simply due to
normals changing around more quickly. On the plus side, Clonk faces
shouldn't go dark anymore while walking, so that's something.
2015-08-31 17:35:08 +01:00
Mark d45cc7c95b Colored lights improvements
Color value is now uint32_t, removed superfluous conversion to unsigned value, simplification in the shader.

Open: C4DP_Last and number of drawing passes
2015-07-11 17:46:00 +02:00
Mark 02fd798631 Colored lights
The color of object lights can now be changed. This includes the following changes:
- added light test scenario, based on DarkCastle, with some lights,
- new functions SetLightColor() and GetLightColor() with C4Script documentation,
- third drawing pass for rendering the light color, the drawing passes are now referenced by enum,
- the blending of light from multiple colored light sources works correctly with alpha blending,
- light color value affects the intensity of the light,
- alpha blending of the light depends on color value and lightness. This means that brighter (= more value) and lighter (= more whiteish) light will be preferred in blending over other lights,
- the object light color is rendered to the lower half of the fow light texture now,
- the shader accesses the brightness/direction information and color information correctly,

The patch was created from the following commits:
dab898a SetLightColor()
f57286e Color texture experiment
d0702f5 Dynamic color
fa14cdf Light test scenario
f99203d Alternate lights
474bade Bugfixes
3113698 Brightness handled better
516fb21 GetLightColor
1d91ec9 Improvements
3cfbf6c Documentation
95ec185 Improvements: Light Shader
a63bffc Scope of alpha
20c7ca0 Improvement: C4FoWLight
17d9123 Undo code style
d79411b Cleaner code

(cherry picked from commit 36dec610e36860b88417e91ce727250673bc2ec2)

Conflicts:
	src/landscape/fow/C4FoWRegion.cpp, merged
2015-06-28 21:28:40 +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
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 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
Armin Burgmeier 31c8c14e73 Fix viewport window size in light coordinate calculations (#1211)
The light rect is made larger than the viewport is by one pixel in
C4Viewport::Draw(), so correct for this.
2015-01-07 14:10:26 +01:00
Armin Burgmeier 434eb1c77b Fix Y offset when transforming fragment to light texture coordinates (#1211) 2015-01-07 12:28:10 +01:00
Sven Eberhardt f25edc64df Do not render lights of hostile objects on player-owned viewports. 2015-01-02 01:42:24 +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 8686441d45 Make mesh shaders use the C4Shader slice machinery 2014-12-22 22:56:30 +01:00
Peter Wortmann 9672ae8947 Framebuffer update improvements
Now we use the shader to do a proper blend - this avoids some artefacts
that were visible before. Also after some hair-pulling the coordinate
transformation now seems to be more correct than before. Maybe even
with zoom. We'll see.
2014-11-20 21:48:46 +01:00
Tobias Zwick 3fd426dc04 revert my fix from yesterday 2014-10-12 13:00:52 +02:00
Tobias Zwick 4257f871c6 fix the brightness of "explored" areas does not reset to 0 2014-10-12 01:36:23 +02:00
Tobias Zwick 21e532da23 split up C4FoW header and source file into one file for each class
* added some class and method documentation, removed some superfluous comments like

	void C4FoW::Update(C4Rect r)
	{
		// Update all lights
		...

* added ASK comments that need clarification before proper documentation
2014-10-11 23:13:10 +02:00