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 Shader Graph - (How) does scene color work with 2D sprites?

Discussion in 'Universal Render Pipeline' started by Nit_Ram, Sep 5, 2022.

  1. Nit_Ram

    Nit_Ram

    Joined:
    May 8, 2016
    Posts:
    24
    Hello all,

    I am currently trying to recreate the Photoshop Blend Modes in Unity. The whole thing should work with 2D sprites.
    However, I don't know how to blend the sprite with the scene. I think that the Scene Color Node is part of the solution, but it doesn't seem to work.

    This is the Blend Mode "Linear Dodge" in Photoshop (how it's supposed to look):
    upload_2022-9-5_14-16-50.png

    Here is the same setup in Unity (wrong):
    upload_2022-9-5_14-17-57.png

    This is the shader I built so far:
    upload_2022-9-5_14-18-29.png


    Apparently Unity doesn't blend with the background sprite in the scene, but with a solid colour. What am I doing wrong?

    Scene setup:

    upload_2022-9-5_14-20-17.png

    upload_2022-9-5_14-20-50.png

    Do you have a hint what could be the issue? Thank you!

    Best,
    Martin
     
  2. n30ngr1d

    n30ngr1d

    Joined:
    Jan 27, 2021
    Posts:
    1
    Bump, as i also cant find a solution to this anywhere
     
  3. Lo-renzo

    Lo-renzo

    Joined:
    Apr 8, 2018
    Posts:
    1,323
    SceneColor isn't doing what you think it's doing. SceneColor samples from the CameraOpaqueTexture
    https://docs.unity3d.com/Packages/com.unity.shadergraph@6.9/manual/Scene-Color-Node.html

    But 2D sprites are transparent, not opaque! There's the problem. They're not written into the CameraOpaqueTexture, so you can't actually get the background color like that.

    There's a limited 2D Renderer workaround for this called the _CameraSortingLayerTexture. This lets you snapshot the colors of your scene at a particular point in time and use those colors in later effects.
     
    Nit_Ram likes this.