Replace/improving the built-in cascaded shadow mapping shader

Hi, I have activated the soft shadows for my directional light but they don’t look good as they could be. I want to improve them with a rotation of the sampling pattern, but I’m not sure how to access Unity’s built-in shadow mapping shaders.

In the .zip file of the built-in shaders provided on the Unity website, I have found a shader called “Internal-PrePassCollectShadows.shader” which seems to be the original shader that I need to modify. However, I have no ideia how to replace the built in shader by the modified version and whether if it will work for both deferred and forward rendering.

Could some one provide advice? Thanks in advance.

Anyone?.. please?

to replace the built in just drop this one into the project
as it will be handled later than the integrated one it will overwrite the integrated one (shaders are refered to by their name and you overwrite has the same as the internal one)

thats how the terrain shaders were replaced since U2 :slight_smile:

Thanks for the tip, I’ve tried that but no matter what I do, I can’t get my modified version of a built in shader to override the built in one.

For instance, if I add the “Normal-Diffuse.shader” file to the project and modify it, the changes have no effect.

Could you provide more instructions on how to perform the override?

Its not about the file, its about the defined name of the shader at the beginning

dreamora is not actually correct. While this trick of “drop in your own shader to replace built-in ones” works in some cases (like Terrain), it does not in other cases. At the moment you can’t override the shader used for shadowmap blurring. I’ll see if I can make that happen for next release.

bump
Any news on whether this will happen in 3.2 ?

Aras has said we’ll be able to define a custom shadow blur shader in 3.2 (Yay!) but I don’t think we’ll be able to completely replace the shadowing system with shaders.

That’s nice, I noticed that the shadow blur filter is in the Built-in Shaders package. So I assumed that it was possible to replace it.
But I’m trying to find a workaround for the bug that shadows, SSAO and most other shaders are broken when you use non-standard projection matrices.
So this isn’t helpful in my situation.

Could you also expose the distances of the different cascade levels too Aras? To get crisp shadows currently, we have to set the shadow distance to be about 20-30mts when we really need them at 200mts. If we could set the first cascade level to be 5mts then it would solve most of the problems even with 4 cascade levels

assumed that it worked for all those shaders where the sources are provided by the built-in shaders as it makes not that much sense to have the source if you can’t alter it at least to me, sorry for missinformation there from my end then.

Bump this~ we should also get some access to a specific shadow map, maybe expose this as Light.shadowmap or some thing similar.

Is this possible to replace unity shadows now?

No… to replace them, you’d have to replace the whole Unity’s rendering process… which is what I’m working on, by the way.

Have you started a thread about this as I would like to follow your progress :slight_smile:

No… not yet. There’s not much to look at anyways as it’s still quite early in development. I just made point light shadows work today. What’s strange is that with comparable quality, they render three times as fast as Unity’s!

EDIT: Yep… seems like Unity is overrating the resolution a bit :wink:

I would like to see your progress too, this means you can add area lights too right? And you could apply ambient occlusion with the ambient light like how its supposed to be? So many possibilities I would love to see what can be done, maybe even turn it into an open source kinda thing where everyone chimes in and see what we can do to improve the quality and rendering in Unity! :grin:

Vast majority of things can be implemented, yes. There are several places you can apply ambient occlusion… ambient light, near lightmaps and other forms of GI is the correct place, you have to use the good old darkening if you don’t have any of these. But yeah, that would definitely be an option :slight_smile:

There’s still a long way full of surprises to the release, but I imagine I’d release one free (or very cheap) open-source version with only the basic stuff in it that you can modify to your hearts desire and then possibly sell it on the store and one paid version with all the fancy features.

I’ll make a thread for this once I can get the shadows to filter properly (probably going for ESSM)… turns out it’s not a trivial thing to do with cubemaps.

I’d definitely like to see some sort of correct softening of the shadows over distance like this. http://freesdk.crydev.net/display/SDKDOC4/Shadows+in+CryENGINE

Well, me too! Sorry it takes so long… these days have been quite lazy for me.