Jump to content

GUI mapped to Box Faces


royibernthal
 Share

Recommended Posts

On 12/12/2017 at 1:56 AM, royibernthal said:

What I theoretically need -

adt submat - 1 face and other 5 faces are blank

box skin submat - 5-6 faces

part of a multimat that's applied to a box.

 

The "issue" is the faceUV is set for the box and can't be set per submat (as far as I know), making what I need to do impossible? at least in a straightforward way.

Can you please elaborate on how you think this can be solved?

and the PG you asked for:

On 12/12/2017 at 11:57 PM, royibernthal said:

I can't say I'm really anywhere as I'm not sure what needs to be done, but here's the general direction:

https://www.babylonjs-playground.com/#ICZEXW#27

 

Link to comment
Share on other sites

I see. Any idea why I'm getting an error here?

https://www.babylonjs-playground.com/#ICZEXW#34

 

Quote

babylon.js:26 Uncaught TypeError: Cannot read property 'subtractToRef' of undefined
    at t.intersectsTriangle (babylon.js:26)
    at i.intersects (babylon.js:15)
    at r.i.intersects (babylon.js:9)
    at i._internalPick (babylon.js:12)
    at i.pick (babylon.js:12)
    at HTMLCanvasElement._onPointerMove (babylon.js:11)

 

Link to comment
Share on other sites

https://www.babylonjs-playground.com/#ICZEXW#36

I was using apparently values that are good for a sphere but not for a box.

How do I know which values make sense for indexStart and indexCount? What's the logic behind it?

I suppose I somehow need to figure this out based on total vertices? In the multimat tutorial for instance the values go between 0 and 2088 while a sphere has 703 total vertices, so I'm not sure how to deduce one from the other, if that's at all the direction.

 

EDIT:

We replied at the same time, checking what you just said.

Link to comment
Share on other sites

I forgot to assign the textures last time for some reason

 

Assuming I have a different texture from a different source for each face, I end up with 6 draw calls per box, correct me if I'm wrong.

https://www.babylonjs-playground.com/#ICZEXW#47

 

I'd like to have 1 texture atlas that contains 5 faces, and map it to the actual box faces - as 1 sub texture.

The other sub texture has the adt, pretty much the way it is now.

The end goal should be 2 draw calls per box.

1) Am I supposed to combine multimaterial with faceUV? If so, how do I do it without messing it all up? :)

https://www.babylonjs-playground.com/#ICZEXW#48

 

2) Do 2 separate BABYLON.Texture instances that use the same source require 1 draw call or 2?

3) If I have 10 boxes that re-use the same 6 textures (1 for each face). Do I end up with 60 draw calls or does bjs optimize the order and ends up with 6 draw calls?

4) Same as above, only each box re-uses 5 textures - but has its own adt. Do I end up with 15 draw calls or 60?

Link to comment
Share on other sites

With multimaterial: 6 draw calls is correct!

You can achieve with only one draw call by playing with:

- 1 texture atlas on uv0

- 1 adt on uv1

You will have to create the first set of UV to point to right place on the atlas

Same for uv1, it will point to 0,0 for all faces but one in order to display the adt on the face you want

 

regarding your questions:

1. If you want to get less draw calls, you have to not use multimaterial

2. Nope, textures are not related to draw calls. Only materials

3. We can get only one draw call per box: so 10 boxes => 10 draw calls

4. See before

 

 

Link to comment
Share on other sites

Got it, so I'll pass on multimaterial :)

 

13 minutes ago, Deltakosh said:

You can achieve with only one draw call by playing with:

- 1 texture atlas on uv0

- 1 adt on uv1

You will have to create the first set of UV to point to right place on the atlas

Same for uv1, it will point to 0,0 for all faces but one in order to display the adt on the face you want

 

- 1 texture atlas on uv0

- 1 adt on uv1

 

Are these 2 different approaches or do you mean I should combine the 2? If combine, how can I combine texture atlas and adt without multimaterial?

I'm not entirely sure I understood your explanation

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...