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

Is there any way to cover like this? #86

Open
tringcooler opened this issue Mar 19, 2021 · 2 comments
Open

Is there any way to cover like this? #86

tringcooler opened this issue Mar 19, 2021 · 2 comments

Comments

@tringcooler
Copy link

tringcooler commented Mar 19, 2021

There are 3 sprite3d with different Z value. The middle one (sp2) is slanted.

 camera

sp1   \ sp2
------ \    sp3
        \ ------
         \

I want to see that sp2 covered sp1, and sp3 covered sp2.
But, because the Z value of sprites is order as sp3 > sp2 > sp1. I always see that sp1 covered sp2, and sp2 covered sp3.

Is there any way to fix the overlay order?

=====
I want to see it like this:
pxpjissue1
But it's like this:
pxpjissue2

@ivanpopelyshev
Copy link
Collaborator

ivanpopelyshev commented Mar 20, 2021

There's a way but it requires algorithm that i .. just dont have in this repo. Google "scanline", if you are not afraid :)

Its shame that i lost my implementation and didnt put it here :(

@tringcooler
Copy link
Author

There's a way but it requires algorithm that i .. just dont have in this repo. Google "scanline", if you are not afraid :)

Its shame that i lost my implementation and didnt put it here :(

I found that can enable the webgl auto hidden surface removal alghritm by set AbstractBatchRenderer#state.depthTest to true, and set AbstractBatchRenderer#state.blend to false.
And then, write z value in vert prog like "gl_Position.z = - 1. / gl_Position.w + 2.;".
The cover ordering is working right now.
(All these mod in Sprite2dRenderer.ts)

But, when enable the webgl depth test, all the alpha channels are going to be a mess.

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

2 participants