Commit Graph

29 Commits (96013162fa53bd13ae9aea9f924f9dc0e52d12db)

Author SHA1 Message Date
Armin Burgmeier 96013162fa Instantiate C4ShaderCall within C4FoWDrawStrategy
This will allow us to use different shaders for different passes of the draw.
2016-11-27 22:11:14 -08:00
Sven Eberhardt ebda8193ef Replace NULL by nullptr in C++ sources
We don't support pre-C++0x any more, so nullptr should be fine everywhere (except in the plain C source files)
2016-11-02 19:58:02 -04:00
Julius Michaelis 376ca5a9df Prevent using USE_CONSOLE in lib{misc,c4script} 2016-10-22 17:42:23 +02:00
Sven Eberhardt a882a6e64b Fix black editor screen due to GL object creation and removal in wrong context 2016-09-06 02:45:17 -04: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
Armin Burgmeier eb1750a7d3 Fix drawing of the FoW debug mode (#1659) 2016-01-30 11:49:20 -08:00
Sven Eberhardt 451ea87ab9 Fix another FoW crash 2016-01-24 17:23:20 -05:00
Sven Eberhardt 42d8885877 Fix crash in FoW rendering #1643 2016-01-24 14:44:00 -05:00
Armin Burgmeier 686a32764c Use an IBO to render the FoW 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 d72b8cc385 Use generic vertex attributes for FoW rendering 2016-01-02 19:11:41 -08:00
David Dormagen a0dddce691 C4FoWDrawLightTextureStrategy: do not crash when nothing to draw
This would crash for me when starting a game in developer's mode. Not sure if this is the best place for the fix. Maybe there is some other underlying issue. ck?
2016-01-02 13:03:44 +01:00
Armin Burgmeier b80a7ebb01 Use VBOs to render the FoW texture
In doing so, refactor the way C4FoWDrawStrategy works slightly. Get rid of
immediate mode OpenGL, and instead populate a vertex array and an index array
as vertices are added to the draw strategy. Then render everything as
triangles.

The actual rendering is then performed in C4DrawStrategy::End(). It passes
the accumulated vertices to the GL. Also get rid of the notion of multiple
passes in C4DrawStrategy. Instead, C4DrawStrategy::End() can simply just draw
the bunch of vertices multiple times. This allows us to do the vertex
generation and GPU upload only once, instead of repeating it for every pass.
2016-01-01 22:28:22 -08:00
Armin Burgmeier f582ea9f24 fow: persist draw strategies between light renderings
This allows the strategy to keep some state between invocations. I want to
use this in order to store a VBO in the draw strategy, and to avoid having
to re-create the VBO for every rendering.
2016-01-01 22:28:22 -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 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 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 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
Peter Wortmann 1aa8585fa1 Cosmetic light improvements
- Increase light fade-in/fade-out quite a bit (4 times stronger)
- Fixed normal jump when multiple lights intersect (will make things a
  little less nice with only one light, but this takes priority)
- Don't draw objects without light in light-debug mode
2015-01-15 12:30:50 +01:00
Armin Burgmeier a508fb38e7 Remove GL shade model changes
This gets rid of GL state changes for questionable gain. It also fixes drawing
of fade sky backgrounds in global viewports (where, for some reason, the shade
model was set to GL_FLAT instead of GL_SMOOTH).
2014-12-29 22:27:49 +01:00
Peter Wortmann 7dd4d1900b Split fan where the normal maxes out
This gives a more consistent normal distribution across directions.
I actually had to make the "normal region" of the light bigger, because
now the Clonk's face would be all dark otherwise. In the end,
everything looks smoother and less flashy now, which is probably as
it should be.

Also slight refactoring.
2014-11-21 15:32:33 +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 fd0163ebc6 refactor and document: C4FoWLightSection only calculates the triangles now, C4FoWLight stitches everything together and renders
* intermediate fade triangles are now calculated in C4FoWLight
* rendering takes also place in C4FoWLight, using different C4FoWDrawStrategies
* solved an old TODO from Peter (int -> int32_t)
* refactor and simplify portions of the light vertex calculation code
2014-11-16 18:57:42 +01:00