<< CODE SAMPLE PAGE UNDER CONSTRUCTION>>
Edge Light
An edge light is a deferred light that only illuminates the edges of objects. This effect fit in very nicely into my game Dischord to help us give the "Tron Like" look that our artists were looking for.
float4 calculateEdgeLight(EdgeLightPixelInput input) { //Edge Lights //Width of edgelight in pixels int offset = 1; int3 offsetUp = int3(offset,0,0); int3 offsetDown = int3(0,offset,0); int3 pixelPosition = int3(input.position.xy, 0); //Sample normals in each direction from the normal buffer float3 centerNormal = NormalTexture.Load(pixelPosition).xyz; float3 rightNormal = NormalTexture.Load(pixelPosition + offset3).xyz; float3 leftNormal = NormalTexture.Load(pixelPosition - offset3).xyz; float3 upNormal = NormalTexture.Load(pixelPosition + offset3u).xyz; float3 downNormal = NormalTexture.Load(pixelPosition - offset3u).xyz; //Use the dot product to serve as light strength float edgeStr = 0.0f; edgeStr += saturate(1.0f - dot(centerNormal, rightNormal)); edgeStr += saturate(1.0f - dot(centerNormal, leftNormal)); edgeStr += saturate(1.0f - dot(centerNormal, upNormal)); edgeStr += saturate(1.0f - dot(centerNormal, downNormal)); //scale intensity of the light with the lights strength finalColor.rgb = edgeStr * finalColor.rgb; return finalColor; }
I will pull a higher res image showing the edge light at a later time, but below is screenshot from our youtube trailer of the game showing the edge-lights effect on the cubes below it.