How to disable specular completely for certain objects?

Hi!
I can’t find a way to disable direct specular impact from real-time lights on a per-object / per-material basis. I can globally disable it either by toggling it off in the HDRP settings or in the light component settings. But that obviously disables it for everything.

If I turn down the smoothness value on the standard lit material to 0 then there’s still a lot of specular lighting left:

If I set the material type to Specular and also turn down the specular value all the way down to the pure black, there’ still some specular response, but its way better.

But what I want is the complete absence of the direct specular like when I turn it off in the light component:

I know that it’s not physically correct, because “everything has fresnel” and other stuff, probably, but I want to provide my own specular lighting response for certain objects. And if it will be overlaid on top of the existing stubborn real-time specular, it will also be incorrect.

Is there some workaround for this?

Thanks!

Bump. Anyone?

Use the fabric shader model instead.

Hey, you can probably use a reflection probe with a custom black reflection map. And use the light layer system to only affect these specific objects. This way they will receive no reflections.

It has even less specular left than the Lit + specular, but it doesn’t disable it completely, unfortunately.

Unfortunately, reflection probes don’t affect/override the direct specular that comes from real-time lights. A custom pure-black reflection probe disables only itself…

I thought that maybe I can render the direct specular component into a rendertexture with the help of AOV somehow, but I was told in the other thread that it’s not possible without performance impact.

You can still use the light layer system to prevent this.

Here’s a test where I set all the objects on a given layer to not receive any reflection. The bronze ball is entirely black as a result:
7514105--926717--upload_2021-9-22_16-4-39.jpg

And if you use a black reflection probe like I mentioned above, you can kill the reflection. The probe doesn’t disable itself like you mentioned.

In the example below, it does indeed receive direct specular from nearby lights, but again, you can use the light layer system to prevent nearby lights from affecting this particular object.
7514105--926711--upload_2021-9-22_15-59-21.jpg

You can tell the lights to not affect the layer the ball is on, and you get zero influence from the nearby black probe nor from the spotlight above as a result. And if you don’t want the black probe to affect other objects than the sphere, again the light layer system comes to the rescue. :wink:
7514105--926720--upload_2021-9-22_16-4-47.jpg

It’s perfectly doable.

1 Like

Thanks for the detailed explanation, and I’m sorry if I get it wrong, but that’s exactly the issue. I don’t want to prevent the lights from affecting the objects completely. I want them to affect albedo, normals, provide shadows, etc. and the only thing that I want to exclude is the direct specular component. It’s like if the “affect specular” option wasn’t an off/on the switch, but rather a layer selection:

7514543--926777--upload_2021-9-22_20-56-29.png

In other words, I need “affect specular” disabled for certain objects, while “affect diffuse” and the rest of the light impact enabled for all objects.

You could duplicate some lights in this room, set them to only affect the “no specular” light layer that you create, and then set them to not “Affect Specular”. Then all objects you add to the “no specular” light layer won’t receive specular from said lights.

It requires some duplication, but in the end, you can separate entirely the “normal lights” from the “no specular lights” easily. And if your lights are in a prefab, it’s just a matter of having another prefab instance of the same light, with 1 override only on the “Affect Specular” property.

Yes, I thought of this option. But wouldn’t such light duplication affect performance in a serious way?

This is something that you would have to profile for yourself. If it’s just a few lights, it might be imperceptible. If it’s several dozens, there might be a cost. The pixel shading pass might even be cheaper.

Maybe this PR will help in this case :): [HOLD] Specular color on HDRP/Lit below 2% can be used to suppress specular lighting completely by FrancescoC-unity · Pull Request #2556 · Unity-Technologies/Graphics · GitHub

It fixes this behavior as far as I know, although you would need to upgrade your project to latest alphas :roll_eyes:

1 Like

That’s interesting, it was merged in 2020. Why is it only in the latest alphas? I’m using 2021.2 beta 11.

It’s still open, not merged for some reason :eyes:

I wonder what my chances are if I merge it myself into the 2021.2 beta…

This is hilarious. Im sorry you cant get good help OP. I would just set the reflection probe usage to OFF for the mesh renderer. Now when you put the smoothness to 0 there will be no light shine at all.

Also, when you set a material type to specular (versus metallic), all you are doing is aenabling a specular map for the shader. This is a map that only affect the Color of the specular shine, thats it.

There are no reflection probes in my screenshots. All the specular response is produced by two area real-time lights.

There is a default reflection probe that is applied in your scene.

What i mean is, if you dont have probe Unity will put a default one there that you cant see.