Rim Light in 2D LRP

On GDC they showed that you can create rim lights through making an outline secondary texture and then somehow setting up a light that only acts on that secondary texture (_MaskTex channel), problem is they don't explain how to setup the light itself to make it only affect the outline. I'm guessing it has something to do with "Light Operation" field which isn't present in our version (main light has Modulate Light, rim light has Additive) or perhaps Import settings of the outline file itself?

https://www.youtube.com/watch?v=0xnYbhqRDkM|start=1464

Has anybody managed to reproduce it?

I don't think this is currently possible as the Mask channel doesn't seem to be working with the 2D LWRP

What strikes me as weird is that the version they have GDC is 2019.2.0a3, we have an access to 2019.2.0b7, yet we don't have that functionality and they do. Is this something they temporarily disabled?

We don't have the "Light Operation" field but we have something called "Blend Style" with 3 options that are marked as (Disabled) - anybody knows if it's the same thing?

You have to define the blend styles in your 2D Renderer asset:
4697036--443174--upload_2019-6-29_12-45-15.png

Yeah, it seems like it has nothing to do with that and just the mask channel isn't affected by light at all, tried all possible configurations already

A few steps:
1) Setup your Blend Styles on the 2D Renderer Asset. For Rim Lights; make a 'Rim Layer' Style
2) Create a Mask Map that outputs a 'Rim Mask' through your chosen Blend Style Texture Channel
3) Assign your Mask map to your Sprite Shader's mask input (you can also output the mask texture channel in Shader Graph)
4) Now create 2D Lights and set them to render on the Blend Style layer of your choise and point to the Target Sorting Layers that your sprite is on.

I can confirm this all works in 2019.2b5 and LWRP 6.7.1 and should work in any higher version(s).

1 Like

I had some difficulties trying to follow that but in the end I managed to reproduce it, here's some additional info that might be useful:
1) The most important is setting Mask Texture Channel in 2D renderer style, it should be either R, G or B (or One Minus R/G/B if you want inverted rim light)
2) Mask Map is simply a black-and-white texture where greyscale decides what gets affected by light (white is fully affected, black is not affected at all). You can leave its import settings at defaults (doesn't even need to be a Sprite)
3) You don't need to assign anything to the shader (i mean you can but that's the hard way and will cause you a lot of overhead) - the easy way is to go to the Sprite Editor -> Secondary Textures, add new texture and name it "_MaskTex" (needs to match that name exactly) and drag your Mask Map in the Texture field (this way you don't need to create a new material for every sprite that needs an outline, you do the same thing for normal maps but the name string for normal maps would be: "_NormalMap"). There's some exceptions where you don't have an access to Secondary Textures (for example with .psb files for 2d animation system)

1 Like

Thats pretty much what I said (Minus the secondary textures part) :smile:

And yet I started off from choosing "None" and "A" as my Mask Texture Channel for rim layer which surprisingly are the only 2 options that don't yield any result, never lucky :hushed:
(well, they actually do but you end up with something approximating a standard light due to alpha channel being always 1 which makes the entire sprite being evenly affected by light but from the perspective of somebody attempting it for the first time without any back-end knowledge you wouldn't be able to come to this conclusion quickly)