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

Question performance issue with material

Discussion in 'General Graphics' started by steveh2112, Jul 30, 2023.

  1. steveh2112

    steveh2112

    Joined:
    Aug 30, 2015
    Posts:
    314
    hi, in my game (VR but don't think that matters) , i am making the road out of 10x10 unit planes, each on textured with a 4096x4096 albedo and normal map, the files are jpeg about 3MB each

    i do it this way so i can tile them as mirror images of each other so they have seamless borders which looks great. but maybe there's a better way? i like this because i can use the same image, asphalt with a white line (center line of road) on one edge.

    anyhow, i notice when i have about 20 road segments displayed, my fps goes from 70 to 35

    it can't be a geometry thing right< 20 planes is nothing so i'm guess its something to do with material? i guess i could drop to 2k textures but they don't look good up close.

    any thoughts? thanks
     
  2. c0d3_m0nk3y

    c0d3_m0nk3y

    Joined:
    Oct 21, 2021
    Posts:
    569
    Is it the same albedo and normal map for each tile or does each tile have different ones?

    If they are all different, you would need roughly
    4096 (width) x 4096 (height) x 4 bytes (assuming RGBA8) x 2 (albedo + normal) x 100 (number of tiles) x 1.3 (mips) = ~16.9 GB of VRAM for those alone

    You can reduce it a bit with texture compression but you get the point.

    You can try to turn on texture streaming and see if that helps
    https://docs.unity3d.com/2019.1/Documentation/Manual/TextureStreaming.html
     
    Last edited: Jul 30, 2023
  3. steveh2112

    steveh2112

    Joined:
    Aug 30, 2015
    Posts:
    314
    yes, one material used on all tiles. each tile is copy and paste from the first one, only difference is scale
    they are already jpegs with 80% quality, i guess i could go down, get the file size down to about 1MB i guess. maybe i don't need the normal map either not really visible

    i don't have mipmaps set up yet, i guess that's the next big job. i'll also look at texture streaming , thanks

    i don't understand how compressed textures work in vram. are the saved in compressed formed in vram (seems unlikely)? i would assume they are decompressed on their way to the GPU? since its the same texture on all files, aren't i just using 4096x4096x2 total vram, so 8k
     
  4. steveh2112

    steveh2112

    Joined:
    Aug 30, 2015
    Posts:
    314
    oops, i just noticed my normal file is a 52MB png, i got it from a normal map generator and didn't see that before. i think i don't need it anyhow
     
  5. c0d3_m0nk3y

    c0d3_m0nk3y

    Joined:
    Oct 21, 2021
    Posts:
    569
    The file size is no indication for the size required in VRAM. In VRAM textures have to be either uncompressed or use a special form of texture compression which can be decompressed on the fly. Texture compression is not as good as file compression.

    Unity shows you what the VRAM size will be when you import the texture:
    upload_2023-7-30_12-20-17.png

    I still don't quite understand if you are using the same material with the same textures on all tiles. If you are, then it's fine and the problem lies somewhere else. But having the same piece of road over and over on all 100 tiles would look strange so I don't understand what you are doing exactly.
     
    Last edited: Jul 30, 2023
  6. steveh2112

    steveh2112

    Joined:
    Aug 30, 2015
    Posts:
    314
    yes, only one texture/material is on every road object

    like i said, i do it this way so i can make a road using objects than blend together perfectly at the edges because the x and z scale is set to either + or - to make mirror images of themself which tile perfectly. tiling in the material doens't work because you will see the tile joins
     
  7. Sluggy

    Sluggy

    Joined:
    Nov 27, 2012
    Posts:
    853
    The profiler, frame debugger, and memory profiler will tell you exactly what is going on. From the sounds of it there is something else because what you've described so far is very lightweight.
     
  8. steveh2112

    steveh2112

    Joined:
    Aug 30, 2015
    Posts:
    314
    yes, i think you are right because i keep dropping down to 35fps even when i disable almost all my models

    i'm suspecting its something to do with the VR rig
     
  9. xindexer2

    xindexer2

    Joined:
    Nov 30, 2013
    Posts:
    78
    I doubt this is the issue but is there a reason why you are using planes over quads? What’s your triangle count?