Jump to content
Posted 06 August 2011 - 05:03 PM
Posted 07 August 2011 - 03:15 AM
float attenuation = 1 - saturate(distanceBetweenPixelAndLight / lightMaxRange); // Simple linear fall-off float3 diffuse = saturate( dot( pixelNormal, lightVectorToPixel ) ) * lightDiffuseColor.rgb * attenuation; float4 albedo = tex2D( albedoTex, uv ); // Get the texture of the sprite, platform, or whatever you are rendering resultColor.rgb = albedo * diffuse; // .. And maybe add some more effects such as ambient or specular resultColor.a = albedo.a; // In case the texture contains an alpha mask for transparencyTo get some better performance (with many lights), you can also think about using a deferred rendering engine, or try to find out which parts of the screen are affected by which lights, rather than simply drawing the whole thing again for each light.
Posted 07 August 2011 - 03:59 AM
Posted 07 August 2011 - 06:21 AM