At any case here's the code:

Code: Select all

```
//===========================================================================
//
// Doom lighting equation exactly as calculated by zdoom.
//
//===========================================================================
float R_DoomLightingEquation(float light)
{
float TotalLight = light * 255.0;
//Spooky house Light Equation
float lightscale = 1.0;
//light/33 should be 4 whe light is 130
float MaxFullLightDist = (TotalLight/33) * TotalLight;
float tmp=0;
if(TotalLight > 0){//sector light is zero so there'll be no light
if(TotalLight == 255){ //if the sector is full light, it'll always be full light
lightscale = 0;
}
else if(pixelpos.w < MaxFullLightDist){ // if the pixel is before the full bright limit, make this pixel full bright
tmp = min(pixelpos.w / 10.0, 64.0 + MaxFullLightDist + (TotalLight/10));
tmp = (tmp / (64.0 + MaxFullLightDist + (TotalLight/10) ) )* 10 ;
// tmp = int(tmp);
lightscale = clamp(tmp, 0 ,1.0);
// lightscale = 0;
}
else{
tmp = min(pixelpos.w / 10.0, 64.0 + MaxFullLightDist + (TotalLight/10));
tmp = (tmp / (64.0 + MaxFullLightDist + (TotalLight/10) ) )* 10 ;
// tmp = int(tmp);
lightscale = clamp(tmp, 0 ,1.0);
}
// lightscale = clamp(( min(pixelpos.w * L , 76500.0)) / 76500.0, 0.0, 1.0);
}
return lightscale;
}
```