Viewport and rendered image not matching in EEVEE

Hello every one!

So… Why aren’t my shadows the same?

I’m a bit new to blender and following a lot of tutorials these days. I’m trying to have a 2D look using the shader to rgb in eevee and before tweaking all of my shaders and stuff I wanted to see if I could trust the viewport or not. Guess what it doesn’t give the same output…
So I wanted to know if I’m missing something, or not sampling something the right way or anything else. I have my viewport settings in simplify but not the render, can it make a difference like that?
I want the shadows to be sharp so I deactivated soft shadow (but even with it on the result is not the same). I’m “indoors” so maybe there’s something with that… (but there’s no mesh as windows). In the tutorials it’s always exactly the same on the first try haha…

Also when I move in the viewport the shadows kind of “moves around”. Like if my camera is closer there is no shadows and farther away a big one. In my mind since the lights and shaders are not moving the shadows shouldn’t but maybe the shader to rgb doesn’t really work like that? I don’t know haha I’m kind of lost honestly ^^

Thank you for any suggestions or pointers :smiley:

Welcome!

From your description, it sounds like you are relying mostly on contact shadows to do most of your shadowing.

Contact shadows aren’t meant to be used as the main source of shadow. They are a screen space effect, which means they depend on what’s visible on screen at any given time.

The main shadow system of Eevee doesn’t have this problem, but its pixellated nature means the shadows often don’t connect perfectly with the objects casting them, or miss very small features. Contact shadows exist to bridge that small gap, to get a little bit of detailed shadow right next to objects, but if you use them with a large distance, they get visibly glitchy.

So, you should go into the render settings, get the regular shadows to their best quality, then use contact shadows with the smallest distance necessary.

2 Likes

Hi! Thank you for you response, and you’re totally right the shadows seem to be screen spaced but I didn’t really want that haha (I put another point of view of my scene with a bit of the node editor maybe it’s my materials that aren’t build the proper way? (the node groupe between the image and the BSDF is just a mix color node to have the image tinted blue)
I mean when I put the lights you can see it affects the shader so in my mind it would have been world space (I don’t know if that’s the right terme for the opposite of screen space ^^'). In image 1 you can see the delimitation of the door and the light coming in and image 2 since the door is not in the screen view there aren’t any shadows cast :frowning:

I tried putting the samples up but the shadows are still not working fine. Maybe it wasn’t the right thing I was moving? I put a screen shot of the render shadow attribut I played with (2nd image).

But I think the main problem is totally the screen space stuff and it affects the render!


I see you are using shader to RGB in the materials. What do the shadows look like without it? I think it would be easier to see what’s happening if the shadows were in their most pure form.

If you think the contact shadows are causing issues, have you tried disabling them to see the difference? The settings are on the light source.

2 Likes

Thannnks! I didn’t know there was a contact shadow parameter on the light source! So I disable it on all the lights, and there is no more shadow glitching HOUUURAY!

Thank you veeeerry muuch! :star_struck: I’m gonna be able to move forward now! AND thanks to you I looked into material overide to be able to see the lights without all my shaders and it really makes the work easier.

I’ll post the photo of the option for whomever reads this in the futur

1 Like

Well the contact shadows can still be useful but you need to know how to use them.

The shadows in Eevee are done using textures, which means they have a limited resolution. This can cause a small gap between objects and their shadows.

This is what the contact shadows are for, bridging that small gap. For this reason, the distance and thickness settings should be kept only at a few centimeters, nothing more than what’s needed.

Contact shadows are a screen space effect. Unlike the main shadows, they aren’t made of textures, but are rather added to the image after it’s rendered. Eevee will try to guess where shadows should be based on what’s visible on screen. The result is accurate to the pixel, but doesn’t use what’s outside the render or hidden behind an other object.

Eevee has multiple screen space effects like this. In the render settings, you will find the “screen space reflections” and “ambient occlusion” features. They render quicker than the Cycles equivalents, but you have to be aware of their limitations and that they can get glitchy if you try to push them too far.

1 Like

Thanks a lot for this explanation! I’ll have to go in and try different stuff to see what works best especially for camera that has animation, on a still image it’s okay to play with the glitches and work around but if my shadows start “clipping” during motion it’s going to be weird…
I’ll go and find some tutorials and see how people do it :smiley:

Still got a loooooooong way to go haha

1 Like