Commit graph

314 commits

Author SHA1 Message Date
Christoph Oelckers
bead3e046b - fixed weapon positioning again, after finding out that the first fix just worked around the actual problem: The entire coordinate calculation must be done in floating point with no integer math at all. Due to roundoff errors the stored int values needed for wall and flat placement significantly lack precision and with the high scaling factor that needs to be used for weapon HUD sprites these can easily become several pixels. After fixing this the border around sprite textures could be reverted to one pixel again.
- fixed: The 'may not be expanded' state should be stored in the texture and reused later. This also needs to revalidate the material if it decides that expansion should be disallowed.
2015-04-04 17:50:22 +02:00
Christoph Oelckers
91eafed5d3 - fixed coordinate calculations for trimmed sprites which were quite a bit broken. 2015-04-04 13:37:55 +02:00
Christoph Oelckers
67334bfa2b - calculate weapon positions fully in floating point to avoid roundoff errors.
- In order to get reliable results the empty border around scaled sprites must be the same scale as the sprite (i.e. 2 pixels for 2x scale and 4 pixels for 4x scale.)
2015-04-04 12:35:10 +02:00
Christoph Oelckers
48e21f6759 - consider MBF sky transfers when checking for skybox precaching. 2015-04-01 12:08:42 +02:00
Christoph Oelckers
1e9a6e667e - GL code adjustments for reworked precaching. 2015-04-01 11:59:41 +02:00
Christoph Oelckers
7701d54b1f - fixed: associated dynamic lights took the sprite/frame info from the actor's current state instead of from the actor's current sprite and frame, which may differ in case some placeholder sprite is used in the state. 2015-03-15 12:24:28 +01:00
Christoph Oelckers
fad3a54100 - fixed positioning for sky textures that are less than 128 pixels tall. 2015-03-15 12:10:22 +01:00
Christoph Oelckers
a5a53c51e6 - fixed: The flat drawing code assumed that the first element of the light list originated from the sector itself. This had been true formerly but in some situations it no longer is. 2015-02-10 21:52:19 +01:00
Christoph Oelckers
00639121c0 - added the missed parts of camera roll in gl_scene.cpp. 2015-02-10 20:34:10 +01:00
Christoph Oelckers
8a9692c29f - fixed: The code which decided whether to clamp two sided middle textures used the texture size instead of the render size for the specific linedef, meaning that any per-sidedef scaling was ignored. 2015-02-10 20:16:25 +01:00
Christoph Oelckers
a578ff5d06 - fixed a problem with some older AMD drivers: Normally calling glBindBufferBase should imply a call to glBindBuffer, but on these drivers it was never done, which resulted in the light uniform buffer never being created... 2015-01-24 13:13:54 +01:00
Christoph Oelckers
d4d041d5fc - fixed: FMaterial::ValidateTexture must determine whether to expand sprites before actually constructing the FMaterial object. 2015-01-08 18:44:55 +01:00
Christoph Oelckers
a8398e70b0 - fixed: The brightfog flag in the GL related map settings was never initialized.
- fixed: brightfog should not disable colored lighting for the weapon sprite.
2014-12-31 23:01:06 +01:00
Christoph Oelckers
4f08b20df5 - consider pixel stretching when rendering models. For non-voxels an aspect ratio of 1:1 must always be assumed while voxels need to be stretched so that 1 voxel unit == 1 map unit. 2014-12-31 12:53:29 +01:00
Christoph Oelckers
e6d59ec429 - fixed: with aspect ratio compensation in the view matrix it is necessary to adjust the view pitch for this because the playsim does not know anything about pixel ratio. 2014-12-31 12:04:55 +01:00
Christoph Oelckers
315827015c - made aspect ratio correction factor configurable through MAPINFO. 2014-12-29 23:52:20 +01:00
Christoph Oelckers
45cf65afbd - moved the aspect ratio correction factor from the projection to the view matrix where it should have been from the start.
- removed the mCameraPos variable in FGLRenderer because it was only used in one place where it is just as easy to use the global viewx/y/z variables directly.
2014-12-29 22:42:19 +01:00
Christoph Oelckers
045725de15 - use strncpy instead of sprintf tp init static char array to ensure that all elements get initialized. 2014-12-29 16:35:30 +01:00
Christoph Oelckers
fbfe0f1e7a - fixed: y-clamped textures with negative scale need to shift their texture coordinates into the proper [0..1] range. 2014-12-26 11:53:38 +01:00
Christoph Oelckers
c66a211200 - fixed: The sky renderer must not only alter the light mode but also reset the software light level to a 'disabled' value. 2014-12-25 22:45:40 +01:00
Christoph Oelckers
ffa069205f - fixed: For fullbright sprites, a weapon's extra light must be ignored because it can be negative. 2014-12-25 18:30:34 +01:00
Christoph Oelckers
0bc2c0094a - fixed: For cubemapped skies with one texture for all 4 sides the texture was never set before rendering. 2014-12-19 16:35:34 +01:00
Christoph Oelckers
717c82ee4a - On Intel, we have to disable shader storage buffers because their complier contains a bug disallowing unsized arrays. 2014-12-01 09:58:23 +01:00
Christoph Oelckers
ec627d94dd - fixed: The depth clamp setting needs to be tracked per portal so that it can be properly restored afterward.
Regular skies need it off but SkyViewpoints need it on - and all others need to use the parent's setting.
So without engine side tracking we can end up rendering the sky with this setting off, resulting in omission of the fog layer.
2014-11-27 12:26:52 +01:00
Christoph Oelckers
eb753a0b7c - fixed: We also should use the proper 'copied' info for the non-inverted planes. 2014-11-27 10:49:03 +01:00
Christoph Oelckers
99d81621f9 - fixed: The 'copied' information of a 3D floor plane should only apply to that particular plane, but never the opposite one of the same 3D floor. 2014-11-27 10:46:28 +01:00
alexey.lysiuk
60d78bcdf6 - implemented hqNx image scaling algorithms using MMX and SSE2 intrinsics 2014-11-27 10:58:34 +02:00
Christoph Oelckers
a7f4185981 - now that we don't have to care anymore about SVN-related merging problems, let's save the 3 global variables of the GL renderer unconditionally, even if the software renderer is running. 2014-11-16 09:08:47 +01:00
Christoph Oelckers
b0a6c94fa4 - fixed: the translucency flag for the flags renderer was inconsistent between the light pass and the render pass on GL 3.x hardware, resulting in bad buffer indices being sent to the shader. 2014-11-09 12:10:33 +01:00
Christoph Oelckers
3e50db9bf0 - fixed: When setting the object color for a shaded decal, the alpha channel must be forced to be 255. The decal's AlphaColor contains the palette index in those bits. 2014-10-26 15:11:04 +01:00
Christoph Oelckers
3c7664a460 - we don't really need a bBrightmap in a texture. All it did was duplicate some functionality of bMasked.
- renamed bBrightmapDisablesFullbright flag.
2014-10-26 08:41:52 +01:00
Christoph Oelckers
5a91fd0ad4 - fixed: DMD models didn't load their triangle data.
- fixed: MD2 models didn't handle the triangles' byte order.
2014-10-24 13:03:26 +02:00
Christoph Oelckers
f8016bef86 - fixed: voxels didn't set their index count. 2014-10-24 11:52:45 +02:00
Christoph Oelckers
e5cd90f323 - use separate vertex buffers per model to avoid large memory usage peaks. Also delete the geometry data for the models once it has been copied into the vertex buffer. 2014-10-24 11:43:25 +02:00
Christoph Oelckers
bca47bb9bc - removed debug code.
- fixed: planes that are created by splitting translucent 3D-floors may never be rendered.
2014-10-23 17:35:58 +02:00
Christoph Oelckers
36b35e85f3 - fixed: overflow checks for dynamic light buffer were not correct. 2014-10-23 12:06:00 +02:00
Christoph Oelckers
066e53ae4c - fixed: sprites rendered as 'bright' should not be affected by dynamic lights. 2014-10-23 10:54:26 +02:00
Christoph Oelckers
618c23303f - fixed: The interpolation factor for models was never passed to the shader. 2014-10-23 09:57:27 +02:00
Christoph Oelckers
5302a10a7d - diable software lighting for textured automap.
* since it is designed for software-style light diminishing it doesn't work for 2D.
* additionally it left the lighting state in an unsuitable setting for further 2D rendering.
2014-10-23 09:19:30 +02:00
Christoph Oelckers
89ce0b8cb7 - test if GLSL version 1.4 can handle uniform buffers on old Intel hardware without making problems... 2014-10-22 16:54:26 +02:00
Christoph Oelckers
9f1f17c306 - fixed: The PolyBSPs weren't fully initialized. Some GZDoom-only fields in the segs were skipped. 2014-10-14 08:54:08 +02:00
Christoph Oelckers
5d032f3fcf - fixed: Since the engine can no longer change renderers on the fly, thanks to ZDoom's messed up video startup code, we have to abort with a fatal error if we can't create a GL context. Otherwise the user will never see a meaningful message. 2014-10-06 10:00:02 +02:00
Christoph Oelckers
3e2a17538b - fixed: HUD weapons were affected by dynamic lights even when the CVARs said that they shouldn't. 2014-10-06 09:05:42 +02:00
Christoph Oelckers
ead8a2874d - fixed: The texture mode implied by render style did not work for models. 2014-10-05 12:03:55 +02:00
Christoph Oelckers
fd3128a164 - fixed: When changing enhanced nightvision mode the shaders need to have their fixed colormap state reset to ensure that the new settings get used.
- fixed: The shader code for handling special fixed colormaps did not use the color vertex attribute which was most evident with the 'shadow' render style on the spectre.
2014-10-05 09:40:36 +02:00
Christoph Oelckers
48da2f87bb - fixed: The light buffer index must not be reset between rendering a camera texture and the main scene.
Since rendering is asynchronous, the camera texture scene may not be finished once the main scene's lights get filled in. Unfortunately forcing a synchronization with glFinisg has bad side effects on performance the only remaining option is to use separate parts of the buffer for both scenes, which in extreme cases may increase the light buffer's size - but on modern hardware that shouldn't be a problem.
2014-09-21 21:01:11 +02:00
Christoph Oelckers
b2cf7d6512 - fixed memory leak: The sector links for dynamic lights were never freed. 2014-09-21 12:40:08 +02:00
Christoph Oelckers
7359631a43 - fixed weapon drawing rules to account for the death camera. 2014-09-21 11:08:38 +02:00
Christoph Oelckers
4682736585 - fixed: non-tiled mid textures on a fog boundary require some special clamping to be performed in the shader. 2014-09-21 11:08:17 +02:00
Christoph Oelckers
da87a34a6f - fixed: MODELDEF's FrameIndex command was case sensitive. 2014-09-21 09:40:41 +02:00
Christoph Oelckers
43e2d704a3 - always use glPolygonOffset to render translucent geometry. 2014-09-20 09:04:36 +02:00
Christoph Oelckers
92dcf2e5ef - fixed some of those supremely annoying and supremely pointless GCC/Clang compiler warnings. 2014-09-17 11:03:05 +02:00
Christoph Oelckers
c5e00dbc53 fixed: The sampler object for camera textures was never initialized. 2014-09-17 10:52:34 +02:00
Christoph Oelckers
c773a500f2 - only activate shader storage buffers on modern drivers also supporting GL_ARB_buffer storage. Early adopters of this extension (i.e. older AMD drivers mainly) tend to implement this badly. 2014-09-17 09:01:16 +02:00
Christoph Oelckers
a25ed3c807 - fixed: inverted rendering for fuzzy things with light powerup was switched off due to change of render style. 2014-09-15 12:15:19 +02:00
Christoph Oelckers
8e7e16f73a - fixed: The light uniform buffer may not be mapped with GL_MAP_INVALIDATE_BUFFER_BIT, because it needs to be mapped for each portal in a scene but it must preserve the existing data for the remaining translucent objects. 2014-09-15 10:27:09 +02:00
Christoph Oelckers
32f08adaf3 - moved some code to better places.
- allow GL version 3.0 in Windows, too.
2014-09-14 23:01:57 +02:00
Ralgor
5cc43137a1 Only require OpenGL 3.0 compatibility profile. 2014-09-14 14:43:42 -05:00
Ralgor
cfc8f3dbbf Global GL render context shouldn't be initialized inside of gl_PrintStartupLog, since it's not compiled in non MSC builds. 2014-09-14 14:42:14 -05:00
Ralgor
1a70a6aabc The light buffer should check for shader_storage_buffer_object rather than buffer_storage. 2014-09-14 14:29:13 -05:00
Ralgor
ddf58b43c9 Fix compile errors on linux. 2014-09-14 14:28:05 -05:00
Christoph Oelckers
3c2f1952fd Merge branch 'master' into v2.x 2014-09-12 21:01:55 +02:00
Christoph Oelckers
25951362fc - fixed: When applying Boom's Transfer_Heights effect to a sector, gl_FakeFlat needs to remove all portals from the original sector planes that are being replaced in the sector copy. 2014-09-11 13:02:39 +02:00
Christoph Oelckers
acf6c259d8 - changed the handling of alpha textures. The only special case they need is with palette-less textures and this can be handled far more easily and robustly with a predefined translation instead of passing another parameter through all the layers of the texture management code. This also fixes problems with paletted PNGs that get used as an alpha texture because the old method clobbered the image's palette. 2014-09-09 13:21:36 +02:00
Christoph Oelckers
4bb320a27c - route texture binding through the renderstate class for better control. Currently it's just a direct passthrough but this will change. 2014-09-09 12:00:42 +02:00
Christoph Oelckers
d5633701b4 - swapped order of textures in burn shader to avoid some problems with the texture samplers.
- fixed: texture sampler state for the burn texture was never set.
2014-09-09 10:17:44 +02:00
Christoph Oelckers
c6f4c0b6f0 - fixed: FMaterial's tex pointer could be accessed before it was set.
- allow more than two texture units in shaders.
2014-09-09 10:03:34 +02:00
Christoph Oelckers
62880f113b - fix a render glitch with Back to Saturn X MAP06: Do not flood missing upper and lower textures with the backsector's flat if that backsector is malformed (i.e. has no area.) 2014-09-09 08:47:39 +02:00
Christoph Oelckers
9b8869e78d Merge branch 'master' into v2.x
Conflicts:
	src/gl/textures/gl_material.cpp
2014-09-09 01:30:11 +02:00
Christoph Oelckers
86d9c7ec8e - add some compatibility settings to fix rendering glitches in BTSX_E1 MAP12. 2014-09-09 01:27:41 +02:00
alexey.lysiuk
e29fce6951 Fixed missing transparency on upscaled textures
Textures with diagonal patterns were treated as opaque after resizing
Images upscaled by hqNx were affected mostly by this issue

http://forum.drdteam.org/viewtopic.php?f=24&t=5370
http://zandronum.com/tracker/view.php?id=269
http://zandronum.com/tracker/view.php?id=315
2014-09-07 11:52:51 +03:00
Christoph Oelckers
b96dd6c421 - fixed: The missing fourth component of the texture coordinate must be filled with 1.0, not 0.0 before applying the texture matrix. Not doing so will cancel out the translation part of the matrix. 2014-09-02 10:31:48 +02:00
Christoph Oelckers
fa3a62e954 - fix a render glitch with Back to Saturn X MAP06: Do not flood missing upper and lower textures with the backsector's flat if that backsector is malformed (i.e. has no area.) 2014-08-31 23:01:53 +02:00
Christoph Oelckers
a280c20b4e - fixed: If we want to cache texture binding state we have to reset it in all places where a texture becomes unbound. 2014-08-31 19:00:17 +02:00
Christoph Oelckers
12160bd29c - remove some obsolete code from decal rendering.
- avoid rebinding the same texture multiple times, as there's considerable overhead in the texture manager.
- check gl_sort_textures only once per scene, not per draw list.
2014-08-30 15:34:14 +02:00
Christoph Oelckers
6a3cd6378a - found out that reading the CPU's real time clock costs a not insignificant amount of time so this is now only done when either the benchmark command is running or the rendertimes are shown. 2014-08-30 14:33:06 +02:00
Christoph Oelckers
49ec7beb8f - separate draw lists for walls and flats. This makes the sorting much more efficient because draw types no longer need to be checked in the compare function. This is a lot more important than having perfect texture order. 2014-08-30 13:04:41 +02:00
Christoph Oelckers
a903cbe12e - sorting draw items by light level no longer makes sense so remove all corresponding code from dicmp. 2014-08-24 13:10:45 +02:00
Christoph Oelckers
bf03d02228 - print OpenGL profile type in startup log. 2014-08-24 01:09:44 +02:00
Christoph Oelckers
904cc2e158 - some code cleanup. 2014-08-23 18:54:24 +02:00
Christoph Oelckers
bf6079af46 - fixed incorrect check for overrideshader. 2014-08-23 00:47:05 +02:00
Christoph Oelckers
1050013017 major cleanup of the texture manager:
- use sampler objects to avoid creating up to 4 different system textures for one game texture just because of different clamping settings.
- avoids flushing all textures for change of texture filter mode.
- separate sprite and regular dimensions on the material level to have better control over which one gets used. It's now an explicit parameter of ValidateTexture. The main reason for this change is better handling of wall sprites which may not be subjected to such handling.
- create mipmaps based on use case, not texture type.
- allows removal of FCloneTexture hack for proper sharing of the same sprite for decals and other purposes.
- better precaching of skyboxes.
2014-08-22 23:50:38 +02:00
Christoph Oelckers
274a4216ea - disabling inlining in the GL loader produces an executable that's 8kb smaller. 2014-08-21 11:47:53 +02:00
Christoph Oelckers
e132fc5eed - replaced GLEW with GLLoadGen for GL access. This allows to have a header that only contains what's actually required, namely OpenGL 3.3 plus glBegin and glEnd which are the only compatibility functions needed for the fallback render path.
GLEW has two major problems:

- it always includes everything, there is no way to restrict the header to a specific GL version
- it is mostly broken with a core profile and only works if all sanity checks get switched off.
2014-08-21 11:02:46 +02:00
Christoph Oelckers
6f65bccf1c - reinstated the far superior assembly HQnX version for Visual C++. 2014-08-20 12:45:33 +02:00
Christoph Oelckers
86d37e06f9 - lowered requirements of GL 2.x to OpenGL 3.3.
There was one issue preventing the previous 2.0 betas from running under GL 3.x: The lack of persistently mapped buffers.
For the dynamic light buffer today's changes take care of that problem.
For the vertex buffer there is no good workaround but we can use immediate mode render calls instead which have been reinstated.

To handle the current setup, the engine first tries to get a core profile context and checks for presence of GL 4.4 or the GL_ARB_buffer_storage extension.
If this fails the context is deleted again and a compatibility context retrieved which is then used for 'old style' rendering which does work on older GL versions.

This new version does not support GL 3.2 or lower, meaning that Intel GMA 3000 or lower is not supported. The reason for this is that the engine uses a few GL 3.3 features which are not present in the latest Intel driver.
In general the Intel GMA 3000 is far too weak, though, to run the demanding shader of GZDoom 2.x, so this is no real loss. Performance would be far from satisfying.

A command line option '-gl3' exists to force the fallback render path. On my Geforce 550Ti there's approx. 10% performance loss on this path.
2014-08-19 15:56:33 +02:00
Christoph Oelckers
a2dc4afe3f - screwed by the editor's autocompletion... (wrong GL flag was used...) 2014-08-19 14:25:47 +02:00
Christoph Oelckers
00d7707aef - allow reallocation of light buffer if more lights are needed.
- added a light preprocessing pass to the renderer so that a non-persistent buffer can be used with minimal mapping/unmapping. This only gets used if necessary because it adds some overhead to the renderer.
2014-08-19 14:18:21 +02:00
Christoph Oelckers
38796e7714 - removed some obsolete and useless GL calls. 2014-08-17 11:41:03 +02:00
Christoph Oelckers
b9ffb51d0c - small but important optimization: Two-sided lines with both sides in the same sector don't really require vertex splitting for precise rendering. 2014-08-04 23:00:40 +02:00
Christoph Oelckers
09a68e8c93 - fixed incorrect function call in shader compiler. 2014-08-03 18:14:19 +02:00
Christoph Oelckers
19cfffebb3 - fixed: the WallTypes enum contained a value that no longer was valid. This was fixed orignally last week but it seems to have gotten lost. 2014-08-03 12:21:05 +02:00
Christoph Oelckers
c98e3ca99d Merge branch 'master' into v2.x 2014-08-03 10:58:41 +02:00
Christoph Oelckers
b3e0d93385 - implemented rendering of wall sprites. 2014-08-03 10:57:58 +02:00
Christoph Oelckers
398d902e7e - split off sprite clipping adjustment code into its own function. 2014-08-03 10:22:12 +02:00
Christoph Oelckers
a63871d170 - at least for Intel GMA we need shaders without 'discard' to render non-transparent stuff. The performance penalty is rather hefty here. 2014-08-02 21:06:34 +02:00
Christoph Oelckers
a97b58fa27 - added check for light uniform buffer overflows, because uniform buffers on Intel are rather small. 2014-08-02 20:41:13 +02:00
Christoph Oelckers
e35fefdc06 - better rebind the active shader after updating the matrices. 2014-08-02 11:59:04 +02:00
Christoph Oelckers
b2860a1d63 - it looks like glProgramUniform is not working correctly with Intel drivers, so better forget about it for setting the view and projection matrices. Even on NVidia the time difference can only be measured in microseconds per frame so it's not a big loss. 2014-08-02 11:57:42 +02:00
Christoph Oelckers
a8e9c1832f - decided to restrict the 2.0 beta to OpenGL 4.x with GL_ARB_buffer_storage extension and removed all code for supporting older versions.
Sadly, anything else makes no sense.
All the recently made changes live or die, depending on this extension's presence.
Without it, there are major performance issues with the buffer uploads. All of the traditional buffer upload methods are without exception horrendously slow, especially in the context of a Doom engine where frequent small updates are required.
It could be solved with a complete restructuring of the engine, of course, but that's hardly worth the effort, considering it's only for legacy hardware whose market share will inevitably shrink considerably over the next years.
And even then, under the best circumstances I'd still get the same performance as the old immediate mode renderer in GZDoom 1.x and still couldn't implement the additions I'd like to make.

So, since I need to keep GZDoom 1.x around anyway for older GL 2.x hardware, it may as well serve for 3.x hardware, too. It's certainly less work than constantly trying to find workarounds for the older hardware's limitations that cost more time than working on future-proofing the engine.

This new, trimmed down 4.x renderer runs on a core profile configuration and uses persistently mapped buffers for nearly everything that is getting transferred to the GPU. (The global uniforms are still being used as such but they'll be phased out after the first beta release.
2014-08-01 22:42:39 +02:00