How do you modify the color of light hitting a surface?

Hey guys! :smiley:

Does anybody know how to modify the color of light hitting a surface?

For context: I am trying to create a holographic foil shader, similar to what you see in a lot of card games. So far I already have something going that works pretty well if you don’t look at it for too long and don’t know how it works in reality, utilizing hue shift and fresnel. However, it does bug me a lot that it’s not really physically correct and it’s visible if you look at it closely. The result I am looking for is basically this:

Of course, in general Metallicness already alters the way light hits surfaces but that’s not exactly what I’m looking for (and already included in the shader). Basically, I think I’m looking for a chromatic aberration effect on light impact. Is there such a thing or something with a similar effect in the Material Editor? I would be extremely thankful for any help! :smiley: It’s something I’ve been wondering for a while now, also for different kinds of shaders, and I can’t really find anything that would be helpful in this regard.

Thanks in advance! :]

Hello and welcome back.

That holographic effect certainly brings back childhood memories of certain trading card games.
I found some documentation that may assist you along the way. I also will include a screen shot of my results and of the blueprint work I performed.

Result:

I hope this all helps you.

This effect is usually called iridescence, the more accurate term (I think) is called diffraction grating. The simplest way to do this is to just use a lookup table with a gradient in your material that adjusts the base color depending on the view vector in relation to the light and the surface normal. There are a lot of ways to do that, but I like this example outlined by James Emory here:

This can work well, but you’re limited to the lights you can pass to your material.

Another very detailed tutorial on this was done by Alan Zucconi (it’s written for Unity but you may (probably?) be able to apply it to Unreal.)

Ideally though, I think you’d need to create a new shading model in order to better support more scene lights.

Thank you both for your replies! :slightly_smiling_face:

This effect is usually called iridescence, the more accurate term (I think) is called diffraction grating. The simplest way to do this is to just use a lookup table with a gradient in your material that adjusts the base color depending on the view vector in relation to the light and the surface normal.

I’ve been trying different versions of iridescence already (including a LUT based solution) for this and while I do have something that works relatively well, its reflection pattern/behavior isn’t quite correct compared to real cards. Here is a capture of it:

The current version is probably good enough for what it is (it’s a personal project, I’ve just wanted to do this for a while now kind of as a challenge to myself) but it’s technically not quite correct. The pattern you can see in the picture I posted in the original post is what you actually see on finished cards, just usually with larger color reflections (which are the luster you see on real cards). I was thinking of maybe using a mask that wanders over the card, depending on the angle, masking in parts of the luster I currently have (tiling the colors a bit more to match the masks) but I’m not sure what the best approach to that would be. The mask would look like this (with the center left out since to fit the picture in the first post):

To accomplish that ā€œwandering over the card based on angleā€ effect I was thinking of maybe using Bump Offset with the mask. That’s how that approach looks at the moment:

All of those are just approximations of the luster’s behavior when the light is hitting the surface at a right angle, though; it’s still not quite correct. If I were to look directly at the card and I had a moving lightsource around me (in reality), the luster would change with its movement even though I am not actually moving. The current version of the shader isn’t affected by light position, only by intensity since the luster is Subsurface Scattering based). I hope I don’t make it sound more confusing rather than clarifying what I’m looking for - this turned out to be a bit more complex than expected. :sweat_smile:

Basically, standard iridescence achieves 80 % of the look but I want to get those last 20 % by getting the right luster pattern as well. For that it would have to change based on the angle toward the light source, together with the angle toward you. Is there any node that can be used for this kind of interaction with a light source (or any other object in the scene, for that matter)?

Ideally though, I think you’d need to create a new shading model in order to better support more scene lights.

Hmmm, yeah - I’ve never created my own shading model. >__>

As for the Scene Fringe solution - is there a way to limit that to focused areas only, basically with the mask I’m using on the current card to limit the luster to the image? It’s an interesting effect that does look like it might be able to achieve what I’m looking for with a little customization and I’ll look further into it.

Thanks again! :smiley:

Is the iridescent part metallic? It should be, if it isn’t. Your specular highlight doesn’t look right which is why I ask.

This effect is a bit annoying to do with a roughness/metallic setup (like Unreal uses) because we can only change the specular color by setting the metalness to 1 and adjusting the base color. You can use the clearcoat shader if these cards normally have an additional clear coat over them (I imagine they must? Or they’d be pretty delicate? Not sure)

Honestly this seems like a reasonable approach and probably closest to what you’re going to be able to get without a lot of work.

Another option would be to just create a cubemap with the highlights in them and sample it from the reflection vector of the cards surface blending it over the existing iridescent effect might be convincing enough.

Me either :frowning: Can’t help you on that road I’m afraid

You can use a stencil mask or alternatively you can just use a transparent plane that hovers above the region you want the post process applied to. It’s used a lot to give a post process effect that only appears behind the plane (depth fog for water is usually the most common example.) Both of these will require you to recreate the chromatic aberration effect though

Hey there again! :smile:

Is the iridescent part metallic? It should be, if it isn’t. Your specular highlight doesn’t look right which is why I ask.

Yeah, the light scene makes it a little hard to see (the skylight is using an overcast HDRI to get a somewhat neutral lighting, which doesn’t exactly help in this case). The foil part has full metallicness and with the skylight turned off (and only the directional light remaining) it looks a lot more realistic on that front:

This effect is a bit annoying to do with a roughness/metallic setup (like Unreal uses) because we can only change the specular color by setting the metalness to 1 and adjusting the base color. You can use the clearcoat shader if these cards normally have an additional clear coat over them (I imagine they must? Or they’d be pretty delicate? Not sure)

Hmmm, good question. I actually don’t think there’s a clear coat there but there might still be a way to utilize the shading model for this in some way. I’ve messed around a little with it recently and I think there might be an application somewhere out there for this! :smile:

Another option would be to just create a cubemap with the highlights in them and sample it from the reflection vector of the cards surface blending it over the existing iridescent effect might be convincing enough.

Honestly, that doesn’t sound too bad at all! I haven’t considered using a cubemap yet but that’s a good approach! :+1: I’ll see what I can do utilizing that!

You can use a stencil mask or alternatively you can just use a transparent plane that hovers above the region you want the post process applied to. It’s used a lot to give a post process effect that only appears behind the plane (depth fog for water is usually the most common example.) Both of these will require you to recreate the chromatic aberration effect though

Hmmm, I see. Yeah, I’ll try that after the cubemap.

Thanks for the help so far! :smiley: