Hi, I want to implement my custom shadows maps for unity. I’m not a expert in the shaders field, but reading the technique of shadows maps I have an Idea of the algorithm
my question is : how can i keep the depthbuffer viewed from the light (sun or spot), then apply this to the scene, rendering through the camera?? I need a shader?
Going crazy is a natural part of the process, it is good for you ;). (My imaginary lawyers are telling me to point out it is not)
If I’m reading your post correctly: Yes, you could generate the depth maps for the lights by rendering the scene from those positions with a camera, either using the zbuffer that it can generate automatically, or by rendering the entire scene with normal map generating shaders yourself.
But there is a good reason why it is built into the Unity engine, because it’s a complex system that you can - and want to - reuse for multiple projects. Which is the entire point of a game engine. Not only does Unity handle shadow mapping for you, and manage which lights should cast shadows, it also lets you have multiple Levels of detail at the same time (by applying the concept of cascaded shadow maps), to better balance performance and visual quality.
But if you want to implement custom shadow maps for the educational aspect, you should definitely check out this Cg tutorial. In fact, all those tutorials are definitely worth at least looking at a few times(You might want to start at the start though).
Hi Thanks for reply, it was helpful! My imaginary layers are telling me the same . definitely i’m going to learn CG, the thing of this post is, that I don’t know how to put the light into the shader, in the cg program (after reading the nvidia cg tutorial web)
that’s funny,I just did that few days ago, with the help of the guy on up_upstairs, sorry about my poor english .the depth map is easy to get,use render to texture(pro) but it is not easy to compare them in the same space