Skip to content

Commit

Permalink
Merge pull request #1193 from anatawa12/fix-white-texture
Browse files Browse the repository at this point in the history
fix: using Texture2D.whiteTexture would break Unity
  • Loading branch information
anatawa12 authored Sep 21, 2024
2 parents 4208f7a + 73eb9ef commit 726922b
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG-PRERELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ The format is based on [Keep a Changelog].
### Removed

### Fixed
- Texture Packing which resolves to the white texture would break the Unity Editor `#1193`

### Security

Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ The format is based on [Keep a Changelog].
- We may relax some restriction in the future.
- Because we have to check for each condition if we use AnyState but we can check for only one (in best case) with entry/exit, this generally reduces cost for checking an parameter in a state.
- Combined with Entry / Exit to 1D BlendTree optimization, which is implemented in previous release, your AnyState layer may be optimized to 1D BlendTree.
- Optimize Texture in Trace nad Optimize `#1181` `#1184`
- Optimize Texture in Trace nad Optimize `#1181` `#1184` `#1193`
- Avatar Optimizer will pack texture and tries to reduce the VRAM usage.
- Currently liltoon is only supported.
- `Copy Enablement Animation` to Merge Skinned Mesh `#1173`
Expand Down
8 changes: 1 addition & 7 deletions Editor/Processors/TraceAndOptimize/OptimizeTexture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -835,13 +835,7 @@ private AtlasResult BuildAtlasResult(AtlasIsland[] atlasIslands, Vector2 atlasSi
// if color is consist of 0 or 1, isSrgb not matters so assume it's linear
var isSrgb = texture2D.isDataSRGB && color is not { r: 0 or 1, g: 0 or 1, b: 0 or 1 };

if (color is { r: 0, g: 0, b: 0, a: 0 })
newTexture = Texture2D.blackTexture;
else if (color is { r: 1, g: 1, b: 1, a: 1 })
newTexture = Texture2D.whiteTexture;
else if (color is { r: 1, g: 0, b: 0, a: 0 })
newTexture = Texture2D.redTexture;
else if (ColorTextures.TryGetValue((color, isSrgb), out var cachedTexture))
if (ColorTextures.TryGetValue((color, isSrgb), out var cachedTexture))
newTexture = cachedTexture;
else
{
Expand Down

0 comments on commit 726922b

Please sign in to comment.