How to get a mask of light on object?

Hello. I have a scene with a thin cube (sort of bank card), which is lit by a point source and reflects a background (hdri sky), also has a hologram that reflects glares in different colors and a normal map that simulates some convex places.

9207546--1284678--upload_2023-8-10_11-55-28.jpg

I need to get a white-black mask of light on that card. Like this (it's not a mask from the image above):
9207546--1284675--upload_2023-8-10_11-53-16.png

How can I achieve this?

9207546--1284672--upload_2023-8-10_11-52-40.jpg

Don't understand what you physical effect you are trying to achieve.

You can set a mask on the light. It is called a light cookie.

Or do you mean making some parts of the map less reflective? It's called a specular map for specular workflow or metallic map for metallic workflow.
https://www.a23d.co/blog/pbr-textures-metallic-vs-specular-workflow/

You can also use a roughness/glossiness map which changes how sharp the reflections are.


I dont try to achieve any effect, and even make any chages in scene.
I just need a two pictures as output: one is some frame of video i render, and second is black-white picture only with light spots in pixels which corresponds to lights and glares on the first image

Still not entirely sure if I understand what you are asking for but it sounds similar to what the bloom post-processing effect uses internally.

Bloom works by first setting all pixels of the rendered image to black that are below a certain brightness value. If you want a sharp mask, than it would be this. Then it blurs that mask by downsampling and upsampling it a few time. If you want a blurry mask, it would be this. Finally, it adds it back on top of the picture to create the bloom.

There is no built-in way to extract those masks but the source code of the post-processing package is available. You could copy and modify it. It's does require quite a fair bit of graphics programming knowledge, though.

I think you get it right: I need to get a sharp mask of lightened zones on objects. For each frame of a video sequence, I can render, I need an additional image, where black color corresponds to non-lightened pixels on the original image, and gray to white colors corresponds to lightened pixels, with regard to the amount of light.

So yes, the first step of bloom looks similar. But I need to get a mask not for just "bright" pixels, but for ones, which are lightened by a source or "bright" (probably depends on threshold) reflections from the background.

Is there a way to get a mask for not "bright" pixels but for lightened ones? And if yes, is there a way to do it with built-in instruments without changing source codes, writing complicated shaders, etc?

Every non-emissive pixel that you can see on the screen is lit by some kind of light source, otherwise it would be black. Light can come either directly from a light source or indirectly (light reflected off walls). Light sources can be directional, point, spot lights, emissive surfaces or ambient light (the sky).

If you ignore indirect light, emissive surfaces and ambient light, you could theoretically create such a mask. It would be black (or zero) if a pixel is in shadow of every single direct light source and white (or one) if at least one light source can "see" the pixel.

When you use deferred rendering, you could check whether a pixel receives light from a certain light source in the light pass. In the light pass a light volume is rendered for each light. This is where you could write out the mask but it does require you to make a copy of the standard deferred light shaders and modify them. I don't think there is a way to do this with built-in instruments.

In pseudo code:

create a render texture for the mask and clear it to white
for each light (pass)
{
for each pixel
{
multiply mask value by the shadow factor of pixel.
}
}