r/GraphicsProgramming • • 23h ago

are shadow rays unavoidable?

Post image

i'm writing a raytracing (maybe pathtracing?) program. my program doesn't treat light sources differently than an hittable object. it doesn't deliberately cast a "shadow ray" toward each light source and check whether it hits and if it does get the color and multiply it with cosine, etc. it just shoot rays and let them bounce and bounce and bounce. some eventually reaches a light source and returns the color

it always produces soft shadows but i can't get sharp and clear shadow. and the soft shadows are quite noisy. is there no way i could overcome this, other than adding a shadow ray shooting procedure?

addition info:

shadows are more visible in low light environments so i usually use relatively dark scenes to test shadow formation and do gamma correction. attached image is an example. the scene has only one light source which is behind the balls and located at infinity

how to get a clear and sharp shadow?

20 Upvotes

16 comments sorted by

View all comments

-1

u/HaMMeReD 22h ago

Well your source light looks really big, if you tried making a point light and not an area light?

7

u/sirpalee 22h ago

That wouldn't work if OP is just firing random rays in a path tracer. They would end up with very noisy results.

Next Event Estimation is the answer and yes, that includes tracing "shadow rays".

2

u/HaMMeReD 22h ago

It certainly isn't going to help to have a giant soft box light source. You sample enough rays, a soft or hard shadow is going to emerge based on your scene geometry.

The scene is the problem here. If there was a point light and a opaque cylinder, I bet the shadow penumbra would be pretty tight. OP should fix the scene layout and prove they actually have a problem first. (Before they focus on acceleration and NR).

-2

u/VictoryMotel 20h ago

Wouldn't work? Smaller lights give harder shadows.

3

u/sirpalee 19h ago

Read the first two sentences as a whole.

-2

u/VictoryMotel 19h ago

Noisy shadows are still soft shadows. These are two separate and distinct concepts.

1

u/sirpalee 18h ago

OP was asking for clear and sharp shadows. Not just for sharp.

1

u/VictoryMotel 13h ago

You have to have the solution right either way. There is no point in conflating two things that can be easily separated.