Comments (15)
Hey,
that is as intended. At line 505, it will only be created when the previous created texture has other sampler settings (like filterMode or WarpMode).
When they have both the same sampler settings, it's likely a bug.
from unitygltf.
Can we just change sampler settings of first one and assign it to the second one? As the first one (I suppose) has no use here after...
from unitygltf.
So the first created Texture is not in use? Maybe you can share the file here?
from unitygltf.
It is the same case for any GLB it'll load the texture twice.... First one has only 1 reference which is (I guess) ImageCache list... and the second one is assigned to materials and has a proper use
from unitygltf.
i will check! that's very likely a bug :)
from unitygltf.
It is a very old bug since first build which I once resolved as well but wasn't able to share at that time unfortunately.
Basically, the problem is that when you load any GLB from code using GLTFComponent in a build and then if you use memory profiler by Unity then it'll show that every texture is loaded 2 times. First texture has only 1 reference and the second has proper use of it. Also if you use CPU profiler then you can see big spikes when a texture is loaded because it once load a texture through LoadImage() and then Object.Instantiate() on same frame. Above mentioned places are the exact points which I found after profiling.
Hope these information help.
from unitygltf.
Still needs some tests, but should prevent this behaviour now: 73f7b66
from unitygltf.
Hi @pfcDorn... Thankyou for sharing the implementation
I managed to brought back my implementation of the issue.
I would prefer older implementation because of many reasons
- If isFirstInstance is null then there might be issues to call Object.Instantiate(null) in that case
- isFirstInstance can't be null because of if (!source) return; at line 427
- No if-else needed for Object.Instantiate so it is a simpler version of it
- I've tested this on few test cases and was working fine on previous version
from unitygltf.
With your solution you just removed completly the support for multiple sampler settings on a single texture. In Unity we need to duplicate a texture when we have in the gltf different sampler settings for the same texture.
Lets say we use Texture A in Material 1 and in Material 2. In Material 1 the texture will have WrapMode Repeat, and in Material 2 it will set to Clamp. So in this case we must dublicate the texture on import to support this. Otherwise one material will not be displayed correctly.
from unitygltf.
Yes but this statement is true for both of the above solutions I suppose.
The issue was that if you've 1 texture and 1 material it was still loading the texture twice.
from unitygltf.
thats the reason why i added the isFirstInstance, so it only create the texture twice or more when it's needed (in case of multiple sampler states)
from unitygltf.
But I think isFirstInstance might always be true because of the lines on 429 and 430 ???
var source = _assetCache.ImageCache[sourceId];
if (!source) return;
Which means matchSamplerState on line 491 will always be false
from unitygltf.
@pfcDorn did you manage to find a work around?
from unitygltf.
line 430 is only false (null) when the texture can't be created in line 427. So don't worry. Don't get confused with ImageCache and TextureCache here ;)
from unitygltf.
Oops! I was missing a point there... Thankyou
from unitygltf.
Related Issues (20)
- 'Texture2D' does not contain a definition for 'isDataSRGB' HOT 10
- Encounter object export errors when using package HOT 5
- Timeline for implementing KHR_interactivity? HOT 1
- Creating animation on runtime, from scratch HOT 10
- ShaderGraph dependency problem for OpenUPM install HOT 5
- how to get progress (while loading) runtime.? HOT 2
- Incorrect material texture offset value on KTX2-based compressed GLB import HOT 2
- KtxTexture AssertionException HOT 5
- Shaders don't mark any exposed properties as "Main Color" HOT 2
- Default range for imported punctual lights is too high. HOT 2
- KHR_materials_anisotropy support HOT 1
- Freeze frame during runtime loading in Android HOT 6
- Fix Suggenstion for HDRP
- Only 4 bone weights per vertex exported/imported when Unity supports up to 256 HOT 2
- Mesh with tangents has validation errors and breaking compression HOT 7
- How to load glb as byte[] or MemoryStream
- i build and run my unity project and i found only pink object. if someone know please help me. HOT 7
- Issues building for runtime loading HOT 2
- File Names are wrong HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from unitygltf.