WIP Video (VERY early) + Rim Light Shader

Test Scene :



http://img819.imageshack.us/img819/9569/shotone.png

http://img862.imageshack.us/img862/1044/shottwo.png

http://img7.imageshack.us/img7/8624/shotthree.png



Performance:

not sure. When doing the above tests, the frame rate did change between light on or off.



Some Possible Uses :

Highlighting objects :: door knobs, chests, weapons ect… good for ‘picking’

works well in cartoon looking scenes to brighten edges

can be used for velvet effects.

great for xray effects



I have simply added a few lines to standard Lighting shader, so I will try and show what I did. Im not really sure the best way to share my code so I will just show all the changes I have made as best I can, and if someone could please halp advise me the best way to go from here :slight_smile: I’m sorry if this is in the wrong place or is unclear.



Common/MatDefs/Light/Lighting.j3md

[patch]

// the env map is a spheremap and not a cube map

Boolean EnvMapAsSphereMap

+

  • Color RimLighting;

    +

    }

    Technique {

    [/patch]



    [patch]

    USE_REFLECTION : EnvMap

    SPHERE_MAP : SphereMap

    +
  •        RIM_LIGHTING : RimLighting<br />
    

}

}

[/patch]



Common/MatDefs/Light/Lighting.vertfrag

[patch]

uniform ENVMAP m_EnvMap;

#endif

+

  • uniform vec4 m_RimLighting;

    float tangDot(in vec3 v1, in vec3 v2){

    [/patch]

    [patch]

    #endif

    gl_FragColor.a = alpha;

    +
  • #ifdef RIM_LIGHTING

    +
  • vec4 rim = pow( 1.0 - dot( normal, vViewDir.xyz ), 1.5 ) * m_RimLighting * m_RimLighting.w;
  • rim.a = 0.0;

    +
  • gl_FragColor += rim*diffuseColor;
  • #endif

    }

    [/patch]



    Usage

    usage is pretty simple …

    [java]float red = 0.0f;

    float blue = 0.0f;

    float green = 1.0f;

    float power = 0.5f;

    mat.setColor(“RimLighting”, new ColorRGBA(red,green,blue,power));[/java]



    The RimShader is a Color, alhpa is used as the “power”, the higher the power the greater the effect. power must be > 0.



    There is room to add some more customization to the appears by passing in a bias and additional power. There is probably plenty of room for optimization as well.
4 Likes