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

VertexData Z #83

Open
hypersurge opened this issue Dec 2, 2020 · 9 comments
Open

VertexData Z #83

hypersurge opened this issue Dec 2, 2020 · 9 comments

Comments

@hypersurge
Copy link

I am attempting to create a 3D Quad where each of its corner points have directly controllable x,y,z. For example:

new Quad3d( Texture, Point, Point, Point, Point );

Within Sprite3d I see calculateVertices() which calculates each vertexData2d x,y,z based on world matrix, orig height & width, anchor. That is to say the underlying vertices are arranged rectangularly (without independent axis offsets or control). I am therefore uncertain if what I have in mind is viable.

@ivanpopelyshev What quick advice can you give please? Thank you.

Currently I have the equivalent working via workarounds ... calculating each corner position independently then drawing the resulting shape in "2D" space. This can be a bit slow, and doesn't benefit from the pixi-projection culling and frustrum routines.

@ivanpopelyshev
Copy link
Collaborator

four points might not even lie on the same plane, how do you want to form quad out of them?

@ivanpopelyshev
Copy link
Collaborator

Are you familiar with mesh-shader approach in pixi? Its almost the same as in threejs.

https://pixijs.io/examples/#/mesh-and-shaders/triangle-color.js

Make your own geometry, shader and stuff.

@hypersurge
Copy link
Author

Thanks. I am in manual control of the quad points, so don't need to worry (too much) about bends :)

Yes, I have already pursued the "roll-your-own" approach (extending mesh.Plane with vertices positioned based on projection matrices). It works fine, just no inbuilt frustrum and some perspective tearing. I can refine it further but wanted to first check I was not missing anything existing within this library.

@ivanpopelyshev
Copy link
Collaborator

ivanpopelyshev commented Dec 3, 2020

extending mesh.Plane with vertices positioned based on projection matrices

plane doesnt have 3d points. no pixi mesh has 3d points.

@hypersurge
Copy link
Author

extending mesh.Plane with vertices positioned based on projection matrices

plane doesnt have 3d points. no pixi mesh has 3d points.

For sure, the "3D" is being done outside of that class (with the resulting screen 2D being applied to the geometry vertices).

@ivanpopelyshev
Copy link
Collaborator

For sure, the "3D" is being done outside of that class (with the resulting screen 2D being applied to the geometry vertices).

and how do you think it will be able to transform texture UV's accordingly? Yes, by 4 points of quad its possible to reconstruct Z-coord that way texture is applied to a quad. That's what Sprite2d in this lib does.

You have to supply (x,y,z) points to your mesh anyway, whether its your calculated Z or something that was reconstructed

@ivanpopelyshev
Copy link
Collaborator

ivanpopelyshev commented Dec 3, 2020

Oh, now i get it. you want to supply all X,y,z to vertexData2D :) Yeah, just override calculateVertices that way it doesnt re-write your changes and it'll be fine. The only thing is ..how will you apply sprite transform ot it? maybe you figure it out too. Basically, third coord there is not Z, its W. projective coord.

@hypersurge
Copy link
Author

Exactly - that's what I'm looking at right now, overriding calculateVertices(). Thank you for the clarification I'm looking in the right place (and W vs Z) ... that's half the battle!

@ivanpopelyshev
Copy link
Collaborator

Yeah, all that stuff blew up my brain when i did it, i re-invented most of it )

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