Jump to content

Minimizing Draw calls suggestions


rn216ccc

Recommended Posts

Hi. My name is Bob. I am new to the Torque3d community. Prior to joining this community, I tried using the GarageGames forums to ask about Multi-UV tiles. I had mentioned that I was new to Torque3d, and before I had started anything, I wanted to know if Multi-UV tiles with texture blending where supported In Torque3D. After posting, one member had mentioned first I should be asking these types of questions over in this board. Secondly, it would be better to use a texture atlas on these type of objects that require large texture space. I thought that this was good news up until I tried doing the FPS demo tutorial. After opening the scene, I have noticed that most of the buildings had multiple materials applied to them instead of using either of the 2 methods above. Firstly, this confused me as I have learned in the past, that using multiple materials causes more draw calls. Isn't this correct?

In addition, I have another confusion with the most current 3D model I am working on. This object is an ambulance, which uses Multi-UV tiles, and now that I saw the demo scene using multiple materials, and was also told to use a texture atlas, I am wondering what would be the best method for current project. To help expedite this, down below is a screen shot of my UV tiles off from my current project.


-AyUjgKtgzWcwzQFJb5aXDNwYHkMux9KVdzgwpWIufIaaC0gXLXpEi7HzOwHPhRrFIlV-zD7GOWDgc4VDCT6aUbKCq3ffgRxJLN0h1UQVBlj7_es2rlKKquAn2l1IxbAkgF5BRZX7MElWv2-DQRJ7H-vNaiUjifxxb7SB_BtyFakUBTakCs-LNptIakPcfJtOZ6zN04HCmqwclSF8PRkRZI56mSt2E_zM9hQ4lN_WnXjOCMMGf-cp8aBO7DpLuujmyXTTfLbx7LmPsWxxWowZDSB21FhCnsfkUgsMiZmMSTXEaxylA9iPLGkI7ne4Q_QBa4LaQpA8Lfs01W95uz7_w9L93DESb7cKHbdWmOlRCWoUoh7liE32QAjgdG5bldgipnJ19Yy3k4gHTwMPsNytDRmBxvZbK1PBJWLDhgxpLkjD8CtUsn-FVPtNEuwANZhHWPCQhvpWq2H0IYBOPIh694LQeqC0ljLjFdK-vS0xzfm4MkvRZvdlLBl2wE044A-kckPBWw6MvVGzRB5mk8EJC4aWuV5JLGOzZwbtwqgCavOh7LVdhZ2FL-mmjoak5n7STko=w504-h212-no

Link to comment
Share on other sites

I thought that this was good news up until I tried doing the FPS demo tutorial. After opening the scene, I have noticed that most of the buildings had multiple materials applied to them instead of using either of the 2 methods above.

 

Old samples are Old, and haven't really had anyone with time to do up a best-practices pass on em to date.

 

Firstly, this confused me as I have learned in the past, that using multiple materials causes more draw calls. Isn't this correct?

 

You are indeed indeed correct. To be a bit more explicit there, each material on a given object effectively forces that to be rendered as an additional mesh, which can break batching, so the more you can fit (within reason) on a given sheet, the better.


From a practical perspective, this may be unavoidable if you wish to use separate techniques on a given subsection of an object, say, emissive glowing headlights behind which you'd attach an actual light source are best done as a separated out mat to name a common cornercase involving vehicles.



Not entirely sure I follow the tile 1-3 bit. Mind further elaborating?

Link to comment
Share on other sites

Not entirely sure I follow the tile 1-3 bit. Mind further elaborating?

 

sure, but bare in mind that this is a difficult task to grasp on the first try, and I do not have access to my 3D model, so I have created a simple sample.


so on with the concept...

One way I know of is by lerping the 3 tiles together. Firstly, there are a few things you need to prepare for the lerping.

Firstly, looking back at the image in my first post, tile 1 is in the 0,0-1,0 space, tile 2 is in the 1,0-2,0 space, and the third tile is in the 2,0-3,0 space,

Next, this method requires 2 UV channels. The first channel will have the 3 UV tiles, and the second channel is a duplicate, but it is scaled to fit all three tiles in the 0-1 space.

The last thing you will need is a 4x4 pixel image. Starting from top-left to top-right, and bottom left...

the first pixel would be colored in fully red (left-top), the second pixel (right-top) would be set to fully green, and the third pixel (left-bottom) would be set to blue.

this 4x4 pixel image will be your RGB mask.

Now, when lerping,....

you will need to somehow separate the R G & B channels of your rgb image mask, and the UV channel is set to channel 2. With the UV texture tiles, they will be set to UV channel 1. Then taking the first lerp, tile_1 is connected to slot a and tile_2 is connected to slot b, and the Green channel of your image mask is connected to the mix factor in the first lerp. Then the result of the first lerp will connect to the second lerp in slot a, and the third tile is connected to slot b, and the Blue channel of the rgb mask image is connected to this second lerp mix factor. If that is not confusing, it sure is a tongue twister. Believe me, this theroy took me 2 days to figure this out. So do not feel bad if you do not get it on the first try.


here is the sample I have promised....

9QSUL9HMKvvYumnX6-DyzC6Qnl6gOWKclCX8stMce-Wrca6eJn6_Ffj_xJMNMHqph8iEVnNhCF-t_pbm47HZZcnBhpDBADHerarmHoxhEYuwITCF4jC4oa8GRyPw-K5ftsh_evsDYnm4Yv8Z5eh3RR_C2ljjJOVu4xRYeMqk2FHTt2r1ugX0FK39XUO_5Zn7kUlB8_icgltotu-VIg8sHNRsqM7epT9ommY_4jbYljc2BNHMNpJ_1MnMNMwXe2ezFogW27SHqxnQ7VKF9sEu1O9_NwAdcP0G8jb9FCnMlF2B5Z6rSg3UwzxMRsSoTMn-t-SOrOuHPOKUyi6uO2sRtQueVYkgqnApz0aZ_PEpOu0yjEARr6Voarubv0VcVDcHFi-A5E5RVRZ-B18Bc-D0ko6BBCQ0mnKpcWiq6nN-gFw_VocyJkvfK94xqTamrBSU8cT0QA34qXbio4tmmXtd-p1LyppSE2H_jAog-po5LX9qa4v88qH2a3f3LhgBhrhpgVvPJ00NmKcZoPbrTm3w5XHpp-zzfukcviMvPYVkCF8tPe8yfAiSFY741xTqjJzzNA7u=s504-no

Link to comment
Share on other sites

Unfortunately, not in Torque3D, as I have never used Torque3D. I am asking these questions in advance, so that I know how to prepare my objects that require large texture space. However, I can point you to a video tutorial using UDK, if that would help. This is where I had learned this technique, when I was using UDK, but I eventually stopped using it because it does not have a road editor and for other reasons as well.



Link to comment
Share on other sites

Looks like one model, one atlas texture, multiple pieces of unwrap. So, basically, just a standard single UV unwrapped texture.


Unless you're packing multiple model data into a single texture? I mean, no reason you can't do that I guess, just UV map different models to different parts of the same image....

Link to comment
Share on other sites

Looks like one model, one atlas texture, multiple pieces of unwrap. So, basically, just a standard single UV unwrapped texture.

 

Sort of. The concept is to have the same number of textures, as you would with your UV tiles. This gives you better control because each textures per-tile can be set at different resolutions. So, in the above example, there are three UV tiles. Therefore I would need three textures. Each of the three textures, I could set my first texture at 512x512, and the last 2 textures could be set to 1024x1024. However, if all of the textures are at the same resolution, say something like 512x512, then your probability would make more sense, since 512x512 x 3 = 1536x1536. So in reality with this scenario, you are not saving on texture memory.

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.

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.

×
×
  • Create New...