Commit Graph

6279 Commits (d60c74c6b6805b8380d9f967298b516a3f886fe1)
 

Author SHA1 Message Date
Armin Burgmeier d60c74c6b6 Fix viewport offset for lightmap lookup 2014-11-20 16:45:34 -05: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
Peter Wortmann 7fea618221 Collected trivial bug-fixes
Turns out we actually can't optimise out the second texture normal
lookup - it makes a noticeable difference in-game. Also there was
possible slice collision, it might be worth warning about this kind
of stuff.

Also removed unused variable, and made error messages more consistent
in terms of whitespace.
2014-11-20 21:44:11 +01:00
Peter Wortmann 72289713f9 Modular shader system
The idea here is that we compose shaders out of "slices", which can
come from the engine ("built-in"), from files or possibly even from
models. This should allow us to more easily share the code between
different rendering shaders (e.g. for lights / normals).

TODO: Workarounds not yet implemented, so this might degrade less
gracefully.
2014-11-20 11:52:14 +01:00
Armin Burgmeier b43e1a9369 Fix ambient texture coords when viewport is smaller than full render target 2014-11-18 16:44:06 -05:00
Armin Burgmeier 48456f5f99 Fix transparency in regions with no ambient and low dynamic light 2014-11-18 16:33:27 -05:00
Armin Burgmeier 2df2ee22d6 Update ambient map on landscape changes 2014-11-18 15:42:53 -05:00
Armin Burgmeier 643ca7fd0a Add functionality to update the ambient map at runtime 2014-11-18 15:42:39 -05:00
Armin Burgmeier 39f5b6f15a Apply landscape re-lighting again in every frame
This was accidentally removed in commit
56bdeec585. It fixes the landscape being
only updated once every second when digging.
2014-11-18 15:42:22 -05:00
Armin Burgmeier ac75c7041b Remove two unused declarations in C4Landscape
There are no implementations anymore for these.
2014-11-18 15:42:22 -05:00
Armin Burgmeier 5ac6ea6a3c Fix FoW deinitialization in C4Landscape 2014-11-18 15:42:22 -05:00
Armin Burgmeier c8ea5d1f85 Explain the one-second relights in a comment
Should make it a bit quicker for the next person to figure out what is
going on there...
2014-11-18 15:42:22 -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 ee33c58cfe Don't apply the dot product to transparency in lighting calculation
This fixes the transparency issue with the coconut tree.
2014-11-17 20:51:18 -05: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
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
Tobias Zwick 239cd222e5 implement/fix clipping during rendering of light 2014-11-17 23:02:00 +01:00
Tobias Zwick 96729ef57c refactor C4FoWLightSection::CalculateTriangles to also use the C4FoWBeamTriangle data structure; refactor the variable names 2014-11-17 23:01:59 +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
Armin Burgmeier e64875d1c7 C4Landscape: Make GetPix and _GetPix const 2014-11-17 09:13:01 -05:00
Tobias Zwick 7f1ca342c2 another build fix 2014-11-16 20:36:12 +01:00
Tobias Zwick eb6bba9c4e fix linker error for G++ and clang 2014-11-16 20:18:09 +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
Armin Burgmeier 00447dd524 Merge branch 'master' into lights 2014-11-12 08:47:43 -05:00
Armin Burgmeier fb5365c2b1 Fix possible crash when drawing empty pix or line PXS 2014-11-12 08:46:53 -05:00
Maikel de Vries fb707a8634 fixed tutorial 3 flint drop (#1171) 2014-11-09 14:38:30 +01:00
Armin Burgmeier a1d653415d Fix typo in elevator description (github #3) 2014-11-07 20:25:16 -05:00
Armin Burgmeier c3bcedfbf9 Don't attempt mouse hover callbacks when mouse control is passive (github #5) 2014-11-07 20:16:30 -05:00
Armin Burgmeier ebeeb534ce CreateParticleAtBone: Take object rotation into account (#1173) 2014-11-07 19:57:04 -05:00
Armin Burgmeier 53f4185958 Add auto-generated normal maps for the firestone graphics 2014-11-07 15:29:32 -05:00
Armin Burgmeier 137abb89df Implement normal maps for sprite graphics 2014-11-07 15:29:09 -05:00
Armin Burgmeier 672e343b84 Remove C4DefGraphics::CopyGraphicsFrom()
It is not used.
2014-11-07 15:28:13 -05:00
Armin Burgmeier 5b54a3d6ea Remove fixed-function lighting for meshes
The light direction is now taken from the light texture, so the only thing that is
still needed is the material definitions.
2014-11-07 12:08:06 -05:00
Armin Burgmeier aed907e30d Remove old fog of war 2014-11-07 11:53:10 -05:00
Armin Burgmeier 219fa8597c Implement light calculations for meshes 2014-11-06 15:56:19 -05:00
Armin Burgmeier 0795715465 Apply lighting on sprites 2014-11-06 15:56:19 -05:00
Armin Burgmeier a6d949d313 Merge branch 'master' into lights 2014-11-04 11:26:45 -05:00
Armin Burgmeier 73e4f5a89c Remove some unused code in C4Draw 2014-11-04 11:24:55 -05:00
Armin Burgmeier a1bafb937f Implement DrawQuadDw with PerformMultiTris
This simplifies the code further.
2014-11-04 11:02:40 -05:00
Armin Burgmeier 9e9f0cee9d Avoid setting oc_ClrModMap shader parameter when clrmodmap is not used
Otherwise, ResolveAutoParameter() does not set the correct parameter type, and
the code would try to set a sampler2D parameter as a float4. It does not matter
in principle since the shader would not use the texture anyway, but it
generates a GL error that is avoid this way.
2014-11-03 14:39:17 -05:00
Armin Burgmeier e9b4ddc426 Fix texture name in normal map shader 2014-11-03 14:38:17 -05:00
Armin Burgmeier f89058f094 Remove config entries that are no longer used 2014-11-02 16:57:50 -05:00
Armin Burgmeier fe7897539a Remove unused code 2014-11-02 16:57:28 -05:00
Armin Burgmeier 233e5e7c13 Remove CStdGL::BlitLandscape
This code is only used for the low-resolution landscape that is hardly in use
anymore. The code was mostly a duplicate of the standard C4Surface blit
function, CStdGL::PerformBlt, with some added code for blitting material
textures with higher resolution. However, that code was not enabled anymore
by the classic landscape renderer either, so it seems safe to remove it.

The landscape is now simply drawn by C4Draw::Blit.
2014-11-02 11:15:06 -05:00
Armin Burgmeier 50769171f1 Remove manual clipping in C4Draw::BlitUnscaled
This was not working anymore correctly, since it now operated on unzoomed
coordinates. This could have been worked around by only applying it in the
unzoomed case, however I don't think the code is actually used much anymore.
In other cases of the rendering code, such as the mesh rendering, manual
clipping was never implemented and this did not seem to cause any problems.

Therefore, it can probably be removed safely.
2014-11-01 23:11:35 -04:00
Armin Burgmeier 373b992f45 Tweak the shader a bit 2014-11-01 22:45:14 -04:00