Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Per-Layer TriPlanar and Refactoring for PBR Terrain Shaders #2353

Merged
merged 17 commits into from
Feb 3, 2025

Conversation

yaRnMcDonuts
Copy link
Member

@yaRnMcDonuts yaRnMcDonuts commented Feb 1, 2025

Refactored AdvancedPBRTerrain and PBRTerrain to work with the new modular system, making the shader much less confusing and easier to work with.

I also added 12 new boolean matParams (1 per layer) to toggle tri-planar mode on a per layer basis. The old UseTriPlanar boolean still works to toggle triplanar for the whole terrain, but now you also can enable triplanar for just 1 or 2 layers that need it most. (for example, mountain textures that are painted on vertical slopes typically always need triplanar to prevent noticable stretching, whereas a grass texture that is typically painted on mostly-flat areas of the terrain could get by without using tri-planar mode, or it could atleast be disabled for terrains at far distances)

Tri-planar mode has typically been the biggest reason that jme's terrains result in low FPS, so this should allow for some big optimizations when using terrains in large scenes.

@yaRnMcDonuts
Copy link
Member Author

yaRnMcDonuts commented Feb 1, 2025

@capdevon
I believe I've addressed most of your review, let me know if I missed anything.

The only thing I didn't do yet is cleanup TerrainUtils.glsllib because I still have plans to add more functions to that file to support PBRTerrain (right now it only works for reading texture arrays for advancedPBRTerrain).

Once everything is approved and finalized for the approach I took to modularize AdvancedPBRTerrain, then I'll adapt things the same way for PBRTerrain. Then after that I'll do a final code cleanup to PBRTerrainUtils once its mostly done changing.

@yaRnMcDonuts yaRnMcDonuts merged commit 7e2f336 into master Feb 3, 2025
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants