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. Dismiss Notice

Question How to render a layer as a Multiply blend on top of another layer?

Discussion in 'General Graphics' started by PolygonPros, Sep 18, 2020.

  1. PolygonPros

    PolygonPros

    Joined:
    Apr 11, 2020
    Posts:
    34
    Hello, I'm wanting to create an effect like Multiply layers in Photoshop, where one layer will render on top of another layer, and darken it based on its values - but do this with the real-time rendered output of different objects in a scene in Unity.
    By blending layers, different objects could overlap in various ways (multiply, overlay, additive, etc...) For example:



    I know how to do this in Photoshop, After Effects, etc., but I'm not sure how this is done in Unity.

    The specific effect I am trying to create, for a NPR look, is to have a skybox that looks like a paper texture, and render various objects in the scene so that they look painted/printed on top of the paper skybox. So instead of the objects simply rendering in front of the skybox, they would darken it, causing the paper texture to show through onto them (instead of just being covered up by them.)
    I hope I am being clear with my less-than-technical description... For example:



    Any idea how to approach this? I'm assuming that the effect could be created using two different cameras, one for the skybox and one for the objects, and then applying the rendered frames from the objects camera onto the skybox camera render, as a multiply blend. Or vice versa: render the skybox in front of the other objects instead of behind them, and use it as a multiply on top of the rest of the scene. I don't know how to do either of these, though, or if they are indeed the correct approach.

    I've done some internet searching already to find how to do this, but haven't found the answer yet. Thank you for any solution you can offer, or for pointing me in the right direction!
     
    Last edited: Sep 18, 2020
  2. mouurusai

    mouurusai

    Joined:
    Dec 2, 2011
    Posts:
    349
    You can't do this without some custom shaders.
    Basically you push 2 textures into shader(maybe render texture from camera) and do a blending.
    If you try write it yourself you can copy blend models from wiki:
    https://en.wikipedia.org/wiki/Blend_modes
    Or you can get Amplify Shader Editor(perhabs Shader grapth too) and use premade node with wanted blending mode.
     
    PolygonPros likes this.
  3. PolygonPros

    PolygonPros

    Joined:
    Apr 11, 2020
    Posts:
    34
    Thank you for the tips, mouurusai!

    I got some help on this from people on Discord. Apparently there are 4 or 5 different ways to accomplish this, some solutions involving creating custom shaders or using assets available on the Asset Store.

    The easiest method that was recommended to me is to:
    1. Set a camera to Render Texture with culling masks for the layers that I want to be the "blender" for the multiply (in my case, the character models);
    2. create a Canvas Image that stretches to fit the screen;
    3. set the Render Camera setting in the Canvas to another camera with culling masks for the layers that I want to be the "blendee" for the multiply (in my case, the skybox and background models);
    4. create a new material, assign the Particles Standard Unlit shader to it, assign the Render Texture from step 1 to the shader's albedo map, set the shader's rendering mode to Modulate, and the color mode to Multiply (other options can create other effects, but multiply is what I wanted);
    5. assign the material from step 4 to the Canvas Image from step 2.
    Here's the result:

    PolygonPros_BattleArts_WIP_screenshot_092620.jpg PolygonPros_BattleArts_WIP_screenshot_092720b.jpg
     
  4. PolygonPros

    PolygonPros

    Joined:
    Apr 11, 2020
    Posts:
    34
    This approach looks good for what I want it to do right now, but is a bit limited. To have greater control, and be able to mix different blend modes together, I may need to learn how to make custom shaders.