Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

UNITY_SAMPLE_TEX2DARRAY and a procedurally generated mesh

Discussion in 'Shaders' started by yehiaserag, Jun 2, 2019.

  1. yehiaserag

    yehiaserag

    Joined:
    Mar 8, 2018
    Posts:
    6
    It's a 2D game I'm generating a mesh at runtime which has z = 0, and only x,y values

    I used to use a default shader with a texture that worked great, but then I needed multiple textures, and atlases didn't help since they had a lot of problems, I decided to go the texture array route, now my mesh isn't appearing neither in scene nor in game views
    I'm using the default shader provided in documentation while changing the the uv to be read from the mesh uv and sending the uv.z to be 0 or 1 since my texture array has only 2 textures, am I doing something wrong or missing something?
    Thanks
     
  2. Invertex

    Invertex

    Joined:
    Nov 7, 2013
    Posts:
    1,495
    1. Post your shader code.

    2. You don't really need to mess with texture arrays if you only need 2 textures, just make another texture input, having an array for just 2 textures is just going to complicate things.
     
    yehiaserag likes this.
  3. yehiaserag

    yehiaserag

    Joined:
    Mar 8, 2018
    Posts:
    6
    Thanks a lot for the help, I'll post my solution here for anyone who gets the same issue:
    It turned out to be totally not related to the shader but in fact my camera is at z = -1 my mesh is at z = 0 and since it is 2d it has no depth so i couldnt notice that i was looking at the back of the mesh which was being culled, inverting the verts direction solved my problem, not sure why it was showing before, maybe my old shader had culling disable, not sure if this is even a thing
    Good luck to anyone reading this