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 interacting with voxels #65

Open
christopherdebeer opened this issue Mar 23, 2013 · 5 comments
Open

Sprites interacting with voxels #65

christopherdebeer opened this issue Mar 23, 2013 · 5 comments

Comments

@christopherdebeer
Copy link

As a bit of background, or context.
What I'm hoping to achieve is a world/level where the physics is handled by voxel-engine but the visuals are actually just 2d painted sprites layered over transparent voxels/meashes.

The issue im comming up against seems similar to the issue mentioned in: Issue #34 but in my case the voxels behind the transparent voxel Are visible as well as the player meshes when walking behind the transparent voxel, BUT sprites rendered at the same position as the transparent voxel are being covered by the voxel.

example: http://christopherdebeer.com/sandbox/voxeljs/

Any ideas?

@shama or @vogonistic, @mbalho mentioned that you might have some insights, if you do, it would be much appreciated.

@shama
Copy link
Contributor

shama commented Mar 23, 2013

First off, that looks like it's going to be rad. :D

Think about the voxel mesh this way. Every voxel in a mesh does not have 6 sides. If a voxel mesh had 6 sides, it would be a single voxel floating on its own. If you put 2 voxels meshed next to each other, it will have 10 sides. The 2 touching sides between the voxels are ignored and don't have faces. Since there isn't a face, a texture isn't rendered. Thus you're looking inside of the mesh. A good way to visualize is to turn on wireframe mode.

@vogonistic has made the most progress on a solution: https://github.com/vogonistic/mineflayer-voxel/blob/master/transgreedy.js I'm planning giving it another go soon as well using his work.

The only tmp solutions I can think of now is don't use transparent textures or make everything cube geometry (I know these are really bad suggestions).

@christopherdebeer
Copy link
Author

Thanks @shama

You mentioned/suggested using cube geometries, but on the left of the example I used a cube geometry with a LineBasicMaterial({transparent: true, opacity: 0.3}) while I understand this isn't an issue with voxeljs do you have any idea why the sprite still isn't visible through the cube even though it's supposed to be transparent?

Thanks for your help all the same.

@shama
Copy link
Contributor

shama commented Mar 23, 2013

I think there you just need to set the material to be double sided with: {side: THREE.DoubleSide}.

@snagy
Copy link

snagy commented Mar 24, 2013

You need to check your draw order and depth state for everything; make sure all the transparent objects render last, and render back-to-front if you want them to layer properly.

@max-mapper
Copy link
Owner

any progress on this? I think @snagy's suggestion to render transparent objects last is a pretty common way of doing it, anyone know how hard that would be in three.js?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants