Commit Graph

19 Commits (652c7e43e23652fb8bf05b4b57e6db36b0eb765c)

Author SHA1 Message Date
Nicolas Hake 652c7e43e2 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.

Cherry-picked.
Author:    Nicolas Hake <isilkor@openclonk.org>
Date:      Wed Jun 17 21:30:56 2015 +0200
Conflicts:
	src/lib/StdMesh.h
2015-09-23 21:12:56 +02: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
Nicolas Hake e2a8f6d303 Reorder some declarations and initializations to avoid order mismatch
While none of the mismatches were having a side-effect, this silences a
number of -Wreorder warnings which were drowning out potentially
important diagnostics.
2015-02-04 22:12:42 +01:00
Sven Eberhardt 7b8ffd79a4 Make Lava/DuroLava emit ambient light as a material property. (#1205) 2015-01-28 22:35:14 +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 dffed48b3d Fix crash on ambient map update outside landscape bounds (#1216) 2015-01-06 11:47:25 +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 ab4de05b4f Fix light/ambient drawing offset when upperboard is active 2014-12-07 21:54:12 -05:00
Armin Burgmeier a7f9ba1e91 Compute ambient texture coordinate based on fragment coordinate
This will allow to use the same shader slice also for the sprite and mesh
shaders.
2014-11-24 14:51:08 -05:00
Armin Burgmeier db6df15377 Add SetAmbientBrightness and GetAmbientBrightness script functions 2014-11-20 17:07:31 -05:00
Armin Burgmeier 643ca7fd0a Add functionality to update the ambient map at runtime 2014-11-18 15:42:39 -05:00
Armin Burgmeier 72255a7e04 Optimize generation of the ambient map
The new algorithm is ~25% faster
2014-11-18 11:06:26 -05:00
Armin Burgmeier 0520c5fcdf Use a named enum for the internalformat parameter of glTexImage2D 2014-11-17 17:53:06 -05:00
Armin Burgmeier 34e100aeb6 ambient: fix some debug code 2014-11-17 17:53:06 -05:00
Armin Burgmeier 5ae426e7bf Fix too large radius when converting radius from landscape to ambient coords
This is basically a leftover to do rounding when the radius was an integer
and not a floating point number.
2014-11-17 17:53:06 -05:00
Armin Burgmeier fc67eca754 ambient: Clamp sample values outside the landscape to the landscape border
GetPix() already has some handling for outside values, however that does not
always give the desired result.
2014-11-17 17:53:06 -05: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