Search Unity

Question Add a texture or UV at specific realworld size - HDRP 9.x

Discussion in 'Shader Graph' started by newguy123, Jul 4, 2020.

  1. newguy123

    newguy123

    Joined:
    Aug 22, 2018
    Posts:
    1,248
    Hi Guys

    I'm not sure how to do this with shader graph.

    In 3ds Max, I just apply a box max and tick "real world map" settings. This gives me a tilable UV over my entire object of 1m X 1m tiling. To then apply a texture, in the material I just type the realwordl size I want, for example 2.5m X 4.2m and my texture tiles over my object 2.5m X 4.2m. To then change the size, all I do is keep my UV map as is, but for the texture just make the size different, for example 3m X 7m.

    In the example below, my cube is 10m X 10m and the UV coords is 1m X 1m (realworld) and the 2d texture is 2.5m X 4.2m

    upload_2020-7-4_15-35-20.png


    How do I go about doing this with shader graph? I imported my geometry with the 1m X 1m UV. I cant figure out how to give my texture a realworld size in shader graph. I don't want to adjust the UV box mapping in max, because I need to try out various diferent textures and need to be anble to enter realworld sizes for it.

    upload_2020-7-4_15-40-22.png

    Alternatively, if I can't adjust the texture size in shader graph, can I overwrite the objects's UV sise within shader graph?
     
  2. newguy123

    newguy123

    Joined:
    Aug 22, 2018
    Posts:
    1,248
    Any ideas guys?
     
  3. newguy123

    newguy123

    Joined:
    Aug 22, 2018
    Posts:
    1,248
    Can anybody shed some light, or point me to a link to read more?
     
  4. newguy123

    newguy123

    Joined:
    Aug 22, 2018
    Posts:
    1,248
    anybody?
     
  5. Remy_Unity

    Remy_Unity

    Unity Technologies

    Joined:
    Oct 3, 2017
    Posts:
    704
    I guess you just want to use the world position XZ as UV input for the sample node ?
     
  6. newguy123

    newguy123

    Joined:
    Aug 22, 2018
    Posts:
    1,248
    no I I'm not sure. Because that would make the texture stick to the world and not move together with the model if that moves isnt it?

    I just want to have my textures at specific sizes for when we do configurastors. I mean why is that such a seamingly complicated thing?

    In Max I just enter the size of each texture and apply it to my already UVed model and all just works.

    In Unity seems there's no way of entering a real size for textures
     
  7. Remy_Unity

    Remy_Unity

    Unity Technologies

    Joined:
    Oct 3, 2017
    Posts:
    704
    I don't know precisely what you want to achieve here, but it is certainly possible.
    You want textures aligned with you object coordinates ? Use the position node with object space setting.
    You want them to compensate with the object scale ? Multiply with the object node scale.

    You want world aligned textures, but stick with your object ? Use the position node with world space, and add the object node position value.

    There is countless of possibilities to make dynamic uv mapping, you need to figure out the math to do to achieve what you want.
     
  8. newguy123

    newguy123

    Joined:
    Aug 22, 2018
    Posts:
    1,248
  9. Remy_Unity

    Remy_Unity

    Unity Technologies

    Joined:
    Oct 3, 2017
    Posts:
    704
    It's not rocket science, it's basic maths and logic.
    You've imported your 10x10 meters plane with UVs set up so that the texture tiles all 1 meters.
    If the object scale is 1, everything is fine.
    If the object scale is 2, you must also double the tiling of the texture to keep it at 1 meter size.
    In shadergraph, you could multiply the UVs with the object scale, and you're good.

    BUT you must also keep in mind that scale the UVs will be done from the 0,0 UV coordinate. So depending on the UV "center", you might indeed see cropping.
    I'll also answer on the other thread.
     
  10. newguy123

    newguy123

    Joined:
    Aug 22, 2018
    Posts:
    1,248
    The object scale is unlikely to ever change.

    Thanks I look forward to your reply in that other thread. Eager to solve this simple issue which appears to be not as simple.....