Remove unneeded #includes in some headers. Make some headers standalone. git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12981 d7cf8633-e32d-0410-b094-e92efae38249
Rename qboolean to qbool git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12920 d7cf8633-e32d-0410-b094-e92efae38249
Split out TaskQueue into its own taskqueue.[ch] module, it doesn't depend on SDL2 itself. git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12495 d7cf8633-e32d-0410-b094-e92efae38249
Overhauled r_shadow_bouncegrid, it performs much faster, makes use of as many threads as you wish, and has a nicer calculation for light path accumulation. r_shadow_bouncegrid now does refractive index calculations on water surfaces, it's not very obvious yet because the traceline doesn't return texture information (if it did, there would be cool caustics effects in dynamic mode). Implemented TaskQueue system for simple threaded tasks (fibers but less featureful), this is used by r_shadow_bouncegrid but will be used by other parts of the engine in future, also added Thread_Atomic* functions. git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12493 d7cf8633-e32d-0410-b094-e92efae38249
Removed r_shadow_bouncegrid_bounceanglediffuse functionality, this was annoying to support and did not actually look good. git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12492 d7cf8633-e32d-0410-b094-e92efae38249
Overhauled bouncegrid light splatting for performance reasons - instead of a series of radial dots being accumulated in the texture, it is spherical distance from line segment calculations performed at each pixel, optimized to process pixels in order (filtering down the list of splat paths in each loop). This is a big framerate increase (as raytracing was not the bottleneck at all), and could be threaded in theory. This required rebalancing the way that spacing interacts with quality, and the conespread parameter has been eliminated (as measuring distance to a non-uniform capsule seems especially challenging, but maybe that could be added back someday), so all parameters have changed a bit. git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12491 d7cf8633-e32d-0410-b094-e92efae38249
Remove unused light attention textures (2D and 3D) since the GL1 path was removed. git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12427 d7cf8633-e32d-0410-b094-e92efae38249
Remove shadowvolume rendering entirely, now shadowmaps are the only kind of shadow. Also remove R_SetStencilSeparate and corresponding gl bindings since it isn't needed (R_SetStencil could also be removed but it might have uses). git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12414 d7cf8633-e32d-0410-b094-e92efae38249
Fix some viewport issues with r_viewfbo and r_bloom by passing view size information when calling the various rendering subsystems - there are still a bunch of bugs but this is a temporary measure before rendertargets are put in. git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12389 d7cf8633-e32d-0410-b094-e92efae38249
Refactored R_UpdateEntityLighting to CL_UpdateEntityShading, which sets fields like ent->render_modellight_ambient. Added texture->render_modellight_ambient and similar fields which concretely define how the material is to be rendered, so all of the various tweaks and modifiers are no longer buried in R_SetupShader_Surface which has now been refactored heavily. Removed R_LightPoint as it's really not necessary - this change will make lit particles a little bit slower as R_CompleteLightPoint is a slightly more expensive function. Refactored R_CompleteLightPoint to have more consistent code, changed the final color math so that it passes q1bsp/q2bsp lighting through unmodified. Changed shading of tag_entity attachments - they now use the root entity's origin for shading, this fixes r_shadows where the shadows could go in different directions on CSQC entities (r_shadows code already contained a hack to work around this problem for network entities). Renamed r_refdef.lightmapintensity and ambient to r_refdef.scene.lightmapintensity and ambientintensity. git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12376 d7cf8633-e32d-0410-b094-e92efae38249
Rewrote bouncegrid path splatting, it now has a cone shape which grows with distance, which reduces the splotchy look (cvars r_shadow_bouncegrid_lightpathsize_initial and r_shadow_bouncegrid_lightpathsize_conespread control this). Replaced r_shadow_bouncegrid_(static|dynamic)_energyperphoton with r_shadow_bouncegrid_(static|dynamic)_quality cvar which works opposite the old one and is automatically multiplied by spacing^2 so you no longer have to hand-tune it when changing spacing. Turned off r_shadow_bouncegrid_blur by default - it's still useful but no longer completely necessary. Replaced r_shadow_bouncegrid_dynamic_stablerandom with r_shadow_bouncegrid_rng_type (which defaults to Lehmer 128bit RNG) and added r_shadow_bouncegrid_rng_seed (which can be set to -1 for the time-based random that stablerandom <= 0 used to trigger). git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12304 d7cf8633-e32d-0410-b094-e92efae38249
Fix severe bugs in mul128 implementation which was breaking the Lehmer RNG. Added gcc specific implementation of mul128 using __int128 intrinsic type. Added unit tests for mul128 implementation. Added r_shadow_bouncegrid_normalizevectors cvar, default on, this slightly brightens typical scenes, some more affected than others. Changed the behavior of r_shadow_bouncegrid_dynamic_stablerandom to also affect static mode, changed it to use the light position as the RNG seed, and changed the meaning of stablerandom 1 to be lhcheeserandom again as it is fast and of sufficient quality, the Lehmer RNG is available as stablerandom 2 but it has a framerate hit in dynamic mode that I can't ignore. git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12301 d7cf8633-e32d-0410-b094-e92efae38249
Significant rework of bouncegrid photon distribution and coloring. r_editlights mode now shows render stats in the overlay. git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12300 d7cf8633-e32d-0410-b094-e92efae38249
Changed bouncegrid to use its own buffers (Mem_Alloc) instead of R_FrameData_Alloc because bouncegrid can be > 500MB per allocation which is unreasonable pressure on R_FrameData_Alloc. Reduce memory when using r_shadow_bouncegrid_blur by ping-ponging between two buffers rather than three. Reduce memory when using small values of r_shadow_bouncegrid_(static|dynamic)_spacing by disabling blur and instead effectively increasing r_shadow_bouncegrid_lightpathsize by 2 (the result is identical, just slower). git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12299 d7cf8633-e32d-0410-b094-e92efae38249
Rollback last change which was meant to be many smaller pieces. git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12291 d7cf8633-e32d-0410-b094-e92efae38249
Added developer_memorylargerthanmb cvar which dprints notices about very large memory allocations (16MB and larger by default). Slightly improved the Mem_Alloc out of memory error to include the size of the failed allocation. git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12290 d7cf8633-e32d-0410-b094-e92efae38249
Overhauled shadowmap rendering to use an atlas texture, this is overall a speed loss on default settings (-7.7% fps on timedemo demo1, or -3% with r_shadow_deferred) but a gain on realtime world lighting (+21.1% normal, +1.7% with r_shadow_deferred) on NVIDIA GTX 680. On video drivers with higher framebuffer switching costs, this should be a framerate gain in all situations. Feature-wise this brings support (in future) for shadowmapping on transparent lit surfaces, and imposes an upper bound on how many pixels of shadowmaps will be rendered in a frame (shadowmap resolution automatically becomes more coarse on frames where they do not fit). git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12281 d7cf8633-e32d-0410-b094-e92efae38249
Added r_shadow_bouncegrid_lightpathsize which is an alternative to blur - but in practice this is just slower at a value of 3 than 1 is with blur, so blur remains the default approach. Implemented r_shadow_bouncegrid_floatcolors cvar which uses fp16 and fp32 float formats to increase dynamic range. Overhauled the default values of the bouncegrid cvars to look better. git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12277 d7cf8633-e32d-0410-b094-e92efae38249
implemented r_shadow_bouncegrid_blur, this tremendously improves quality at a cost of processing time, eliminating many rounding error problems in all levels. renamed several r_shadow_bouncegrid_* cvars to have a dynamic prefix, and split spacing so that it can also be different between static/dynamic modes (static now uses 32). git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12276 d7cf8633-e32d-0410-b094-e92efae38249
Refactored r_shadow_bouncegrid light splatting code, it now makes an array of light paths and then performs their splatting in a separate step with an optional sort. Implemented culling of out-of-view light paths in dynamic mode. git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12275 d7cf8633-e32d-0410-b094-e92efae38249