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 Does SRPs limit how we write our own custom shader.

Discussion in 'Shaders' started by armmekung, Jul 24, 2022.

  1. armmekung

    armmekung

    Joined:
    Jul 20, 2020
    Posts:
    2
    First, I'm not an English speaker. sorry in advance for any mistakes.
    I have been learning how to write Shader for days, and got stuck with multi-pass shader (not sure what it is called). From google, look like SRP doesn't support more than one shader pass in a single shader (please correct my if I'm wrong)

    Does this problem will affect how we write custom shader? There are some tuitorials that use multipass in their code so I don't really know if they(tuitorials) are outdated or not.I heard there are some ways we can simulate the multipass shader such as multi materials but it didn't work in my case.
     
  2. armmekung

    armmekung

    Joined:
    Jul 20, 2020
    Posts:
    2
    Since I'm here, I'm a bit confused which one I should focus on first between Shader in code and Shader in graph. Do people still writting shader in code these days (for modern game engine) ?
     
  3. burningmime

    burningmime

    Joined:
    Jan 25, 2014
    Posts:
    845
    What effect are you trying to achieve by using multi-pass shader? You may need to do multiple passes manually, and they may work differently if using deferred vs forward vs forward+. But most objects do not need multiple passes, multi-pass is useful mainly for full-screen effects.

    I don't use graph at all anymore. But some people may like it because you can see the result while you edit it. You can choose whatever way is easy for you.

    Anything with custom lighting model will also require custom code. HDRP has many graphs to choose from. On URP, you may want custom shader for:
    • Glass (thin glass like wineglass or thick glass like beer mug sometimes different)
    • Water
      • Puddle or rain on slick surface
      • Flowing water (river)
      • Shallow water (pool)
      • Deep water (lake)
      • Wavy water (ocean)
      • Dynamic water (boats or stuff moving in water make waves)
      • 3D water or liquid with physics
      • Many other kinds of water/liquid
    • Hair
    • Fur
    • Eyes
    • Skin
    • Candle wax
    • Trees and plants
    • Grass (sometimes must be different from tree because there's a lot of grass)
    • Iridescence (butterfly wings or gasoline spill)
    • Clouds and weather
    • Very complex terrain
    • Cartoon or Anime
    • Full-screen special effects
    • Must go very fast in mobile VR, so need special hacks
    • Other stuff
    Basically anything that must do something special with light. Shader graph only gives you control of surface and light is done automatically. Sometimes light matters though.
     
    Last edited: Jul 29, 2022