Skip to content

Improve Region Blend, gizmos, shaders#899

Merged
TokisanGames merged 19 commits intoTokisanGames:mainfrom
Xtarsia:improve-flat-bg-mode
Jan 20, 2026
Merged

Improve Region Blend, gizmos, shaders#899
TokisanGames merged 19 commits intoTokisanGames:mainfrom
Xtarsia:improve-flat-bg-mode

Conversation

@Xtarsia
Copy link
Collaborator

@Xtarsia Xtarsia commented Dec 12, 2025

@TokisanGames
Copy link
Owner

Note, the color map is getting injected in #842.

@TokisanGames TokisanGames moved this to In Progress in Terrain3D Roadmap Dec 13, 2025
@TokisanGames TokisanGames added this to the 1.1 milestone Dec 13, 2025
@TokisanGames
Copy link
Owner

We could optionally generate new regions at ground level; and maybe the world noise offset level. Though I'm not terribly concerned about leaving it at 0.

@Xtarsia Xtarsia force-pushed the improve-flat-bg-mode branch from 8816be7 to fcda93b Compare December 13, 2025 18:25
@TokisanGames
Copy link
Owner

disable or provide option to use gizmos OR shader version

Do we need this? I'd like to drop the classes. The gizmos are ugly. As long as we can render everywhere we need, is there any reason to keep them?

@Xtarsia Xtarsia force-pushed the improve-flat-bg-mode branch 3 times, most recently from a08d5db to b8d3312 Compare December 15, 2025 09:12
@Xtarsia
Copy link
Collaborator Author

Xtarsia commented Dec 15, 2025

some quick AB test in the demo,
Main:
image

This PR:
image

The blendinging differences are due to the grass now being projected at the fixed 45 degree point as well.

@Xtarsia Xtarsia force-pushed the improve-flat-bg-mode branch from b8d3312 to f8ff8ca Compare December 15, 2025 10:20
@TokisanGames
Copy link
Owner

The speed boost is great. I don't see any, but are there any artifacts due to vertical projection? What happens with faces exactly at 45? Or when a grass slope starts off <45 and curves up >45? Is there a seam?

@Xtarsia
Copy link
Collaborator Author

Xtarsia commented Dec 15, 2025

The speed boost is great. I don't see any, but are there any artifacts due to vertical projection? What happens with faces exactly at 45? Or when a grass slope starts off <45 and curves up >45? Is there a seam?

The condition is checked against each index normal, (not the smooth interpolated terrain normal) and then the biliniear blend prevents seams.

So there are no severe stretching artifacts like before, if the threshold was too high/low.

@Xtarsia Xtarsia force-pushed the improve-flat-bg-mode branch 4 times, most recently from a20f57c to 73641d9 Compare December 17, 2025 11:50
@TokisanGames TokisanGames changed the title various improvements Improve Region Blend, gizmos, shaders Dec 19, 2025
@Xtarsia Xtarsia force-pushed the improve-flat-bg-mode branch 3 times, most recently from 491e304 to 4f04ede Compare December 19, 2025 10:44
@Xtarsia Xtarsia marked this pull request as ready for review December 19, 2025 10:44
Copy link
Owner

@TokisanGames TokisanGames left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, really nice work on the region blend, matching collision and the control we have over the edge of regions now. This makes sculpting down under the ocean a breeze.

I'm also very glad to be rid of the region gizmo. We can finally keep view gizmos turned on without seeing all of those annoying lines.

Some notes for improvement:

One of these is a region, the rest are not. What about making the grid near non-regions a dark/middle grey say around .333-.4, and white around regions?
Image


This addition to the material is great:

Image

I don't think these debug views are very useful. I was thinking these checkboxes would turn on and off the above material settings, and what they currently do goes away. They could be renamed, height dropped, etc.

Image

@TokisanGames
Copy link
Owner

Flat mode works great and will do well with an ocean. In None mode, I'm unable to sculpt down to any height I want without a lip.

{15C7C1E6-975F-4AB1-B1D5-03652D5A098C}

Depending on the camera angle the lip comes all the way up to 0.

{FBFFA5D6-9267-4244-AD3A-B0B8EFB3A3C2}

In Noise mode the region blend is a little odd.

In flat mode region_blend goes from the region height to ground_level. This provides great control over blending.

image

Here region_blend=0.25 with Noise, offset lower. Region_blend seems fixed at 0 height. It is more possible to get a usable coast line with Noise than it was before, but it still feels a bit inflexible. Is it possible for Noise to work more like Flat, using world_noise_offset.y as ground_level? Maybe with a multiplier (maybe of about 88).

{7AF9BB1D-9F6C-4074-9690-4C66AF1456C6}

@Xtarsia
Copy link
Collaborator Author

Xtarsia commented Dec 30, 2025

Yeah, i can look at making noise blend regions similar to flat.

None is problematic, but now that its a seperate insert, I could investigate it a bit more. I suspect having tesselation enabled doesnt work well with the current fix.

@Xtarsia Xtarsia force-pushed the improve-flat-bg-mode branch from 4f04ede to 57d13d7 Compare January 6, 2026 16:52
@Xtarsia
Copy link
Collaborator Author

Xtarsia commented Jan 6, 2026

NOISE background is now purely background (fixed blend, noise always has ZERO effect on in-region heights), and has the same features as FLAT mode.

The PBR debug views, I have found useful on occasion, for checking normals, heights etc are packed correctly. They are tucked away at the bottom of the debug views so I think its fine if they stay.

None mode I think could be a seperate issue, as it might need some investigating again.

@Xtarsia Xtarsia force-pushed the improve-flat-bg-mode branch from 8a8a4a7 to ee3a03f Compare January 9, 2026 13:30
@Xtarsia Xtarsia requested a review from TokisanGames January 9, 2026 21:35
Copy link
Owner

@TokisanGames TokisanGames left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really great work, as always. I fixed some broken things in the minimum shader, and adjusted categories in the shader uniforms and inspector parameters.

One pending issue is if the Region tool is selected, it shows the grid. If Terrain3D is deselected, the grid goes away. If reselected, it does not show the grid.

UNIFORMS = 0u,
TEXTURE_ARRAYS = 1u,
REGION_ARRAYS = 2u,
FULL_REBUILD = TEXTURE_ARRAYS | REGION_ARRAYS,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This structure is a little confusing.

  • UNIFORMS implies that it's optional, meaning update(TEXTURE_ARRAYS) won't include UNIFORMS, but it does in the activity.
  • 0 isn't a bit and should mean no flags are set. If UNIFORMS was optional it should be a bit. NONE or UNIFORMS_ONLY might be more clear. WorldBackground::NONE already exists and we might have an issue with the same name, especially in C#. Maybe I'll just do UNIFORMS_ONLY.
  • The values should look like bits, eg, 1<<1 or 0x1, 0x2, 0x4
  • Full Rebuild updates both the arrays, AND rebuilds the shader. There's no option to just do the arrays. I also added a new bit for full_rebuild, allowing doing the arrays only.

void _update_uniforms(const RID &p_material, const uint32_t p_update = UpdateFlags::UNIFORMS);
void _set_shader_parameters(const Dictionary &p_dict);
Dictionary _get_shader_parameters() const { return _shader_params; }
static inline bool _has_update_flag(uint32_t value, UpdateFlags flag) { return (value & static_cast<uint32_t>(flag)) != 0u; }
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need this. if (value & flag) is fine. If we need more type safety we could look at moving to C++20 and enum class and these helper functions. But this is only the first flags enum in the class.

map_data.resize(hshape_size * hshape_size);
real_t min_height = FLT_MAX;
real_t max_height = FLT_MIN;
real_t max_height = -FLT_MAX;
Copy link
Owner

@TokisanGames TokisanGames Jan 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FLT_MIN is not negative!? OMG

@TokisanGames TokisanGames merged commit a0aef00 into TokisanGames:main Jan 20, 2026
15 checks passed
@github-project-automation github-project-automation bot moved this from In Progress to Done in Terrain3D Roadmap Jan 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Terrain texture issue Bitflags for Material::update() Inject Projection PBR Channel debug views Draw region grid in shader instead of gizmos

2 participants