Unity Community |
The problem with this is that when you do it you are doing 'hand coded' sorting. This is okay if you can guarente that something will ALWAYS be drawn behind something else. But for many / most situations this is not the case. Some examples of where it might be applicable are water, when things in the water will always be drawn BEFORE the water surface (provided you are not in the water volume looking up). It's a painful situation and unity does not seem to sort non transparent queues.the grab pass can technically be rendered whenever you want but doing so prior to the transparent queue doesn't make any sense as it will lack foliage etc on terrain then among many other things.
Also, that shadows don't work on such surfaces is rather common, you won't find many engines that offer shadow drop onto water for example, especially none that don't cost your soul or corresponding amounts in $$$
As for the refraction mask: could be a bit tricky but technically you could potentially use a second camera to render such a mask texture through rendertexture to then use in your real shader for example.
Last edited by Tim C; 11-16-2010 at 02:38 PM.
Have you tried the Strumpy Shader Editor?
Such situations are where usage of scripting to dynamically adjust the queue trigger in to keep it alive.
Its not that common to have combined grab passes as most people prefer to have realtime FPS![]()
I can just imagine how slow that would be to execute... so many ray casts and bounds checks... or a quadtree or volume structure. Blegh.
Have you tried the Strumpy Shader Editor?
agreed.
Though such complicated environments don't exist. At least not if you had the target of gaming or realtime as that will never work without raytracers, having multiple dependent refractive transparent surfaces and alike.
as long as it remains in realistic borders there is an alternative way that potentially works: use distinct cameras that you restrict near - far wise to the distance of the refractive transparent surface and let them render to render texture and then create shaders that build upon these data + what they see on their camera. This could potentially work
Stramit, I asked this question some pages ago. It's fairly simple, and if you have time to answer, this shader noob would greatly appreciate it.
I've been trying to setup my own skybox shader that blends between 2 cube maps. The shader works fine on a mesh but does not work as a skybox material. Any hints?
I know this could easily be done in Shaderlab but I'm just trying to learn your awesome tool. =)
I'll have a look tonight for you Loken. So you are talking about when you actually hook it up into skybox (i.e the camera skybox or the scene skybox. Not just a box you have in the scene?)
Have you tried the Strumpy Shader Editor?
Yeah, I'm using the Camera Skybox rendering component.
Thanks for the quick reply!
Hi loken. Skyboxes are a special case and they do some interesting stuff in the back end. Because of the way they are done they are not supported in the current release, but I have made changes in the code base which will fix them up for 3.1. Thanks for pointing this out to me.
In 3.1 this is how you would do a skybox shader. Note you still use the UV not the normal. This is because unity passes the correct vertex skybox normals via the UV channels.
![]()
Have you tried the Strumpy Shader Editor?
If I have missed any questions that have been asked over the past few days I am sorry. Post them again now and I will see what I can do.
Have you tried the Strumpy Shader Editor?
I had a feeling they were a special case.
Thanks again, really appreciate it!
Stramit I sent you a PM with 2 nodes.
hmm...i guess you guys right about this.. even in the newest COD series they still had false refraction for they're water shader.agreed.
Though such complicated environments don't exist. At least not if you had the target of gaming or realtime as that will never work without raytracers, having multiple dependent refractive transparent surfaces and alike.
as long as it remains in realistic borders there is an alternative way that potentially works: use distinct cameras that you restrict near - far wise to the distance of the refractive transparent surface and let them render to render texture and then create shaders that build upon these data + what they see on their camera. This could potentially work
Well with grab pass limitation, this is as far as i get then...
If you look at games like bioshock rea they manage to do this type of refraction. The trick seems to be to use a very small distortion offset in the shader so that it minimizes the foreground objects leaking into the distortion (Have a look at the windows in that game looking out into the water) and it might give you some ideas.
Have you tried the Strumpy Shader Editor?
hmm....i think you're right....somehow i remember reading their water tech somewhere.....If you look at games like bioshock rea they manage to do this type of refraction. The trick seems to be to use a very small distortion offset in the shader so that it minimizes the foreground objects leaking into the distortion (Have a look at the windows in that game looking out into the water) and it might give you some ideas.
well i'll see what i can do...
The limitation is gotten around by various things. I'll copy this verbatim from a Crytek prentation called "Crysis Next Gen Effects" by Tiago Sousa:
- Use current back-buffer
- Mask out everything above water surface
- Water Depth > World Depth = leaking - disallow refraction texture offset for this case
http://crytek.com/cryengine/presenta...xt-gen-effects
You might be able to do that in unity actually. Batch the distortion pass into transparent (even if you have zwrite on / no transparency). Grab the current pixel z depth and compare to the one from the depth buffer.The limitation is gotten around by various things. I'll copy this verbatim from a Crytek prentation called "Crysis Next Gen Effects" by Tiago Sousa:
- Use current back-buffer
- Mask out everything above water surface
- Water Depth > World Depth = leaking - disallow refraction texture offset for this case
http://crytek.com/cryengine/presenta...xt-gen-effects
Anyways here is an example of a distortion effect. What you need to do is have offsets centered around 0. So an offset ranges from -1 -> 1. If you want to get fancy normalize to grab texture dimensions ect, but I am not doing that here. The normalization means that the foreground objects will not leak very much, just a small frill around the edges.
Note the inclusion of the unpack normal to convert into [-1, 1], this means you need an offset texture encoded this way (for my testing I just used a normal map I had handy)
Here is an extreme example (I would never use this much in a real game). Notice the foreground cube is preserved, but there is some leakage into whatever is in the background.
Here is a more realistic example (looks good in motion as well), some small frills.
![]()
Have you tried the Strumpy Shader Editor?
Have you tried the Strumpy Shader Editor?
hey Stramit i sent you a PM, can you check it?