Commit Graph

27 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
Julius Michaelis 34a9a1de8d Twiddle with header organization: lib{misc,c4script} do no longer include GL/glew.h
(Yes, it is just that complicated.)
2016-10-20 18:46:32 +02:00
Lukas Werling 3d5f2f012a Fix openclonk-server build 2016-09-06 22:12:06 +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
Sven Eberhardt df6d349166 Add safety to light object creation. 2016-01-23 21:09:12 -05:00
Armin Burgmeier aef7538aa1 Switch shader code to OpenGL 3 style 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
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 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
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 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
Nicolas Hake 4db690b0c6 Add copyright header to files that were missing it 2015-02-16 18:40:52 +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
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
Armin Burgmeier 2ebb15c5db Fix crash on player elimination (#1191) 2014-12-28 12:28:25 +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
Armin Burgmeier 88f8f75441 Add ambient lighting
This introduces a new texture, an ambient light map, that is generated
automatically at the beginning of the round by the sky portion of the
landscape. This basically makes everything that is close to sky visible
by default.

The shaders have been adapted so that they deploy direction-independent
lighting for the ambient component, and the current (diffuse) behaviour
for the diffuse component. This makes the shaders use an additional
texture unit that represents the ambient light. We can think about merging
this information into the light texture, but the coordinate systems are
different at the moment, so this could be performed at the stage of light
texture generation.

For meshes, the ambient material is not actually used, but instead a
diffuse light from the front is used. This makes many meshes look more
interesting, maybe also because the ambient material setting of most
meshes are not set correctly at the moment.
2014-11-17 09:35:50 -05: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 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