TokisanGames / Terrain3D

A high performance, editable terrain system for Godot 4.
MIT License
2.26k stars 134 forks source link

Compatibility renderer support #500

Closed Xtarsia closed 1 month ago

Xtarsia commented 1 month ago

Admin edit: Fixes #217


Detects whether Godot is using the compatibility renderer.

If so, The generated shader will have a set of #defines added that allow full support for the standard shader. The shader override will have the #defines visible at the begining on the shader, before shader_type.

The editor will inject code at the begining, and the end either the standard shader, or any provided override shader in order to draw a "decal" on the terrain.

in the interest of simplicity, the gdscript changes are as small as possible, tho some things are a bit inneficient, performace is fine and its only during editing anyways.

The slope tool doesnt have propper decal support.

adding terrain3d.get_compatibility() seems a bit dubious to me, but saved repeating a ton of code in gdscript, and ensures that the editor is always on the same page.

Finally, there are no warnings at the moment when the albedo and normal arrays are in compressed mode. for 4.3 this is fixed anyways, but for 4.2 all textures will be black. The workaround is to re-import all textures as "Lossless". Resizing to half resolution results in the same VRAM use for Lossless vs Compressed at the original size.

EDIT: recently updated test version is available: https://github.com/Xtarsia/Terrain3D/actions/runs/11079134556

Xtarsia commented 1 month ago

Im unable to get web export working, i suspect due to needing custom export template build for terrain 3D, or something along those lines.

As for textures import settings for 4.2, both options work.

I'll add some initial things to platform.md in the mean time.

TokisanGames commented 1 month ago
TokisanGames commented 1 month ago

image

Xtarsia commented 1 month ago

I think I need to tidy up the regex stuff a bit still.

TokisanGames commented 1 month ago

It seems that all the samplers need highp. Including those in uniforms.glsl. Mistakenly posted an update here

Xtarsia commented 1 month ago

This PR https://github.com/godotengine/godot/pull/85430 should make correctly determining when to use compatibility modifications much simpler.

TokisanGames commented 1 month ago

Ok, down to 4 clean, topical commits. Thanks for all the work on this. It will help a lot of people.