Zylann / godot_voxel

Voxel module for Godot Engine
MIT License
2.72k stars 251 forks source link

VoxelLodTerrain ignores set_shader_parameter on its material #707

Closed Illauriel closed 2 months ago

Illauriel commented 2 months ago

It's pretty straightforward - VoxelTerrain's Material accessed via material_override works fine, but VoxelLodTerrain's 'material' ignores it. Params can be sampled with 'get_shader_parameter', though.

https://github.com/user-attachments/assets/3af9e25f-ba1c-4ad6-85b3-d455b94950c2

I wonder if it's an implementation necessity, Godot shenanigans, or just a bug.

MRP: shader_param_mrp.zip

Zylann commented 2 months ago

Unfortunately, this is an implementation necessity. In VLT every chunk gets its own instance of ShaderMaterial due to per-chunk features and LOD, therefore changes to the original are not reflected. To do so, hundreds of chunks would have to replicate every change you do to them somehow (also I'm not sure you can even listen to a parameter in ShaderMaterial).

Illauriel commented 2 months ago

Unfortunately, this is an implementation necessity. In VLT every chunk gets its own instance of ShaderMaterial due to per-chunk features and LOD, therefore changes to the original are not reflected. To do so, hundreds of chunks would have to replicate every change you do to them somehow (also I'm not sure you can even listen to a parameter in ShaderMaterial).

Ah, I see. Well, there's a workaround, using global uniforms, and it's a niche thing anyway. I stumbled upon it making weather effects on terrain x) I just didn't want to overuse them, and reported just in case it's some kind of regression. Closing this, thanks a lot for the answer.

PS: Note to self to add it to LodTerrain's docs in 'material' property description. It's documented, but talks about different things.

Zylann commented 2 months ago

Documented in adf625d2c2578b937ce1f375a94adbea84f23fbc