# Creating a Specular using two color channels?

I've been attempting to recreate a game's cel shading and am currently stuck on making speculars function.

The main issue is that the speculars are done manually using both the red and blue channels of a specific texture, and that the Red channels determines "Intensity of Specular Highlight" and the Blue Channel determines "Ease of entering highlights".

Here's how it looks in the game in question with a model reference and the texture used for lighting:

https://imgur.com/a/vItyeBX

https://imgur.com/a/R933kYX

https://imgur.com/a/b9UPEJ8

Not really sure how to go about this now, considering the lighting is not natural and actually tracks the camera in-game, though I thought I should plug the camera in last after the actual calculations are done first.

How should I go about this? Can I somehow "factor" the Blue with the Red somehow like a Mix RGB node?

• I think I might have an idea about how you could set things up, but before I write a 3 page report, it would be really helpful if I could see what's in both the red and blue channels. Any chance you could post pics of what the images in those channels look like (connect to basecolor or something)? – Christopher Bennett Jun 16 at 4:56
• @ChristopherBennett Sure thing. Here's the blue channel visible: imgur.com/a/D2tmaXx This is the red channel visible:imgur.com/a/I87yiio And here's each respectively in an image editor, note that I intentionally made them the same value. This is the red: imgur.com/a/41VzynV This is the blue: imgur.com/a/rdrlD11 – Diran Jun 16 at 7:05
• Damn, I thought I had it, but those maps don't exactly look like what I was expecting. I guess I don't have enough experience with defining specular highlights this way. I was hoping I could drive the "Easing of specular highlights" as a factor through a color-ramp, and then use that as a mix factor for something else (possibly the intensity). However, it looks like the channel contains more data than just that. I'll keep working on it to see if I can come up with anything. In the meantime, I'll up-vote the question in the hopes that someone with better knowledge will stumble along. – Christopher Bennett Jun 16 at 7:40
• Ok. I was hoping one of them would be B&W only and was an obvious "mask" of some sorts. I think I get the idea - one map shows where the "shadow divisions" should be, and the other decides the intensity of the colors in those shadow areas based on the specular strength. However, how they would "prefer" to be connected is beyond me. – Christopher Bennett Jun 16 at 15:27
• Yeah, maybe try a light path. selecting "is reflection ray" plugged in as a mix factor for the blue or something. – Christopher Bennett Jun 16 at 15:47

Ok so I spent a lot of time on this last night, and I don't want to all go to waste, so I'm just gonna post it, in the hopes that you might find ANY part of it helpful. If this doesn't help you at all, let me know and i'll delete this answer - it is simply far too much to put in a comment.

I think I understand what you're trying to do, but without access to an image texture with shader values embedded in the color channels, I'm shooting blind somewhat. Hopefully this setup, or some close rearrangement, is able to give you what you are looking for. I'm not really familiar with defining specular highlights this way, so I'm doing my best to translate it to what I know.

Generally, when making cell shading, I simply drive a Diffuse BSDF through a Shader to RGB and into a ColorRamp set to constant, with three or four harsh cutoffs.

If I am trying to cell shade an existing texture, I use a MixRGB shader set on multiply and mix the texture with the result of this ColorRamp, to apply the "harsh shadows" from the cell shading to the texture. As you can see from this image, I multiplied the texture by the ColorRamp values twice so I could have an extra strong contrast for this example image. You may or may not need this.

Now, on to your specific case (to the best of my abilities) You said the blue channel defines the "easing" of the highlights - I think this represents the shadow level cutoffs like I specified in the ColorRamp. Here's where I'm divided though. The wording (easing) suggests the presence (or lack therof) of a gradient between the different light levels - cell shading is generally defined by the lack of a gradient, therefore I think this would be represented by the "constant" cutoff I used on the ColorRamp, as opposed to "linear". However, I do not know how much this also includes where the light cutoff points are. This brings me to my next issue - the red channel - the "intensity" of the specular highlight. Does this mean the brightness at certain cutoff levels? if so, does this mean that the blue channel determines where the "light level containers" are, and the red channel determines what actual "light level" they each get filled with? I have to assume that it must be something like this, because the only other use of "specualr intensity" I can think of refers to how much the specular reflection takes on the hue of the diffuse color, which generally only applies to shiny metallic items, which I don't generally associate with cell shading. Maybe that's the case here - maybe they're trying to use metallic values to drive the hue of the "shaded" area - I don't know and if that's the case, I have no idea how to do it.

So, given all that I know, and all that I don't know, here's where I am: I was thinking some setup SOMETHING like this might get what you want, but I don't have the image with the separate channels, so you'll have to try it yourself. Maybe if you just switch up the node connections randomly you'll miraculously stumble upon the answer. I've done all I can - the more I look at it at this point, the more I feel like my eyes are bleeding.

The brief explanation is this (though keep in mind I'm totally lost at this point). I used the reflection ray to drive the mix of the shadow cutoffs based on reflection angle with the "easings" in the blue channel. I have no idea if this is even necessary. Anyway, I then used this "shadow combo" with as a mix factor between the original image (if there is one) and white "highlights" . I have no idea what to do here if there is no "original image" texture to work with.

Anyway, I then combined this "shadow+image highlight" combo with the brightness and color values of the red channel, using the shadow values as a factor (because it gets info from the reflection ray - again I don't know if this is the right way). So that's it. Hopefully by playing with some arrangement of this setup you can come up with something at least workable.

Let me know if it works out.

Cheers

• I forgot to mention that I'm using Eevee to render, and I actually found an old 2.79 file that contained what I needed to get the bare essential effect: link Now all I need is to do is make it depend on camera view instead of sun rotation, but I'd like to leave your comment in that someone can use it instead and how much you put into giving me an answer, also the fact I'm onto another problem itself lol. Thanks for sticking with me through this, I didn't think I'd get this far talking about it! – Diran Jun 17 at 1:58
• All good. Glad you got it resolved. I'll study the setup in the link so I understand it for the future. – Christopher Bennett Jun 17 at 2:17