-
-
Notifications
You must be signed in to change notification settings - Fork 35.6k
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
Sprite issues #7956
Comments
Also, I am aware that the issue title is bad, please change it to something more adequate, I could not think of a sufficiently descriptive name myself |
Couple more to add:
|
What about the sprite sheet example in http://threejs.org/examples/misc_ubiquity_test2.html? In any event, there is room for improvement. In fact, in the above example, type |
I was looking at your lovely prototype with translate, scale, rotation and centre properties for Materials ( on this feature: #5876 ) when I was implementing sprite sheets. However nice that material update would be, repeat and offset to worked nicely with translation / scaling of texture. |
One has to have a different THREE.Texture for each sprite as long as one wants them to be individually animated. Though, as I understand that example uses .clone() to make the texture copies, which is not a deep copy thus resulting in no texture repetition in the video RAM, so it is not an issue. Is webglRenderer.info counting each THREE.Texture existent, or somehow accounts for the clones? I agree that .repeat and .offset should be moved to THREE.Material. Also I was not aware that .repeat was for scaling, the name is a little inadequate IMHO. |
Could be wrong - but I think you can hack it not to re-upload the cloned to the GPU texture by setting the cloned uuid to the same as the source texture, i.e.: clonedTexture.uuid = sourceTexture.uuid; |
Confirmed. In the sprite sheet example, using the hack var tex = texture1.clone();
tex.uuid = texture1.uuid; prevents the texture from being uploaded to the GPU repeatedly. |
If so, couldn't/shouldn't THREE.Texture.clone be patched to include setting the uuid perhaps? Or is there something I am missing |
Note the GPU texture hack:
caused a huge performance drop in my render time ( sub 1ms to 35 ms + ). |
Are you sure this uuid hack affects texture being uploaded to the GPU instead of just affecting webglRenderer.info counting of textures? |
I am going with whatever WestLangley says on this one :-) - however the huge performance drops are caused by Image Decode events in chrome: http://imgur.com/dcUliZc These go away when I disable 'tex.uuid = texture1.uuid;' |
I have just submitted a PR that allows for per-map/per-material UV offset/repeat that should address this issue: #8278 |
I have a solution to make spriteMaterial objects to rotate with scene. |
BTW: The mentioned hack in #7956 (comment) does not work anymore since |
The current THREE.Sprite implementation has a number of issues.
The last one is actually quite interesting.
See https://github.com/mrdoob/three.js/blob/master/src/objects/Sprite.js#L12
and https://github.com/mrdoob/three.js/blob/master/src/renderers/webgl/plugins/SpritePlugin.js#L24
I even tested this by commenting out the BufferGeometry creation in THREE.Sprite, and sprites continued working.
Meanwhile I imagine the workaround is to use a Mesh with a PlaneGeometry and a .lookAt(camera.position) in every loop in place of Sprites if one needs the features mentioned above.
Fixing this issue I imagine is not terribly difficult.
Here is my suggested plan:
The text was updated successfully, but these errors were encountered: