Commit graph

172 commits

Author SHA1 Message Date
reduz 0d2e02945b Implement shader caching
* Shader compilation is now cached. Subsequent loads take less than a millisecond.
* Improved game, editor and project manager startup time.
* Editor uses .godot/shader_cache to store shaders.
* Game uses user://shader_cache
* Project manager uses $config_dir/shader_cache
* Options to tweak shader caching in project settings.
* Editor path configuration moved from EditorSettings to new class, EditorPaths, so it can be available early on (before shaders are compiled).
* Reworked ShaderCompilerRD to ensure deterministic shader code creation (else shader may change and cache will be invalidated).
* Added shader compression with SMOLV: https://github.com/aras-p/smol-v
2021-05-31 10:13:09 +02:00
Rémi Verschelde f1abfbbeb1
Merge pull request #48837 from Soupstraw/shader-pi
Added constants PI, TAU and E to the shader language
2021-05-25 18:07:15 +02:00
Rémi Verschelde f050719da8
Merge pull request #48933 from Chaosus/shader_array_params
Allow shader arrays to be passed as parameters and return value in functions
2021-05-25 11:47:08 +02:00
Joosep Jääger 16567321ba Added constants PI, TAU and E to the shader language 2021-05-25 12:15:08 +03:00
reduz 789713b008 Support for 2D particles to collide against SDF
-Added SDF collision support for 2D particles
-Changed the SDF generation to be fully signed
2021-05-23 16:43:36 -03:00
Yuri Roubinsky 5874b7a29c Allow shader arrays to be passed as parameters and return value 2021-05-22 20:15:03 +03:00
Winston Hartnett 96fa2ee2a0 Fix instance uniform typo 2021-05-20 21:11:40 -05:00
Rémi Verschelde 4219a4cb6f
Fix typos with codespell
Using codespell 2.0.0.

Method:
```
$ cat > ../godot-word-whitelist.txt << EOF
ang
curvelinear
dof
doubleclick
fave
findn
GIRD
leapyear
lod
merchantibility
nd
numer
ois
ony
que
seeked
synching
te
uint
unselect
webp
EOF

$ codespell -w -q 3 -I ../godot-word-whitelist.txt --skip="./thirdparty,*.po"
$ git diff // undo unwanted changes
```
2021-05-20 12:38:56 +02:00
Yuri Roubinsky 6135744786 Implements length() shader function for arrays in structs 2021-05-19 21:50:11 +03:00
Bastiaan Olij 02980be834 Implementing blit shader with versions 2021-05-12 22:52:28 +10:00
Rémi Verschelde 0c693f8781
Merge pull request #48472 from BastiaanOlij/render_state
Make better use of our render_state struct
2021-05-12 13:44:03 +02:00
reduz 479391ef54 Fixes missng 2D engine bits
-Mesh2D now works
-MultiMesh2D now works
-Polygon2D now works
-Added hooks for processing 2D particles
-Skeleton2D now works

2D particles still not working, but stuff needed for it is now implemented.
2021-05-11 11:21:36 -03:00
Bastiaan Olij 308b26762b Split RenderDataRD struct from RenderState struct to simplify passing our render data around the renderer. 2021-05-10 21:52:15 +10:00
Rémi Verschelde 7449d6c752
Merge pull request #48435 from BastiaanOlij/no_repeat_mobile_renderer
Remove repeat from forward mobile renderer
2021-05-05 16:19:03 +02:00
Bastiaan Olij cc45ed448b Remove repeat from forward mobile renderer 2021-05-04 11:37:58 +10:00
jfons 6995b0429c Assorted fixes to UV unwrapping and GPU lightmapper
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-05-03 18:10:34 +02:00
Bastiaan Olij 58ff0dac1a Create mobile renderer 2021-05-03 21:54:11 +10:00
reduz 90056460ad Implement Particle Trails
-Enable the trails and set the length in seconds
-Provide a mesh with a skeleton and a skin
-Or, alternatively use one of the built-in TubeTrailMesh/RibbonTrailMesh
-Works deterministically
-Fixed particle collisions (were broken)
-Not working in 2D yet (that will happen next)
2021-04-30 17:38:02 -03:00
Rémi Verschelde 305b2a15bf
Merge pull request #48239 from akien-mga/goodbye-copymem
Core: Drop custom `copymem`/`zeromem` defines
2021-04-28 11:04:05 +02:00
Rémi Verschelde 95cfce661b
Merge pull request #48050 from JFonS/occlusion_culling 2021-04-27 19:07:12 +02:00
Rémi Verschelde 8247667a3e
Core: Drop custom copymem/zeromem defines
We've been using standard C library functions `memcpy`/`memset` for these since
2016 with 67f65f6639.

There was still the possibility for third-party platform ports to override the
definitions with a custom header, but this doesn't seem useful anymore.
2021-04-27 16:26:27 +02:00
Dennis Brakhane 31d41d83c3 Remove duplicate comments
A few single line comments were duplicated, probably due to bad merges.

This commit removes the obviously duplicate ones.
2021-04-25 20:03:52 +02:00
jfons 4d9d99bb82 Implement occlusion culling
Added an occlusion culling system with support for static occluder meshes.
It can be enabled via `Project Settings > Rendering > Occlusion Culling > Use Occlusion Culling`.

Occluders are defined via the new `Occluder3D` resource and instanced using the new
`OccluderInstance3D` node. The occluders can also be automatically baked from a
scene using the built-in editor plugin.
2021-04-23 21:45:23 +02:00
Bastiaan Olij ebf10fe736 Fix reflection probe 2021-04-21 23:42:29 +10:00
reduz 906882ee66 Split particle shader entry points
* Particle shaders now have start() and process()
* Particle collision happens between them.
* The RESTART property is kept, so porting an old shader is still possible.

This fixes the problem of particle collisions not functioning on the first particle frame.
2021-04-17 12:22:55 -03:00
reduz d3b49c416a Refactor GLSL shader compilation
-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-04-14 11:37:52 -03:00
Bastiaan Olij 71c5d73b5e Remove low_end option from renderer, being replaced by separate implementation 2021-04-09 22:04:56 +10:00
Bastiaan Olij dad40fa2df Move clustered renderer functionality 2021-04-05 23:11:38 +10:00
Rémi Verschelde d83761ba80
Style: Apply clang-tidy's readability-braces-around-statements 2021-04-05 14:09:59 +02:00
Rémi Verschelde 65a2888057
Style: Apply clang-tidy's modernize-use-default-member-init 2021-04-05 13:37:27 +02:00
Bastiaan Olij e93c9fc4ed As GLSLang seems to be all or nothing, added our own defines 2021-03-31 21:47:25 +11:00
Bastiaan Olij 7f63c9e7c9 Changed SCsub for shaders to find shaders automatically and create dependencies with include files 2021-03-18 12:59:47 +11:00
Ignacio Abal ccdd7ab890 Added validation when assigning heightfield_resolution (Fix #46281) 2021-03-17 12:03:52 -03:00
Bastiaan Olij f7cbeb0d1b Removed time duplicate from ForwardClustered. Just use the variable from its superclass 2021-03-11 18:08:10 +11:00
Bastiaan Olij 73b5eb2673 Combine init_gi and init_sdfgi into a single init 2021-03-11 18:07:33 +11:00
Bastiaan Olij 52ab369d5f Renamed one more Forward render struct and fixed typo 2021-03-11 14:18:05 +11:00
Bastiaan Olij dfc41eb6f6 Moving RendererStorageRD *storage to protected, no sense duplicating it in forward_clustered 2021-03-11 13:24:23 +11:00
Bastiaan Olij a895844c82 Renaming RendererSceneRenderForward to RendererSceneRenderForwardClustered so we can introduce RendererSceneRenderForwardMobile 2021-03-10 22:34:50 +11:00
Rémi Verschelde 3856bc5afe
Merge pull request #46642 from BastiaanOlij/sdfgi_rename_and_cleanup
Renamed SDGIShader to SDFGIShader and moved a bunch of things to private
2021-03-08 08:22:48 +01:00
Ev1lbl0w 1f0b60c47d
Fix negative VRAM values 2021-03-05 21:48:20 +00:00
Bastiaan Olij 760be46a81 Renamed SDGIShader to SDFGIShader and moved a bunch of things to private 2021-03-04 11:53:09 +11:00
Bastiaan Olij 1f96ba5141 Moving GI code into RendererServerGIRD
Moving Skyshader code into RendererServerSkyRD
2021-02-25 15:15:48 +11:00
Clay John 32dec4accd
Merge pull request #45326 from clayjohn/VULKAN-ign-shadows
Use Interleaved gradient noise for shadow samples
2021-02-18 13:17:41 -08:00
reduz 64140eaf42 Reorganize Project Settings
-Advanced Settings toggle also hides advanced properties when disabled
-Simplified Advanced Bar (errors were just plain redundant)
-Reorganized rendering quality settings.
-Reorganized miscelaneous settings for clean up.
2021-02-18 11:23:34 -03:00
Kayomn fa8a47e1bf Fix math error in blend shape application tolerance 2021-02-17 10:30:29 +01:00
Rémi Verschelde e9a25b8552
Merge pull request #45859 from Kayomn/master
Accomodate blend shape ranges of -1 to +1 for Vulkan
2021-02-12 09:26:14 +01:00
Yuri Roubinsky dd0874e717 Allow passing varying from fragment to light shader function 2021-02-11 15:59:21 +03:00
reduz 8b19ffd810 Make Servers truly Thread Safe
-Rendering server now uses a split RID allocate/initialize internally, this allows generating RIDs immediately but initialization to happen later on the proper thread (as rendering APIs generally requiere to call on the right thread).
-RenderingServerWrapMT is no more, multithreading is done in RenderingServerDefault.
-Some functions like texture or mesh creation, when renderer supports it, can register and return immediately (so no waiting for server API to flush, and saving staging and command buffer memory).
-3D physics server changed to be made multithread friendly.
-Added PhysicsServer3DWrapMT to use 3D physics server from multiple threads.
-Disablet Bullet (too much effort to make multithread friendly, this needs to be fixed eventually).
2021-02-10 13:21:46 -03:00
Kayomn ca945421a0 Accomodate blend shape ranges of -1 to +1 2021-02-09 23:09:54 +00:00
reduz 3e2281a347 Improve SDFGI indirect light feedback loop
-Use occlusion for feedback, further reduces light leaking.
-More control on feedback, now its a slider.
2021-02-07 21:30:12 -03:00
jfons 99e1ce0690 Invert spotlight angle attenuation
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-02-07 20:10:33 +01:00
Rémi Verschelde 7a60c45671
Merge pull request #45786 from reduz/fix-sdfgi-radeon
Fixed an SDFGI reflections bug in Radeon
2021-02-07 12:24:07 +01:00
reduz c4daf1c4ba Fixed a SDFGI reflections bug in Radeon
-Code was using too many conditionals.
-Rewrote it to use less and it now works fine.
2021-02-07 07:33:41 -03:00
jfons 9c6b081ab1 Fix volumetric fog for SpotLights
The code for spot lights was referencing the omni light list. Most
likely a copy-paste mistake :)
2021-02-07 03:38:09 +01:00
reduz d0cc899398 Fix SDFGI bug after previous optimization.
Was causing arctifacts, should be good now.
2021-02-06 18:49:10 -03:00
reduz 8faf23b52b Simplify Volumetric Fog
-Always use temporal reproject, it just loos way better than any other filter.
-By always using termporal reproject, the shadowmap reduction can be done away with, massively improving performance.
-Disadvantage of temporal reproject is update latency so..
-Made sure a gaussian filter runs in XY after fog, this allows to keep stability and lower latency.
2021-02-06 15:08:21 -03:00
Lyuma 780e761dbc Fix mismatched define in scene_forward.glsl for POSITION override 2021-02-05 13:09:33 -08:00
reduz 7997544af5 Added temporal reprojection to Volumetric Fog
-It's an option, just enable it
-Just works, don't have to do anything else.
2021-02-05 10:52:54 -03:00
reduz 33278b0721 Fixes to get Godot running again on Intel IGP
-Fixed strange bug with shadowed instance_param (this should not have worked anywhere, odd..)
-Cleaned up barrier usage further.
2021-02-05 00:02:06 -03:00
reduz f20999f6fe Rewrote how barriers work for faster rendering
-Added more finegrained control in RenderingDevice API
-Optimized barriers (use less ones for thee same)
-General optimizations
-Shadows render all together unbarriered
-GI can render together with shadows.
-SDFGI can render together with depth-preoass.
-General fixes
-Added GPU detection
2021-02-04 09:42:28 -03:00
Rafał Mikrut 0c3febca06 Don't use trashy max_decals value to prevent crashes 2021-02-01 21:43:08 +01:00
Rémi Verschelde d2e1216504
Merge pull request #37547 from aaronfranke/tau
Use Math_TAU and deg2rad/etc in more places and optimize code
2021-02-01 20:55:25 +01:00
reduz 280f334f81 Reorganize RenderingDevice barriers
-Removed sync to draw, now everything syncs to draw by default.
-Fixed many validation layer errors.
-Added support for VkImageViewUsageCreateInfo to fix validation layer warnings.
-Texture, buffer, raster and compute functions now all allow spcifying which barriers will be used.
2021-01-26 10:24:12 -03:00
clayjohn 7323cbab4b Add named resources and debug labels in RenderDoc 2021-01-25 20:04:13 -08:00
reduz 51d8e32c93 Implement shadow meshes
-When importing, a vertex-only version of the mesh is created.
-This version is used when rendering shadows, and improves performance by reducing bandwidth
-It's automatic, but can optionally be used by users, in case they want to make special versions of geometry for shadow casting.
2021-01-25 15:03:15 -03:00
reduz a9beb7aa8c Shadow map rendering optimization
-All shadow rendering is done with raster now (no compute)
-All shadow rendering is done by rendering directly to the shadow atlas
-Improved how buffer clearing is done to optimize the above.
-Ability to set shadows as 16 bits.
2021-01-24 20:17:28 -03:00
reduz 6fe342478b Several GI related optimizations and fixes
-SDFGI direct light is done over many frames
-SDFGI Changed settings for rays/frame
-SDFGI Misc optimizations
-SDFGI Bug fix on probe scroll

-GIProbe was not working, got it to work again
-GIProbe dynamic objects were not working, fixed

-Added a half size GI option.
2021-01-24 19:29:07 -03:00
clayjohn 561de937b1 Use Interleaved gradient noise for shadow samples 2021-01-21 07:47:01 -08:00
Rémi Verschelde a9b151c664
Merge pull request #44668 from clayjohn/VULKAN-downsample
Use cubemap downsampler for reflection mipmaps
2021-01-20 20:41:47 +01:00
reduz 099dee35f4 Added GPU based cluster builder
Clustering is now GPU based, uses an implementation based on the Activision algorithm.
2021-01-19 23:31:06 +01:00
reduz 7008e3c6ea Shader optimizations to reduce VGPR usage and increase occupancy 2021-01-19 23:31:02 +01:00
Rémi Verschelde 0b409d89d0
Merge pull request #45136 from akien-mga/clang-format-11
CI: Update to clang-format 11 and apply ternary operator changes
2021-01-13 16:10:44 +01:00
Rémi Verschelde af878716f2
CI: Update to clang-format 11 and apply ternary operator changes 2021-01-12 19:32:53 +01:00
Yuri Roubinsky ef941a6500 Renamed emit_particle to emit_subparticle shader function 2021-01-12 09:41:08 +03:00
Yuri Roubinsky fcc5d67b03 Fix shader uniform instances compilation 2021-01-11 17:46:33 +03:00
Yuri Roubinsky fdfddbdc3c Fix LIGHT compilation for canvas shader 2021-01-09 23:22:59 +03:00
Aaron Franke 1d5042c9e2
Use Math_TAU and deg2rad/rad2deg in more places and optimize code 2021-01-09 03:47:14 -05:00
reduz cdb216f4e4 Added ability to visualize native shaders 2021-01-06 09:40:09 -03:00
reduz 446618cf94 Change the light attenuation formulas.
-Much better looking, physically based.
-Almost negligible extra cost.
2021-01-05 14:44:05 -03:00
reduz 77bc3e9ac3 Threaded optimizations to cull and render
-Reorganize thread work pool for rendering
-Fixes to make secondary command buffers to work (disabled because they need more testing)
2021-01-05 08:50:18 -03:00
reduz 5d2a1d7892 Rewrite render code to be more cache and thread friendly. 2021-01-05 08:50:18 -03:00
reduz 9a2f18f8e7 Reorganize renderer code.
So it can hopefully be made more cache efficient afterwards.
2021-01-05 08:50:18 -03:00
Rémi Verschelde 00f5ea2ed2
Merge pull request #44842 from clayjohn/VULKAN-SSAO-2
SSAO renames and move push constant binding
2021-01-04 23:03:54 +01:00
Hendrik Brucker ec6fc059b7 fix inconsistent normal map shader variable naming 2021-01-04 14:08:01 +01:00
Rémi Verschelde a408622c06
Merge pull request #44530 from clayjohn/VULKAN-framebuffer-error
Use basic uniform set for depth prepass
2021-01-04 09:34:27 +01:00
clayjohn 0015260c4b SSAO cleanup and fixes 2021-01-03 21:32:22 -08:00
Muller-Castro 31dd07ba30 Typo correction
simple typo correction
2021-01-02 02:27:12 -03:00
Rémi Verschelde b5334d14f7
Update copyright statements to 2021
Happy new year to the wonderful Godot community!

2020 has been a tough year for most of us personally, but a good year for
Godot development nonetheless with a huge amount of work done towards Godot
4.0 and great improvements backported to the long-lived 3.2 branch.

We've had close to 400 contributors to engine code this year, authoring near
7,000 commit! (And that's only for the `master` branch and for the engine code,
there's a lot more when counting docs, demos and other first-party repos.)

Here's to a great year 2021 for all Godot users 🎆
2021-01-01 20:19:21 +01:00
Marcel Admiraal b4a190e0bc Consistently use normal_map 2020-12-29 08:04:19 +00:00
Rémi Verschelde 058f3fe069
Merge pull request #44149 from madmiraal/rename-tangent-orthogonal
Rename Vector2.tangent() to Vector2.orthogonal()
2020-12-28 16:00:12 +01:00
Marcel Admiraal 5b937d493f Rename empty() to is_empty() 2020-12-28 10:39:56 +00:00
Rémi Verschelde 1f7d6ba736
Merge pull request #44715 from clayjohn/VULKAN-SSAO-cleanup
Cleanup leftover functions from adding SSAO
2020-12-27 10:53:23 +01:00
Yuri Roubinsky ef4e625918
Merge pull request #44705 from Chaosus/shader_fix_array_postinit
Fix using post-init shader array constructors
2020-12-27 08:26:31 +03:00
clayjohn 34cfe1cc40 Cleanup leftover functions from adding SSAO 2020-12-26 16:33:07 -08:00
reduz 548524152e Rewrite culling to be more cache/thread friendly.
-Uses a single array with all data
-Massive performance improvement
-Does not support threads yet, but code is now thread friendly
2020-12-26 19:11:33 -03:00
Yuri Roubinsky bc0e8e7a21 Fix using post-init shader array constructors 2020-12-27 01:07:24 +03:00
Yuri Roubinsky fb16b1e39b
Merge pull request #44436 from Chaosus/shader_const_switch
Added support for constants in shader `case` and array size declaration
2020-12-27 00:55:45 +03:00
clayjohn 28d0f8a455 Use cubemap downsampler for reflection mipmaps 2020-12-24 16:39:17 -08:00
Lyuma d976003b16 Fix blendshapes and calculation of bone_aabbs
Blendshapes without a skeleton already worked.
However, due to a faulty ERR_FAIL_COND, it was impossible to create a mesh with both bones and blendshapes.
This also fixes an assumption that all surfaces reference the same number of bones as surface 0.
2020-12-24 00:01:07 -08:00
clayjohn 3a8c99a10b Use basic uniform set for depth prepass 2020-12-23 20:23:51 -08:00