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

Sprites: Combined rendering with opaque and transparent objects #6396

Closed
rmarques-realstatus opened this issue Apr 14, 2015 · 5 comments
Closed

Comments

@rmarques-realstatus
Copy link

I've created a scene where there's an outer box that's being rendered from the inside (THREE.BackSide). Inside the main box I've placed two smaller boxes (also being rendered from the inside), some particles, and a text Sprite. All the boxes have transparency enabled.

All seems to work well enough, except the sprite not being visible through the inner boxes, and only through the outer one. Here's an example (with OrbitControls enabled): http://jsfiddle.net/rgE2j/104/

After some digging I found this: http://stackoverflow.com/questions/19046972/three-js-cannot-view-a-sprite-through-a-mesh-with-transparency

Which had me change my example to: http://jsfiddle.net/rgE2j/106/

The latter example works. However, my question is: Is this behavior to be fixed in the future, or is the workaround the way to go?

Many thanks!

@mrdoob
Copy link
Owner

mrdoob commented Apr 15, 2015

Yes. The problem is that, right now, WebGLRenderer renders Sprites in a "second pass". We should fix this...

@rmarques-realstatus
Copy link
Author

So I'll stick with the workaround for now. Thanks @mrdoob!

@T045T
Copy link

T045T commented Dec 16, 2017

Just to make sure: This behavior hasn't changed in the interim, correct?

We ran into the same problem at RobotWebTools/ros3djs#192.

@mrdoob, do you have any idea what a proper solution might look like? I'm not really a serious graphics or JS programmer, but with a pointer in the right direction, I think I could take a shot at this.

From some cursory reading, it seems like the depth buffer doesn't contribute much to the correct rendering of (correctly sorted) transparent objects.

So if transparent objects by default didn't write into the depth buffer (or maybe the depth buffer got restored to the state it was in after rendering all the opaques after the transparents are done), that shouldn't break much, right?

Then the sprite "pass" would just render over any transparent objects, but not solid ones. Looks like that's what OGRE does, too – at least the way it's used in RViz (see the second screenshot in RobotWebTools/ros3djs#192 ).

Feels a little closer to "right" to me than what's happening now. Then, to get 100% correct results, I guess you'd have to sort sprites and objects together and switch renderers potentially every other object, which looks like a lot of work and possibly wasted performance...

@mrdoob
Copy link
Owner

mrdoob commented Feb 6, 2018

Just to make sure: This behavior hasn't changed in the interim, correct?

It has not.

@mrdoob, do you have any idea what a proper solution might look like?

You could create 3d planes and make them point the camera.

var geometry = new THREE.PlaneBufferGeometry();

var texture1 = new THREE.Texture( image );
var material1 = new THREE.MeshBasicMaterial( { map: texture } );
var label1 = new THREE.Mesh( geometry, material );
label1.scale.x = image.width;
label1.scale.y = image.height;
label1.lookAt( camera.position );
scene.add( label1 );

@Mugen87
Copy link
Collaborator

Mugen87 commented Jul 10, 2018

I guess this issue can be solved now with the following suggestion: #14411 (comment)

@Mugen87 Mugen87 changed the title Sprite transparency Sprites: Combined rendering with opaque and transparent objects Jul 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants