Hi,
First post on the forum, Super impressed with everyones work, very inspirational.:)
I'll post some pics as soon as i get attachment rights. In the meantime If you would like to see the shaders and assets you can go here
Unity Shader Project
Theres a couple of videos there as well.
Cheers,
0brn0
Replies
The complex surfaces are done in multiple passes with captures of the frame buffer used to create the reflection and refraction. They are both done with a screen spaced technique, where the surface normal is used to create a UV offset from the surfaces screen space position.
Many of the transparent surfaces are also Zprimed to clean up any draw order issues.
If you look carefully at the video you will notice that only the closest Backface & closest Front face of any surface are rendered.
The shader tackles light and color differently to most shaders. Instead of adding the reflection to the diffuse light contribution. I replace the diffuse term with reflected light . Im following the theory that the surface can only be as bright as its light source. So if the light is being reflected back in a specular fashion then the same percentage of light has to be removed from the diffuse term. This enables the surfaces to handle extreme lighting conditions without appearing to blow out to white. And at the same time make white and Chrome surfaces much easier to handle. With the method I'm using its possible to achieve a "black reflection" ( a technically bad description ) But the best example I can give is if you stand in front of a mirror with a matt black shirt on no matter how bright the light source is the reflection of the shirt in the mirror is also black.
The way I'm doing the metallic reflection also differs from the normal method. The standard method is to multiply the reflection by the diffuse color to achieve a metallic look. I lerp between an untinted reflection and a tinted one based on luminosity and a metallics property like this
Reflection = lerp (CubeTex.rgb, CubeTex.rgb *_Color.rgb, (1-ReflectiveLum) *_Metalics);
The calculation above can be done without the 1- but the compiler was smart enough to work that out for itself, or so stupid that when I did it without the 1- it used the same number of instructions anyway
The result of this means that I can still get white reflections in metallic surfaces but as they get darker more of the diffuse tint becomes visible. And by changing the metallics property which is exposed to the user you can get every variation in between.
I also vary the Alpha of the surface by the luminosity of the reflection. This ensures that reflections on transparent surfaces are handled properly.
Creating art for the shader is quite straight forward. The only tricky part is the combined Spec/Gloss/Reflection mask texture (RGB). But it does allow for greater control.
If you want to play around with the shaders there is a free vesion on the unity asset store.
@fingus, binopittan,Peris & Maph , Thanks guys I put allot of time into these shaders I'm glad you like them.
i am doing some shader coding by myself.
i am really interested in the screen space reflection technique! i have done some ssao or ssaa but this is new for me. do you got any whitepapers or something like this describing this technique.
I don't know of any white papers on screen spaced reflection. But if you look up Screen spaced refraction you can find find many papers dating back as far as 2005 "Interactive Image-Space Refraction of Nearby Geometry Chris Wyman University of Iowa" is a good one to start with. If you get a refraction going you will have all the inputs and information you need to generate a reflection also.
Im a little hesitant to say "this is the way I did it, and the way you should to " because to be honest my method dosen't follow physically accurate maths. The criteria I set out on when I did it were based on making the result intuitive to the user and as simple as possible for the GPU. I based my shader visually by observing lights behavior on a bag of marbles and some glass kitchen ware.
I found approaching the shader this way I was able to eliminate many behaviors that were not noticeable to the human eye and focus on the ones that were.
If you send me a private message I'd be quite happy to explain the inner workings in more detail. Other wise this post will turn into a white paper
Cheers
0brn0