Commit Graph

38 Commits (cd2b5a0e3995652ce95d2ffb852876b9eeb6396f)

Author SHA1 Message Date
Armin Burgmeier cd2b5a0e39 Add a directional shader for light rendering
This allows to render light as a cone in a certain direction with an inner
circle that is illuminating all directions. It is basically implemented as a
mask when rendering into the light texture. A separate fragment shader for the
first of the three render passes is used to set the light intensity based on
where the fragment is relative to the light source.
2016-11-27 22:11:14 -08:00
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
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 4fdafbc78a Move StdColors.h ref from C4Surface.h to files that actually need it
C4Surface.h doesn't require anything from StdColors.h, so there's no
reason to reference the latter there.
2016-02-08 02:13:18 +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 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
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
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 e8bf04840f Fix some refactoring bugs (#1227)
The "b" value returned by the new find_cross function had basically
nothing to do with what the old version did (it was for the other
pair of coordinates *and* sign-switched). This is not cosmetical - the
algorithm depends quite a bit on this being consistent.

Additionally, most of the list modifications in CalculateTriangles were
wrong (didn't reprocess last triangle for ascend shadowing, and the descend
case was removing the wrong triangle). I admit the old code was probably a
bit too tricky with how it handled "i", so I attempted to refactor it to
make it less easy to screw up in future.
2015-01-14 14:23:26 +01:00
Sven Eberhardt f25edc64df Do not render lights of hostile objects on player-owned viewports. 2015-01-02 01:42:24 +01:00
Tobias Zwick f5ecd4776d new function SetLightRange (replaces SetPlrViewRange) 2015-01-02 01:06:00 +01:00
Tobias Zwick 1ad16efe23 fix intermediate fade point sometimes end up overlapping the fan 2014-12-06 01:44:18 +01:00
Tobias Zwick 43d7bbfa73 make Peter's change conform to the naming scheme 2014-11-23 18:39:24 +01:00
Tobias Zwick 256c86fccd Merge remote-tracking branch '_origin/lights' into lights
Conflicts:
	src/landscape/fow/C4FoWLight.cpp
	src/landscape/fow/C4FoWLight.h
2014-11-23 18:06:10 +01:00
Tobias Zwick 3a8fb34bea shorten and make intermediate fade triangle render code more performant 2014-11-23 17:50:21 +01:00
Tobias Zwick a1794359cc squash and simplify function to find cross-intersection again 2014-11-23 17:49:29 +01:00
Tobias Zwick e33ef90bba fix a bug in the intermediate fade triangle render code 2014-11-23 17:46:59 +01:00
Tobias Zwick 8850d2e755 replace algorithm to calculate the intermediate fade point with a more failsafe version 2014-11-23 17:45:53 +01:00
Tobias Zwick 800885a21b add const keyword to some methods 2014-11-23 17:40:24 +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
Tobias Zwick 6bd5beafde make certain fades a bit smoother by reimplementing PeterW's NEWER_INTERFADE_CODE. This is only a very slight effect, but visible 2014-11-20 23:43:14 +01:00
Tobias Zwick 1b96eaabf2 move find_cross function to a different class, reimplement 2014-11-20 23:43:13 +01:00
Tobias Zwick 815a61c540 fix a bug in intermediate fade generation 2014-11-20 23:43:12 +01:00
Armin Burgmeier 86d2ba7d68 Fix the build 2014-11-17 20:30:41 -05:00
Tobias Zwick e7c9c176b1 fix clipping 2014-11-18 00:30:27 +01:00
Tobias Zwick 239cd222e5 implement/fix clipping during rendering of light 2014-11-17 23:02:00 +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
Tobias Zwick 7963065eb8 rename C4FoWRay to C4FoWBeam, add some documentation 2014-10-12 12:59:25 +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