Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Multiple user generated textures on single material / mesh

Discussion in 'General Graphics' started by maximviss, May 21, 2023.

  1. maximviss

    maximviss

    Joined:
    Apr 17, 2023
    Posts:
    1
    I’m fairly new to Unity. ( I hope it’s not a total dumb problem that is easily solved by reading up on the right guide that I should have read first) Iam stuck on the following problem / function:

    The player should be able to upload multiple Images to a single mesh and move them around on the mesh. I created an uploader for the image part.

    Here comes the problem: I'am stuck on the part were I need to organize multiple materials/textures on one mesh. At the moment iam able to upload one image to the mesh. I can’t control the placement and the size. Basically the uploaded image spans the entire mesh wide. My understanding atm: I need to build a box on the UV-Map that gets filled by the user upload or build a procedural shader.

    Can you guys point me in a direction?
    Do I solve my problem with the implementation of a shader or do I create multiple materials with alpha Chanels on each uploaded image? Or is it a UV-Mapping solution I’am looking for? How do I scale the uploaded image so that the size on the mesh is consistent no matter what the user imports?

    Thank you in advance!
     
  2. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,891
    Hi!

    There's myriads of ways to go about this.

    Meshes can be divided into sub-meshes. Each sub mesh can have its own material, and each material can have multiple textures and use up to 8 UV channels from the mesh. Additionally, you can render the mesh as many times as you wish using a different material each time (these are called passes). These are the tools you're working with, which are pretty much common to all engines.

    If the textures do not overlap but are restricted to a specific area of the mesh each, you could use submeshes with a different material/texture each.

    If textures may overlap, you could use a separate UV channel for each one and pack up to 8 textures per pass, using the same material/shader. Then you'd do another pass (using alpha blending) for every new set of 8 textures you need to add.

    By modifying the UVs in the shader. Most built-in shaders have tile/offset properties that allow you to scale and translate a specific UV channel.