toonshader in unity

Upload: andreiporfireanu

Post on 26-Feb-2018

226 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/25/2019 ToonShader in Unity

    1/13

  • 7/25/2019 ToonShader in Unity

    2/13

    Theory

    Toon a.k.a cel shading is a non photorealistic rendering technique

    Makes the 3D models appears in a style of cartoon, comic, hand-drawing.

  • 7/25/2019 ToonShader in Unity

    3/13

    Stylized Specular Highlights

    Plane white specular highlights with sharp boundaries

    Compute the specular reflection term of the Phong shading modeland set a threshold. If greater than the threshold, set thefragment color to the specular reflection color times the(unattenuated) color of the light source.

  • 7/25/2019 ToonShader in Unity

    4/13

    Stylized Diffuse Illumination

    The diffuse illumination is stylized, consists of very few colors(depending on the number of cuts)

    Set a threshold for the diffuse reflection term of the Phongreflection model. For example, when threshold is

    0, use the full diffuse color, no unlit color

    1, use full unlit color, no diffuse color0.5, half diffuse, half unlit

    Anything in between = a combination of diffuse and unlit

  • 7/25/2019 ToonShader in Unity

    5/13

    Characteristic Outline

    Has outlines of specific color (usually black) along the silhouettes ofthe model

    The outline is made from the model in question but scaled upwards,rendered in a single color, and it always shows on top of everythingexcept the object it is outlining.

  • 7/25/2019 ToonShader in Unity

    6/13

    Standard shader vs Our toon shader

  • 7/25/2019 ToonShader in Unity

    7/13

    Shader Properties

  • 7/25/2019 ToonShader in Unity

    8/13

    First Pass of the Shader:struct vertexInput/vertexOutput

  • 7/25/2019 ToonShader in Unity

    9/13

    First Pass of the Shader:Vertex shader

  • 7/25/2019 ToonShader in Unity

    10/13

    First Pass of the Shader: fragment shaderAttenuation (directional light vs spotlight)

  • 7/25/2019 ToonShader in Unity

    11/13

    First Pass of the Shader: fragment shaderSet colors and return fragmentColor

  • 7/25/2019 ToonShader in Unity

    12/13

    Second Part of the Shader: Outline

  • 7/25/2019 ToonShader in Unity

    13/13

    Questions?

    Thank you for your attention!