12 agosto 2013

Skin Shader for Unity (Iteration 2)

IBL support and seams fix attempt (still not perfect at all)

The main improvements are not in visuals, but in the "system". Now is 100% automatic. The setup is simple, setup the shader and add the script, thats all. Before, I had to setup an extra camera manually, but adding some lines, it can be done without human interaction :) 
Also, the object should be set in a new layer to avoid rendering anything else:

GameObject go = new GameObject ("Camera_RTT", typeof(Camera), typeof(Skybox));
Camera_RTT = go.camera;
Camera_RTT.enabled = false;
Camera_RTT.hdr = true;
Camera_RTT.cullingMask = (1 << SSSobject.layer);
Camera_RTT.backgroundColor = Color.black;

While updating:

   Camera_RTT.transform.position = Camera.main.transform.position;
Camera_RTT.transform.rotation = Camera.main.transform.rotation;
Camera_RTT.fov = Camera.main.fov;

Another interesting idea is doing the blur iterations in a loop to avoid duplicating text and making it customizable:

   RenderTexture.active = RTTBlur_H;
Graphics.Blit (RTT, RTTBlur_H, BlurMaterial_H, 0);

for(int i=0;i<iterations;i++)
RenderTexture.active = RTTBlur_V;
Graphics.Blit (RTTBlur_H, RTTBlur_V, BlurMaterial_V, 0);

RenderTexture.active = RTTBlur_H;
Graphics.Blit (RTTBlur_V, RTTBlur_H, BlurMaterial_H, 0);

RenderTexture.active = null;

No hay comentarios:

Publicar un comentario