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

Fix Ocean Depth Cache baked texture size limit #1016

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions crest/Assets/Crest/Crest/Scripts/LodData/OceanDepthCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,8 @@ public override void OnInspectorGUI()
ti.wrapMode = TextureWrapMode.Clamp;
// Values are slightly different with NPOT Scale applied.
ti.npotScale = TextureImporterNPOTScale.None;
// Round up so it encompasses desired resolution.
ti.maxTextureSize = Mathf.RoundToInt(Mathf.Pow(2f, Mathf.Ceil(Mathf.Log(dc._resolution, 2f))));
Copy link
Contributor

Choose a reason for hiding this comment

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

may be worth using max(dc._resolution, 1) . i'm not sure if it could ever be 0 in any situation but log() will go haywire if it is

ti.SaveAndReimport();

Debug.Log("Crest: Cache saved to " + path, AssetDatabase.LoadAssetAtPath<UnityEngine.Object>(path));
Expand Down
1 change: 1 addition & 0 deletions docs/about/history.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Fixed
- Fix several *Texture2D* and *RenderTexture* memory and reference leaks.
- Fix excessively long build times when no *Underwater Renderer* is present in scene.
- Fix *Underwater Renderer* not working with varying water level.
- Fix *Ocean Depth Cache* baked texture size being restricted by texture import settings.

.. only:: birp

Expand Down