Sunday, December 2, 2012

New Job.. I hope I never leave.

I've been at  Kixeye  for about a month now..... and I love it. For starters I get to work with amazing people that have had years of experience in the industry. People like ex Blizzard, Pixar, Disney....etc. I never feel left out and it's such a weird feeling having people appreciate the little things that you do. At my old company I was promised pay... and it never came. On top of that I had to work late to crunch for a paycheck that I would haven ever receive. At Kixeye I really do appreciate the pay, but in all honesty this companies philosophy about creating games is game development at it's purist form. I don't feel corrupted, nor do I feel like I'm creating a copy of a game. I enjoy the product that I am producing, and I wish that all companies shared this passion.

I LOVE MY JOB!

Wednesday, October 3, 2012

Thing 2..

~this .. thing... I need to practice some more~

Getting back into drawing a monster a day...

~Say hello to Meh.~

Friday, May 4, 2012

Thursday, April 26, 2012

Day 3 (Surface Shaders)

Wohoo, really tired right now but I am committed to completing these 7 days.

Writing Surface Shaders
Surface shaders in Unity is a gcode generation approach that makes it much easier to write shaders using low level vertex/pixel shader programs. The code just generates all the repetitive code that it would have to be written by hand.  (can be written in CG/HLSL)

Here is how it works

1) Define a surface function that takes in any UVs or data you need as input and fills in output structure SurfaceOutput. SurfaceOutput basically describes properties of the surface. (can be written in CG/HLSL) The shaders compiler then figures out what inputs are needed, what outputs are filled, then generates actual vertex&pixel shaders, as well as rendering passes to handle forward and deferrend rendering.

Standard output structure of surface shaders is this:
struct SurfaceOutput
{
     half3 Albedo;
     half3 Albedo;
     half3 Emission;
     half Specular;
     half Gloss;
     half Alpha;
}

Surface shader compile directives should be placed in between
CGPROGRAM
and
ENDCG

For more information reference here Surface Shaders

Wednesday, April 25, 2012

ShaderLab Day(2) (Passes)



Day 2 learning all of this stuff, just as a recap of what I did the yesterday

I have learned about Properties and how they should be implemented.
Syntax
Properties
{
     Available parameters
     Float, Color, Vector, Range, 2D, Cube, and Rect
}
Subshaders are essentially used for rendering and it is required for the graphics card to read all of passes that make the shader what it is.

OKAY so new lesson today..

PASSES
The Pass block causes the geometry of an object to be rendered once.
Syntax:
  • Pass
    {
         [Name and Tags] Reference: Name and PassTags
         [RenderSetup]
         [TextureSetup]
    }
This basic pass command contains an optional list of render setup commands, optionally followed by a list of textures to use

Name and Tags:
A pass can define it's Name and arbitrary number of pass tags - name/value strings that communicate Pass intent to the rendering engine

Render Set up
A pass sets up various states of the graphics hardware, for example
Should alpha blending be turned on?
Should fog be used?
Here are the possible components that can be used:
  • Material { Material Block }
    Defines a material to use in a vertex lighting pipeline. 
    • Materials include:
      • Diffuse Color
        Object's base color
      • Ambient Color
        The ambient color component. This is the color the object has when it's hit by the ambient light set in the RenderSettings!
      • Specular color
        The color of the object's specular highlight
      • Shininess Number
        The sharpness of the highlight, between 0 and 1. At 0 you get a huge highlight that looks a lot like diffuse lighting, at 1 you get a tiny speck.
      • Emission Color
        The color of the object when it is not hit by any light
    • Examples can be found here  Materials
  • Lighting ON | OFF
    Turn vertex lighting on or off. 
    Reference: Materials
  • Cull Back | Font | Off
    Set polygon culling mode.
  • ZTest ( Less | Greater | LEqual | GEqual | Equal | NotEqual | Always)
    Set depth testing mode
  • ZWrite ON | OFF
    Set depth writing mode.
  • Fog { Fog Block}
    Set fog parameters.
  • AlphaTest  ( Less | Greater | LEqual | GEqual | Equal | NotEqual | Always CutoffValue
    Turns on alpha testing.
  • Blend SourceBlendMode DestBlendMode
    Sets alpha blending modes:
    SourceBlendMode
    DestBlendMode
  • Color Color value
    Sets color to use if vertex lighting is turned off
  • ColorMask RGB | A | 0 | any combination of R, G, B, A
    Set color writing mask, Writing ColorMask 0 turns off rendering to all color channels
  • Offset OffsetFactor, Offset Units
    Set depth offset. Note that this command intentionally only accepts constrants
    (Not really sure what this does yet... )
  • SeparateSpecular ON | OFF
    Turns separate specular color for vertex lighting on or off 
  • ColorMaterial AmbiendAndDiffuse | Emission 
Texture Setup
After the render state setup, we want to specify a number of textures and their combining modes to apply using SetTexture commands:

SetTexture 
texture property {[combine options]}
The texture setup configures fixed function multitexturing pipeline, and is ignored if custom fragmend shaders are used. Reference: Custom Fragment Shaders


Details:
Per-pixel Lighting
The per-pixel lighting pipeline works by rendering objects in multiple passes. Unity renders the object once to get ambient and any vertex lights in. Then it renders each pixel lighting affecting object in a separate addictive pass. Reference: Rendering Pilepine



Per-vertex Lighting
Per-vertex lighting is the standard Direct3D/OpenGL lighting model that is computed for each vertex. Lighting On turns it on. Lighting is affected by Material ColorMaterial and SeparateSpecular commands.


There are other variations of passes that are similar to the Pass command but different.


UsePass
The UsePass command uses named passes from another shader.
Syntax
UsePass "Shader/Name"
This inserts all passes with a given name from a given shader. Shader/Name contains the name of the shader and the name of the pass, separated by a slash character


Some of the shaders could reuse existing passes from other shaders, reducing code duplication. For example, in most pixel lit shaders the ambient or vertex lighting passes are the same as in the corresponding VertexLit shaders. The UsePass command includes a given pass from another shader.
Example:
UsePass "Specular/BASE"

Name "MyPassName"


Tuesday, April 24, 2012

ShaderLab: Day 1 (Properties & SubShaders)

For the next 7 days I will be blogging about my ShaderLab findings,

PROPERTIES
Shaders can define a list of parameters to be set by the artists in the material inspector.

Syntax:there are a only few things I need to look out for when setting up properties:
  • When setting up Properties you begin the section with:
    Properties
    {
           Property [Property]
    }
  • Some of the properties that you can include are as follows:
    • name = variable Name that is used in code
    • display name = the name that is showed in the inspector
    • name( "display name", Range (min, max)) = number)
      • example: _WaveScale("Wave scale", Range(0.02, 0.15)) = 0.07
        // sliders default is 0.07
    • name("display name", Color) = (number, number, number, number)
      • example: _RefractionColor("Refraction Color", Color) = (0.34, 0.85, 0.92,1)
        // this is a color, where the last value is the alpha color
    • name("display name", 2D) = "name"{ options }
      • example: _Fresnel{"Fresnel (A)", 2D) = "" { }
    • name("display name", Rect) = "name" {options}
      • example: _ReflectiveRect( "Reflective Rectangle, Rect) = "" { }
    • name("display name", Cube) = "name" {options}
      • example: _CubeMap ("Cube Map", Cube) = "" { }
    • name("display name", Float) = number
      • example: _RippleFrequency( "Ripple Frequency", Float) = 2.0
        //2 is the default value
    • name("display name", Vector) = (number, number, number, number)
      • example: _InfluenceVector("Influence Vector", Vector) = (0.2,0.0,0.0,1.0)
    • *Special Note: in the options field -> { options } here are the available options
      • TexGen texgenmode -> Automatic texture coordinate generation mode
        for the texture. TexGen is ignored if custom vertex programs are used.
      • LightmapMode -> Texture will be affected by pre-renderer lightmap parameters.
        That is, the texture to use can be not  in the material, but taken from the settings of the Renderer instead.
SUBSHADERS

Each shader in Unity consists of a list of subshaders. When Unity has to display a mesh it will find the shader to use and pick the first subshader that runs on the user's graphics card.

Syntax:
  • SubShader
    {
         [Tags] [CommonState] Passdef [Passdef.. ]}
         //defines the subshader as optional tags, common state and a list of pass definitions
    }
A subshader defines a list of rendering passes and optionally setup any state that is common to all passes. Additionally, subshader specific Tags can be set up. All tags can be found here: TAGS. When Unity chooses which subshader to render with it renders the object once for each Pass defined. As each render of the object is an expensive operation. The shader must be defined in the least number of passes possible. Sometimes on some graphics hardware the needed effect can't be done in a single pass.