Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

quick question

edited February 2014 in Questions Posts: 49

I just started the process of completely rewriting a game that I was working on (sloppy coding leads to lag) and I was planning on running a shader. Just as a quick question, would it be beneficial to create the entire scene in one mesh (player and all) and then run the shader on the entire entity? I'm not worried about the math (trust me, I can handle it) I just wanted to know if there is a performance hit when running a shader multiple times on different meshes (meshi?). I'm already planning on adding the entire terrain to one mesh, I just want the most room for performance to work with.



  • Posts: 2,161

    The shader is attached to the mesh, so if you use the same shader on several meshes then it will actually be several copies in the GPU - one for each mesh. So it is more expensive to run several meshes with the same shader. However, it might not be that much more expensive, so if it makes the code really complicated then it might not be worth the hassle.

  • Ok. I think I'll just attach all the immovable terrain to a single mesh (shouldn't be too hard) and just keep everything that moves in their own meshes. I just wanted as much wiggle room (technical term) as I can get programming on a second gen iPad, but I agree, it wouldn't be worth the hassle

  • IgnatzIgnatz Mod
    Posts: 5,396

    @1980geeksquad - if you are texturing a lot of terrain, then you may want to use a tiling shader which can greatly reduce the number of vertices required, especially if your terrain is flat. My ebook on shaders (in the wiki) shows how to do this (it's just one line of shader code, but a beautiful trick - not mine!). This may be one reason to have different shaders for different meshes.

    I have also written quite a lot about working with terrain, in various places, if you need help. I don't claim to be an expert, but I have fallen over enough obstacles to have learned a little.

Sign In or Register to comment.