

















































Studia grazie alle numerose risorse presenti su Docsity
Guadagna punti aiutando altri studenti oppure acquistali con un piano Premium
Questa pagina non è visibile nell’anteprima
Non perderti parti importanti!


















































SPECIAL EFFECTS WITH DEPTH
The talk is about simple and effective techniques, that can be quickly implemented based on the data (easily) available to Unity developers.
Ok, so here we see a lightmapped scene (running deferred), so let's just define "special effects", for the purpose of this talk, as the result of this image...
... subtracted from this image. This results in...
Let's talk about various buffers that are available in Unity, which are either part of the rendering or can be easily created.
Where does the nonlinearity come from? The input to the vertex shader is the object space position of the vertex (v.vertex, POSITION semantic). The output of the vertex shader should be the position of the vertex in clip space. This is the space where things outside of the viewing frustum get clipped. Typically you multiply v.vertex by the model-view-projection matrix in one go. Multiplying by the model matrix places the object in the world. Multiplying by the view matrix makes the position relative to the camera. Multiplying by the projection matrix projects th vertex on the near clip plane, resulting in a value in clip space.
The normals buffer is a natural product of the deferred lighting pipeline. It stores world space normals in .xyz components. In the .w component it stores shininess. Just sample it and move back into the [-1;1] range.
And of course you have access to the color buffer as well. You can request it via GrabPass and then access the texture as _GrabTexture in the shader. Or you can use camera.OnRenderImage callback. The incoming image is the source render texture. The result should end up in the destination render texture. When there are multiple image filters attached to the camera, they process the image sequentially, by passing first filter's destination as the source to the next filter. You write to the destination render texture by using Graphics.Blit with a specific material. The source image is then accessible in the shader as _MainTex.
All of the examples we are showing run in the vanilla Unity 3.4 (probably 3.3 etc as well, no voodoo required)
We are not going to show the traditional depth/normals based effects such as SSAO, depth of field, etc. but talk about more unusual scenarios…