267 Commits

Author SHA1 Message Date
Marc Gilleron
5943b1d549 Moved VirtualTextureOutput out of VoxelMesher 2022-08-14 22:34:27 +01:00
Marc Gilleron
92b3c25292 Moved distance_normalmaps to engine/ since it doesn't depend on meshers 2022-08-14 21:53:59 +01:00
Marc Gilleron
bab04748b3 Make normalmap baking more independent
- The baking code no longer depends on Transvoxel
- Moved usage out of the Transvoxel mesher, but still uses its fastpath
  for cells. There is still no "generic" path because there is no need yet.
- Moved settings on VoxelLodTerrain.
2022-08-14 19:15:55 +01:00
Marc Gilleron
cf43ff5201 Missing include 2022-08-13 16:58:06 +01:00
Marc Gilleron
dbbab6a81d Separate normalmap baking from meshing, so meshes don't have to wait.
- The option for having it separate is hardcoded and both code paths still
  exist. Not sure if that will be exposed or removed entirely.
- Still need to limit the frequency at which normalmaps are updated
- Would be nice to make this mesher-independent,
  Transvoxel is just a fastpath
- Task priority might need improvement, it's a bit messy. Maybe use bands?
2022-08-13 16:40:46 +01:00
Marc Gilleron
0b26071663 Support edited voxels in distance normalmaps 2022-08-09 23:56:38 +01:00
Marc Gilleron
b0cd02a2ef Support modifiers in distance normalmaps 2022-08-07 23:03:45 +01:00
Marc Gilleron
5bb0f4a508 Fix some signedness GCC warnings 2022-08-07 23:00:41 +01:00
Marc Gilleron
fcd1fc38a5 Group properties in VoxelMesherTransvoxel 2022-08-07 18:05:16 +01:00
Marc Gilleron
04bc2110df Default octahedral encoding to false for now because it doesnt look good enough 2022-08-07 17:46:20 +01:00
Marc Gilleron
c15ded67f6 Vary tile size with LOD and integrate to VoxelLodTerrain 2022-08-07 16:40:27 +01:00
Marc Gilleron
8dab1e8f2a Fail earlier if the generator does not support series generation 2022-08-07 16:15:51 +01:00
Marc Gilleron
c645bb708d Comments 2022-08-06 23:15:42 +01:00
Marc Gilleron
dcc5e3c174 Added option for octahedral encoding of normals to save memory 2022-08-04 21:19:02 +01:00
Marc Gilleron
3606ab9b93 No need to cache direction 2022-08-04 21:16:33 +01:00
Marc Gilleron
3ee3931824 Separated function to store into images only 2022-08-03 21:43:57 +01:00
Marc Gilleron
bde74f0785 Store final normals encoded instead of full vec3f, and copy into Image instead of using set_pixel 2022-08-03 21:31:29 +01:00
Marc Gilleron
6c0a1e4463 Missing ref 2022-08-03 21:05:26 +01:00
Marc Gilleron
9973ac5e3a Split into functions a bit 2022-08-03 19:31:24 +01:00
Marc Gilleron
adbe393440 Optimized triangle raycasts a bit 2022-08-03 18:49:46 +01:00
Marc Gilleron
2d757c7ece Moved distance normalmaps code to its own file 2022-07-31 23:04:36 +01:00
Marc Gilleron
0c3b103689 Improvements
- Project samples on triangles to make cells more seamless,
  instead of a box of samples on a quad. Requires 2x more samples.
- Don't sample when there is no triangle for a given pixel
- Dilate normalmaps to reduce artifacts on edge of triangles
- Moved math functions about triangles in their own file
2022-07-31 22:42:05 +01:00
Marc Gilleron
fcddf4da61 WIP normalmaps for Transvoxel.
Adds enough stuff to test the approach. It is not correct at the
moment, probably needs to project to triangles to make cells line up,
currently it's using planes. There might be incorrect coordinates too,
did that with bit of guessing. A grid-like pattern is also showing, so
might have to make tiles a bit larger to account for filtering.
2022-07-31 16:14:36 +01:00
Marc Gilleron
7254dcb7fc Template vector types 2022-07-17 18:34:05 +01:00
Marc Gilleron
ac62a05346 Fix errors caused by empty materials in VoxelBlockyLibrary 2022-07-16 19:39:36 +01:00
Marc Gilleron
c13303b464 Fix material properties were listing unsupported types 2022-07-16 17:37:22 +01:00
Marc Gilleron
ec24204ecc Add override specifiers 2022-07-03 03:39:50 +01:00
Marc Gilleron
6e501811d1 Unused variable 2022-06-26 19:21:21 +01:00
Marc Gilleron
afb83285f0 Update Transvoxel shader in docs, remove unnecessary shift 2022-06-26 18:33:03 +01:00
Marc Gilleron
d9b74359f8 Provide a default material for VoxelMesherTransvoxel with variable-lod 2022-06-26 17:21:05 +01:00
Marc Gilleron
eaa40876b8 Don't generate transition meshes when VoxelMesherTransvoxel is used in a fixed-lod volume 2022-06-26 17:20:08 +01:00
Marc Gilleron
647be47395 Fix secondary positions in positive axes 2022-06-25 17:28:00 +01:00
Marc Gilleron
ce91b3890c Combine regular and transition meshes together.
- Less draw calls
- Much faster rendering updates (about 5x),
  although colliders are still the biggest bottleneck so when collision is
  enabled this improvement isn't noticeable
- A shader is now always required to render Transvoxel properly.
  TODO: integrate a default one when no material is assigned?
2022-06-25 16:47:09 +01:00
Marc Gilleron
13a9bf7deb Prefix tls 2022-06-23 19:39:53 +01:00
Marc Gilleron
c7d8c2557c Attempting to give priority to main mesh building over transition meshes.
This effectively creates them after ALL main meshes have been built,
resulting in a seemingly faster convergence of LOD, however when moving
around it causes some cracks to appear briefly. This can be bad if the
terrain is dark and the underlying skybox is bright. Might need to be
optional, or find a different approach.
2022-06-22 22:05:25 +01:00
Marc Gilleron
c51f3d8005 Merge branch 'modifiers' 2022-06-20 19:53:23 +01:00
Marc Gilleron
317cd23616 Fix per-surface collision generation in VoxelMesherBlocky 2022-06-19 22:57:55 +01:00
Marc Gilleron
19f94e9912 Merge branch 'master' into modifiers 2022-06-19 21:41:38 +01:00
Marc Gilleron
a01fffd906 Fix mesh collision should be exposed as a boolean 2022-06-19 17:56:42 +01:00
Marc Gilleron
86ba74ce3a Some changes and fixes related modifiers
- VoxelLodTerrain no longer caches generated voxels by default, so
  generating on the fly is no longer exclusive to full load mode.
  Might add an option later, but not for now (VoxelTerrain is still
  unaffected and keeps caching them)
- The "Cached" state is represented with blocks having no voxel data,
  so it needs extra checks in some areas to avoid null access
- Fix generate task was not including modifiers after the base generator
- The "save_generator_output" option on streams now means such blocks are
  considered edited
- Modifying modifiers now clears cached generated blocks
  intersecting with them.
- Fix "re-generate" was erasing the internal stack of modifiers
- Added docs
2022-06-18 23:14:18 +01:00
Aaron Franke
3c37bb95a5
Add RWLock include to VoxelMeshLibrary header 2022-06-04 14:41:59 -05:00
Marc Gilleron
8966ad5b1f Fix holes in geometry with Transvoxel 2022-06-03 17:30:38 +01:00
Marc Gilleron
6aad611215 Moved methods outside Vector3f 2022-05-21 21:12:16 +01:00
Raphaël Duchaîne
f9690542b2
Cross-compiler compatibility: const -> constexpr
As suggested in https://github.com/Zylann/godot_voxel/issues/387
This allowed 2 full Mac builds using these commands:
 ```
scons platform=osx arch=x86_64 --jobs=$(sysctl -n hw.logicalcpu) warnings=all tools=yes tests=no target=release_debug production=yes
 ```
```
scons platform=osx arch=arm64 --jobs=$(sysctl -n hw.logicalcpu) warnings=all tools=yes tests=no target=release_debug production=yes voxel_fast_noise_2=false 
```
 -


( Also after having the VulkanSDK like mentioned here[1] and after deleting the `denoise` module which doesn't like ARM64)

[1]: https://github.com/godotengine/godot/issues/57622#issuecomment-1120486153
2022-05-18 16:15:14 -04:00
Marc Gilleron
008c38bb6b Fix some signedness warnings 2022-05-17 23:10:18 +01:00
Marc Gilleron
602ae1ea95 Don't crash if no materials are specified 2022-05-17 23:10:11 +01:00
Marc Gilleron
fa027cbe4e Allow to specify which surfaces have collision 2022-05-17 22:12:54 +01:00
Marc Gilleron
4f862722ae Removed usages of Map 2022-05-17 19:44:58 +01:00
Marc Gilleron
12862a46d0 Changes to blocky materials
- They are now defined in each model
- VoxelTerrain no longer has material slots, except for a global override
- Models can have up to 2 materials instead of only one
2022-05-16 22:55:06 +01:00
Marc Gilleron
09d0be21e2 Remove remaining usages of HashMap 2022-05-14 19:38:39 +01:00