How to make windows random shader

Hi, I did a project and I would like to texture it, I wanted to put some building textures in it, as I thought it was a night scene, I wanted the windows to be bright, but not all, so I wanted only some windows to emit light, I took a simple texture from the internet, and used colorRamp, to differentiate the windows from the walls, but they all emitted light, so as my knowledge of shaders, it’s almost 0, I left the image in black and white in photoshop and erased some windows, it worked, but I would like to know if it is possible, to make the windows stay lit, just with the nodes, thank you

Have you tried this material setup?

1 Like

shiruzinho :
If your window have their own face, you can create a second UVmap for the object, scale UV of each window at 0, then you can use noise texture to have a different value for each window. With this value, you can choose if the window emit light or not, or affect different texture to the window.
Step by step :
1 : Select all your windows


2 : Create new UV map for your object
Window1
3 : Use individual origin as pivot
Window21
4 : Scale UV of all window to 0
Window22
5 : Use a UV Map combined to noise texture to obtain a random value to each window, connect to a ColorRamp to transform that random value to 0 or 1, and connect to emission Strength

6 : If everything is Ok, some windows emit light and other do not emit.

This is the blender file if you need :
testWindow.blend (869.1 KB)

2 Likes

Thanks, I love you!

what kind of UV image do you use ?

is it like some fake reflections from other things around?

also there are 2 UV images here !

thanks
happy bl

I usually use the Object Info Node → Random for this purpose. Your method seems interesting! Would love to try it. Thanks a lot for the tips and the blender file!

Object Info Node → Random is simpler, but you need taht all windows are different object, and sometime, it is simplier to have a single object for the building and all windows.
For example, I worked on an SF city project with a lot of building ( Sciernce fiction City ) and I didn’t want to have a different object for each window.

1 Like

i do not undersand your question.
The image F5 for baseColor is a simple image that I take in textures.com, but you can use other pictures (or if you edit the node shader, you can select a random image for the windows…)
The second UV map is used to have an unique random value to each window thank to its combination with a noise texture.
If you want glass reflection, you just have to set rougnhess to 0 in the principled bsdf node.

True. I really like this method. It’s going to be very useful.