Search Unity

Copy texture to a material and then copy that material's texture to a render texture?

Discussion in 'Scripting' started by saifshk17, Feb 19, 2020.

  1. saifshk17

    saifshk17

    Joined:
    Dec 4, 2016
    Posts:
    488
    Is there a way to copy a texture to a material and then copy that material's texture to a render texture?

    I have come across copying a normal texture to a render texture using Graphics.Blit(texture2D, renderTexture);. But is there a way to copy a skybox texture (360) to a render texture cube? The particular skybox texture fills all the 6 sides with the texture2D. Is there a way to copy all 6 sides to a render texture as well?
     
    Last edited: Feb 19, 2020
  2. csofranz

    csofranz

    Joined:
    Apr 29, 2017
    Posts:
    1,556
    Use Blit() to apply a texture to a render texture. Using a Material is optional.
     
  3. saifshk17

    saifshk17

    Joined:
    Dec 4, 2016
    Posts:
    488
    No you don't understand. I want to copy the material's texture to a render texture. Let me explain in detail:

    I have come across copying a normal texture to a render texture using Graphics.Blit(texture2D, renderTexture);. But is there a way to copy a skybox texture (360) to a render texture cube? The particular skybox texture fills all the 6 sides with the texture2D. Is there a way to copy all 6 sides to a render texture as well?
     
  4. csofranz

    csofranz

    Joined:
    Apr 29, 2017
    Posts:
    1,556
    I understood completely. You misstated your question [EDIT: The original question was edited by OP after my response]. Where in

    "Is there a way to copy a texture to a material and then copy that material's texture to a render texture?"

    did you mention skyboxes? Please be more considerate when writing questions and assigning blame for your own shortcomings.
     
    Last edited: Feb 19, 2020
  5. saifshk17

    saifshk17

    Joined:
    Dec 4, 2016
    Posts:
    488
    okay but is there a way to do this?
     
  6. csofranz

    csofranz

    Joined:
    Apr 29, 2017
    Posts:
    1,556
    I'm not sure that I completely understand your question. A skybox usually has the form of an 'unrolled cube', it's in the form of a cross made from 6 squares, with the six squares representing all six directions. Another way is to stitch together the skybox using six separate images. The question here is: what Format should the resulting texture (i.e. the one you are looking for) look like? If you want the cross, you should be able to use the skybox texture directly. If you have six separate Images, use any of the many free programs available on the net to stitch them together to form the cross. If you are not looking for a cross-shaped texture, what are you looking for?

    Can you perhaps try to explain in your own words what you are trying to achieve, i.e. what you have, and where you want to arrive at and why?
     
  7. saifshk17

    saifshk17

    Joined:
    Dec 4, 2016
    Posts:
    488
    Okay so basically when I copy a texture 2D to a render texture cube, it only fills quarter of the render texture cube. I want the render texture to be filled completely of this texture 2D. In order to do that I must convert the texture2D to a cube and then copy it to a render texture. How do I do that? I have no clue.
     
  8. csofranz

    csofranz

    Joined:
    Apr 29, 2017
    Posts:
    1,556
    What is a render texture cube? Are you talking about a cubemap?
     
  9. saifshk17

    saifshk17

    Joined:
    Dec 4, 2016
    Posts:
    488
    Yes sorry a cubemap.
     
  10. csofranz

    csofranz

    Joined:
    Apr 29, 2017
    Posts:
    1,556
    Maybe look here.