Get brightness of object

Started by Belmont224, June 26, 2025, 06:08:34 PM

Previous topic - Next topic

Belmont224

Is there any way to get the brightness of an object (terrain)? I see some function like get diffuse color and get final color, but I can't seem to make them do anything. 

As an example, can I make a shader that when the brightness is 0.5 and below it will be black and 0.55 and above it will be white?

Dune

I don't know if this would work for you.

Belmont224

#2
Thank you! After playing around a lot I did get something similar to that (though not as concise).

I'm actually trying to get the amount of light that is falling on the surface, not necessarily the brightness based on the texture. (that's what I meant by brightness, I can see I was very unclear).

Initially I was thinking I could base it off the angle between the direct lighting and the surface normal. So if the sun was right behind me, and the landscape it was hitting had a surface normal pointing right back at me I would consider that brightly lit. If the surface normal was pointed 45 degrees away from me, that would be halfway lit, etc. I thought that might be a rough estimation. Besides not knowing the math for how to do that, it doesn't take into account shadows though.

Dune

I think if you make clear what you want to achieve exactly (with that mask), someone else may have an idea.

Belmont224

A simple 'cartoon' or threshold shader. So values below a certain value are black, values above a certain value are white. See example below (one half showing the effect I want, the other half showing the render without the effect). It isn't based on texture, but on the light hiting the object. I know this can probably be done outside of terragen, but I wanted to see if I could do it inside.


Dune

I don't know a simple way to do this. There are some functions like get ray origin, but I have no clue what they do and how to link. Just wait for Matt or Kevin I suppose...

Kevin Kipper

Well a toon shader would be cool.  I'm not sure if it can be replicated via the available nodes...I'll ask Matt :) 

Kevin Kipper

Have you tried the Shadow Catcher shader?  Not exactly a toon shader, but may get you closer to what you're describing.   Here's the online docs: https://planetside.co.uk/wiki/index.php?title=Shadow_Catcher_Shader

Belmont224

That is very interesting, I hadn't seen that shader before. Thanks for pointing that out!