0

I am trying to convert a post processing vignette into a decent torchlight effect and have the centre position brighter instead of the dark edges now but unable to work out depth buffer so as to get depth adjustments. Can anyone help me with this ??

My code is in HSLS (Dx9) and this is what I have (based off CopperCube game engine - irrLicht) as extra bits of post processing code to the main vertex and pixel shader.

Seems to be a problem with my calculation of ‘lightDistance’ as works in a flat but correct way when I remove it - not with it added as below:

const char* POSTPROCESS_SHADER_VIGNETTE_D3D =
your text`"sampler2D tex0 : register(s0);
float4x4 mWorld; // world matrix
float PARAM_Vignette_Intensity;
float PARAM_Vignette_RadiusA;
float PARAM_Vignette_RadiusB;
float4 pixelMain( float2 TexCoord : TEXCOORD0, float4 Position : POSITION) : COLOR0 {
const float centerX = 0.5;
const float centerY = 0.5;
float4 col = tex2D( tex0, TexCoord );
float e1 = ( TexCoord.x - centerX ) / ( PARAM_Vignette_RadiusA );
float e2 = ( TexCoord.y - centerY ) / ( PARAM_Vignette_RadiusB );
float3 camPos = float3(0,0,0);
// just for testing for now - later will be correct camera position
float3 camToLight = camPos - float3(Position.xyz);
float objDistance = length(camToLight);
float lightDistance = (1.0 / objDistance) * 0.25;
float distanceFromCentre = clamp(2.0 - ((e1 * e1) + (e2 * e2)), 0.0, 1.0);
return col * (1.0 + (PARAM_Vignette_Intensity * distanceFromCentre)) * lightDistance);`

Is not "Position" the world position of each vertex and thus should work ?

0 Answers0