summaryrefslogtreecommitdiff
path: root/modules/lightmapper_rd/lm_compute.glsl
AgeCommit message (Collapse)Author
2022-08-31Implement Physical Light Units as an optional setting.clayjohn
This allows light sources to be specified in physical light units in addition to the regular energy multiplier. In order to avoid loss of precision at high values, brightness values are premultiplied by an exposure normalization value. In support of Physical Light Units this PR also renames CameraEffects to CameraAttributes.
2022-06-24add support for soft shadows to the lightmapperPriyansh Rathi
2022-02-11RendererRD: Remove binding specifier for push constantsRémi Verschelde
This is unsupported and glslang made it raise an error in 11.7.0: https://github.com/KhronosGroup/glslang/pull/2810 Co-authored-by: Clay John <claynjohn@gmail.com>
2021-11-19GPULightmapper: better algorithm to generate rays for indirect lightingWilliam Deurwaarder
Previous algorithm used an algorithm to generate rays that was not completely random. This caused artifacts when large lighmap textures were used. The new algorithm creates better rays and by that prevents artifacts.
2021-10-15GPULightmapper: increase ray triangle hit rateWilliam Deurwaarder
Currently the method ray_hits_triangle determines triangles not to be hit by a ray due to an epsilon that is too big. In practice those triangles are hit by those rays. This is fixed by introducing a smaller epsilon.
2021-10-13Merge pull request #53744 from williamd67/GPULightmapper-prevent-endless-loopRémi Verschelde
2021-10-12GPULightmapper: prevent loop with max iterationsWilliam Deurwaarder
In case the calculation of the delta contained infinity values (division by zero), than later the calculation of the next cell failed as the infinity value was multiplied by zero which resulted in a nan. The nan-value caused that the next cell was equal to the current cell which resulted in an end-less loop, which only terminates by the maximum iterations protection. This is solved by replacing infinity with grid_size which acts as infinity.
2021-10-12GPULightmapper: process rays to sky in all bounces as activeWilliam Deurwaarder
Before this change only rays to the sky (RAY_MISS) in the first bounce were processed as active rays. This caused artifacts, areas were too light, when more than one bounce were processed. Now rays to the sky are processed as active rays for all bounces.
2021-09-14GPULightmapper exclude back-face triangles while calculating bouncesWilliam Deurwaarder
Edges that are at the edge of a plane, may get behind the scene and will hit back-face triangles which where included in the lighting calculations. This caused leaking of light at the edge of planes. In case a ray hits back-face triangle, it is skipped in the bounce calculations.
2021-09-11GPULightmapper's triangles and their bounding box will be in-syncWilliam Deurwaarder
Previously the bounding boxes and triangles were maintained in two separate arrays (Vectors). As the triangle vector was sorted and the bounding-box array was not , the order of both arrays differed. This meant that the index in one was different than the other, which caused lookup issues. To prevent this, the bounding-box is now part of the triangle structure so that there is a single structure that cannot become out-of-sync anymore.
2021-05-03Assorted fixes to UV unwrapping and GPU lightmapperjfons
Various fixes to UV2 unwrapping and the GPU lightmapper. Listed here for context in case of git blame/bisect: * Fix UV2 unwrapping on import, also cleaned up the unwrap cache code. * Fix saving of RGBA images in EXR format. * Fixes to the GPU lightmapper: - Added padding between atlas elements, avoids bleeding. - Remove old SDF generation code. - Fix baked attenuation for Omni/Spot lights. - Fix baking of material properties onto UV2 (wireframe was wrongly used before). - Disable statically baked lights for objects that have a lightmap texture to avoid applying the same light twice. - Fix lightmap pairing in RendererSceneCull. - Fix UV2 array generated from `RenderingServer::mesh_surface_get_arrays()`. - Port autoexposure fix for OIDN from 3.x. - Save debug textures as EXR when using floating point format.
2021-04-14Refactor GLSL shader compilationreduz
-Used a more consistent set of keywords for the shader -Remove all harcoded entry points -Re-wrote the GLSL shader parser, new system is more flexible. Allows any entry point organization. -Entry point for sky shaders is now sky(). -Entry point for particle shaders is now process().
2021-02-07Invert spotlight angle attenuationjfons
Inverted the spotlight angle attenuation so a higher value results in a dimmer light, this makes it more consistent with the distance attenuation. Also changed the way spotlighs are computed in SDFGI and GIPorbes and GPU lightmapper, now it matches the falloff used in the scene rendering code.
2021-01-05Change the light attenuation formulas.reduz
-Much better looking, physically based. -Almost negligible extra cost.
2020-05-18GLSL: Change shader type specifier from [vertex] to #[vertex]Rémi Verschelde
The added `#` prevents clang-format from misinterpreting the meaning of this statement and thus messing up the formatting of the next lines up until the first `layout` statement. Similarly, a semicolon is now enforced on `versions` defines to prevent clang-format from messing up formatting and putting them all on a single line. Note: In its current state the code will ignore chained statements on a single line separated by a semicolon. Also removed some extraneous lines missed in previous style changes or added by mistake with said changes (e.g. after uniform definitions that clang-format messes up somewhat too, but we live with it).
2020-05-14Style: Enforce separation line between function definitionsRémi Verschelde
I couldn't find a tool that enforces it, so I went the manual route: ``` find -name "thirdparty" -prune \ -o -name "*.cpp" -o -name "*.h" -o -name "*.m" -o -name "*.mm" \ -o -name "*.glsl" > files perl -0777 -pi -e 's/\n}\n([^#])/\n}\n\n\1/g' $(cat files) misc/scripts/fix_style.sh -c ``` This adds a newline after all `}` on the first column, unless they are followed by `#` (typically `#endif`). This leads to having lots of places with two lines between function/class definitions, but clang-format then fixes it as we enforce max one line of separation. This doesn't fix potential occurrences of function definitions which are indented (e.g. for a helper class defined in a .cpp), but it's better than nothing. Also can't be made to run easily on CI/hooks so we'll have to be careful with new code. Part of #33027.
2020-05-14Style: clang-format: Disable KeepEmptyLinesAtTheStartOfBlocksRémi Verschelde
Which means that reduz' beloved style which we all became used to will now be changed automatically to remove the first empty line. This makes us lean closer to 1TBS (the one true brace style) instead of hybridating it with some Allman-inspired spacing. There's still the case of braces around single-statement blocks that needs to be addressed (but clang-format can't help with that, but clang-tidy may if we agree about it). Part of #33027.
2020-05-10New lightmapperJuan Linietsky
-Added LocalVector (needed it) -Added stb_rect_pack (It's pretty cool, we could probably use it for other stuff too) -Fixes and changes all around the place -Added library for 128 bits fixed point (required for Delaunay3D)