• RuntimesUnity
  • Looking for an easier way to set up emissive and light mask

Thanks for the additional info.

Cheshirecrow The goal is to figure out an effective way to get animated emissive lights in runtime with the correct rim light which uses the red channel.

I'm afraid I don't quite understand the desired combination of rim light and emissive light here. Normally the rim light is created by outside sources, a 2D Light placed in the scene where the back of the character should be lit when moving past it. For the rim light, the skeleton's material just controls reflection intensity of such lights, via the Light Mask, limiting reflections to the rim. Emissive light on the contrary is used for light sources emitting light from the skeleton, like e.g. green fluorescent areas or glowing eyes. If you want to control the emissive map's intensity at runtime, you normally set the emissive map to cover only the glowing areas, and then change the color parameter next to it accordingly, which is multiplied with the mask. You can then use e.g. a MaterialPropertyBlock to avoid creating material duplicates.

Related Discussions
...

Cheshirecrow I didn't find any option to set the light mask to only use a red light channel like what I used to do.

Here's an example of what the light mask is supposed to look like:

If like in the short video section you posted earlier, this looks more like you want to place a 2D Light in the scene at the respective location (or let the position move with a bone via a BoneFollower) and then let it light your skeleton. How did you originally create this lighting effect? Why can't you reproduce it with the Light Mask now, what prevents it from working?

  • Cheshirecrow ответили на это сообщение.

    Harald Thanks, I understand the concept of achieving this effect in runtime and I can recreate this light effect as needed. The reason why I'm trying to find a better way to do it is because of the lack of control over the emission map (animation).

    Now I'm trying to make an automated landmine as you can see in the first video. The emission map should be animated on or off depending on its active states and I achieved that by animating an 'additive' layer inside Spine and then exporting it into Unity. Here's what the material looks like in runtime for this animated emission effect:

    Instead of setting a light mask or emission, Spine did a good job combining all meshes into one:
    But now I can't set up the light mask like I used to do as that wouldn't fit in with this atlas

    Do you have any suggestions?

    • Harald ответили на это сообщение.

      Cheshirecrow The emission map should be animated on or off depending on its active states and I achieved that by animating an 'additive' layer inside Spine and then exporting it into Unity.

      Thanks for sharing the details. Unfortunately I don't quite understand, why don't you use the additive slot blend mode any more if it worked before? Or did you run into problems making the additive blend mode work with URP?

      Cheshirecrow But now I can't set up the light mask like I used to do as that wouldn't fit in with this atlas

      You don't pack mask or normal textures into the atlas, you need to have an identical atlas texture for the mask where only these regions are not black.

      • Cheshirecrow ответили на это сообщение.

        Harald So what do you suggest I do if I need to achieve the flickering effect in the first video? Could you give a general idea of how to achieve the same effect with the separated textures method?

        • Harald ответили на это сообщение.

          Cheshirecrow I would create a 2D Light at the respective position and vary it's intensity over time. If you need to mask the effect to some parts of the skeleton, then have the 2D light's Blend Style set to be e.g. rim. Then let the mask atlas texture at the skeleton only be non-black (in e.g. the red channel) where you want the light to affect the skeleton.

          Note that the mask texture is a copy of the normal atlas texture with identical layout, not adding mask attachments to your normal atlas texture. You can ensure the identical layout by creating the mask atlas texture from the output normal atlas texture, or pack attachments by folder structure and ensure that all attachments to be packed are of the same size and have Strip whitespace X/Y disabled to ensure all are packed with identical layout.

          If I misunderstood your question, please let me know.

          • Cheshirecrow ответили на это сообщение.

            Harald Do you mean adding another 'Light blending style' and using additional lights to control the emission map aside from rim lights?

            Does this mean 'additive layers' from Spine are useless if I want to use a light mask in runtime and I should remove them completely?

            • Harald ответили на это сообщение.

              Cheshirecrow Do you mean adding another 'Light blending style' and using additional lights to control the emission map aside from rim lights?

              Sorry if the description didn't help. I was mostly describing how to create the lighting effect for the second video you posted, the one with the walking robot below the text "Here's an example of what the light mask is supposed to look like". Your example of the rolling ball is actually a bit different.

              Regarding your first video with the multiple red lights at the ball, plus the white rim mask:
              The red lights and the rim are completely separate things. For the white rim, if the ball would not be rolling: the rim atlas texture should be assigned at the Light Mask with only these atlas parts non-black where the rim light should be displayed. Then place 2D Lights in your environment with Blend Style set to Rim. And don't set the rim light attachment slot to Blend Mode Additive, you want to use the 2D Light to light the masked parts. That all applies if the ball would not be rolling.

              Since the ball is rolling, you have the problem that the rim moves with it. To fix that would require the attachment to be separate and aligned horizontally via e.g. a TransformConstraint or overriding bone location programmatically, or using a similar solutions to keep the bone horizontal. Since you can't separately rotate the rim mask texture from the normal color texture at a single attachment, you need to have two separate bones with separate attachments. This fixes the orientation part of the problem. The light-attachment at the top could have Blend Mode Additive. Then you would enable the material parameter Light Affects Additive, so that the 2D Lights are multiplied with the additive color. With this combination, you should not need a mask for this rim light any more, as the light is multiplied already with the additive texture, resulting in the mask effect.

              Regarding the multiple red lights: I'm not quite sure what the exact problem with those was, but you can simply enable the Emission property and assign the emission atlas texture there (again, identical in layout to the normal atlas texture, only white where the red lights are), then modify the color property next to it (programmatically e.g. via MaterialPropertyBlock to avoid material copies).

              • Cheshirecrow ответили на это сообщение.
                • Изменено

                @Cheshirecrow An easier solution would be to have the rim mask cover the whole area of your ball, and to have Spotlight rim lights illuminate the top part brighter than the bottom.

                You can actually see a similar setup in the example scene URP 2D Shaders, at the Spine GameObject (stretchyman) objects, there you can have a look at the material setup.

                Harald Regarding the multiple red lights: I'm not quite sure what the exact problem with those was, but you can simply enable the Emission property and assign the emission atlas texture there (again, identical in layout to the normal atlas texture, only white where the red lights are), then modify the color property next to it (programmatically e.g. via MaterialPropertyBlock to avoid material copies).

                Thank you for the wall of text, this is what I'm looking for. Sadly there isn't any solution to animate it directly inside Spine but I guess it is what it is. I'll talk to the programmer and figure out a way.

                I really appreciate your help, wish you have a wonderful week

                • Harald ответили на это сообщение.

                  @Cheshirecrow Glad it helped, sorry that there isn't a simple straightforward solution.

                  Cheshirecrow Sadly there isn't any solution to animate it directly inside Spine but I guess it is what it is.

                  I assume the by "animate it" you mean animating the red emissive parts. Of course you could also just use a Slot with Blend Mode Additive and then create an animation which changes the slot color. Sorry if I missed that you want to do that, I was mostly focussing on a solution for the rim light (which is the harder problem to solve properly for the rotating ball.)

                  • Cheshirecrow ответили на это сообщение.

                    Harald Of course you could also just use a Slot with Blend Mode Additive and then create an animation which changes the slot color.

                    It's what I did, but I was stuck on making the rim light work with this. I suppose I have to use static maps

                    • Harald ответили на это сообщение.

                      Cheshirecrow It's what I did, but I was stuck on making the rim light work with this.

                      That advice was intended just for the red emissive lights, not for the rim lights.