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. Dismiss Notice

Patch smaller textures2d onto a larger texture2d with a shader

Discussion in 'Shaders' started by Quatum1000, Feb 16, 2015.

  1. Quatum1000

    Quatum1000

    Joined:
    Oct 5, 2014
    Posts:
    888
    Hi everyone,

    I want to generate different rendertextures on the fly by a shader. Means I want to patch some smaller sized textures into a larger rendertexture on different positions. The public rendertexture result should be used in some different materials.

    (I do not want to use any cs script that build it pix by pix, or any camera quad solution)




    My idea was to use a script that pass the required values to a shader and execute with graphic.blit.
    But how to setup a shader for this because of the different texture sizes.
    Any ideas how to set up a shader for this?

    Thank you and kind regards,
    Quatum

    "I also thought about to clamp a texture and patch it by tile and uv offset, but that cause some ugly last line repeatings on the result texture."
     
  2. Alexey

    Alexey

    Unity Technologies

    Joined:
    May 10, 2010
    Posts:
    1,600
    >>My idea was to use a script that pass the required values to a shader and execute with graphic.blit.
    judging from your screenshot you should be better
    1. set RT
    2. draw quads in screen space (or do ortho camera or just use immediate mode rendering)
    3. profit? 8)
     
  3. Quatum1000

    Quatum1000

    Joined:
    Oct 5, 2014
    Posts:
    888
    Thanks, but as I wrote no cam quads plz! :-]
    Under different conditions its required to blend normals and other stuff of single small textures into the main texture. So I ran into the same problems as before. The best would be a shader solution.
     
  4. Alexey

    Alexey

    Unity Technologies

    Joined:
    May 10, 2010
    Posts:
    1,600
    >>Thanks, but as I wrote no cam quads plz! :-]
    well
    >>or do ortho camera or just use immediate mode rendering
    pick another or?
     
  5. Quatum1000

    Quatum1000

    Joined:
    Oct 5, 2014
    Posts:
    888
    "immediate mode rendering"
    Hmm.. Is this GL.(QUADS) and Graphics.Blit (source, dest, mat); stuff by script?