GameMonetize Posted December 18, 2017 Share Posted December 18, 2017 it is. I see no reason why you can't Quote Link to comment Share on other sites More sharing options...
royibernthal Posted December 19, 2017 Author Share Posted December 19, 2017 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 Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted December 19, 2017 Share Posted December 19, 2017 You must update your PG to add submeshes in order to point to right material : http://doc.babylonjs.com/how_to/multi_materials Quote Link to comment Share on other sites More sharing options...
royibernthal Posted December 22, 2017 Author Share Posted December 22, 2017 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) Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted December 22, 2017 Share Posted December 22, 2017 because there is no 900 indices in your meshes lines #77, 78. You have to specify indices you want per submesh (a box has 6 indices per face and 6 faces so 36 indices) Quote Link to comment Share on other sites More sharing options...
royibernthal Posted December 22, 2017 Author Share Posted December 22, 2017 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. Quote Link to comment Share on other sites More sharing options...
royibernthal Posted December 22, 2017 Author Share Posted December 22, 2017 Okay I checked this a little https://www.babylonjs-playground.com/#ICZEXW#42 Are the numbers I specified now correct? Any idea why the textures are not rendered? (lighting problem?) Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted December 22, 2017 Share Posted December 22, 2017 Yes https://www.babylonjs-playground.com/#ICZEXW#43 Quote Link to comment Share on other sites More sharing options...
royibernthal Posted December 22, 2017 Author Share Posted December 22, 2017 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? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted December 26, 2017 Share Posted December 26, 2017 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 Quote Link to comment Share on other sites More sharing options...
royibernthal Posted December 26, 2017 Author Share Posted December 26, 2017 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 Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted December 27, 2017 Share Posted December 27, 2017 Here: https://www.babylonjs-playground.com/#6PFPL7 Check line #28: IF you ahve a second UV set, you can uncomment this line royibernthal 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.