- updated shader programs

- fixed brightness shader
- fixing leifx shaders
- r_modelshader - enables the use of a new diffuse fragment shader for enhanced model shading
- shadespecular slightly regressed :(
- don't do libxmp for travis?
- disabled leifx gamma, seems redundant with actual gamma now
- more waterimage cruft removal. don't do this waterreflectrefract until we have fbos please
This commit is contained in:
leilei-
2015-01-26 05:01:46 -05:00
parent 05433b5c7e
commit f2c082017e
13 changed files with 255 additions and 169 deletions

View File

@@ -12,7 +12,7 @@ script: ./travis-ci-build.sh
before_install:
- sudo apt-get update -qq
- sudo apt-get remove -qq -y mingw32
- sudo apt-get install -q -y libgl1-mesa-dev libsdl1.2-dev libvorbis-dev libfreetype6-dev mingw-w64 libxmp-dev
- sudo apt-get install -q -y libgl1-mesa-dev libsdl1.2-dev libvorbis-dev libfreetype6-dev mingw-w64
notifications:
email: false

View File

@@ -1,4 +1,4 @@
// Color control shaders
// "LeiFX" shader - Pixel filtering process
//
// Copyright (C) 2013-2014 leilei
//
@@ -7,6 +7,8 @@
// Software Foundation; either version 2 of the License, or (at your option)
// any later version.
// GLSL-based color adjustment/control
// because xorg/x11/sdl sucks.
uniform sampler2D u_Texture0;
varying vec2 texture_coordinate;
@@ -17,24 +19,14 @@ uniform float u_CC_Gamma;
uniform float u_CC_Contrast;
uniform float u_CC_Saturation;
float erroredtable[16] = {
14,4,15,1,
8,12,5,10,
15,2,14,3,
6,12,7,11
};
uniform float u_ScreenToNextPixelX;
uniform float u_ScreenToNextPixelY;
void main()
{
gl_FragColor = texture2D(u_Texture0, texture_coordinate);
// Dither setup...
vec4 OldColor; // compare differences for amplifying a correctional dither...
float OldCol = 2.0f / 255;
int ditdex = int(mod(gl_FragCoord.x, 4.0)) * 4 + int(mod(gl_FragCoord.y, 4.0)); // 4x4!
// looping through a lookup table matrix
vec3 color;
vec3 colord;
int coloredr;
@@ -46,17 +38,11 @@ void main()
int yeh = 0;
float ohyes;
for (yeh=ditdex; yeh<(ditdex+16); yeh++) ohyes = erroredtable[yeh-15];
ohyes = floor(ohyes) / 24;
OldColor = OldCol; // reset oldcolor
// Overbrights
gl_FragColor *= (u_CC_Overbright + 1);
OldColor *= (u_CC_Overbright + 1);
gl_FragColor.rgb += (ohyes * OldColor.rgb); // dither this stage
OldColor = OldCol; // reset oldcolor
// Gamma Correction
float gamma = u_CC_Gamma;
@@ -64,9 +50,7 @@ void main()
gl_FragColor.g = pow(gl_FragColor.g, 1.0 / gamma);
gl_FragColor.b = pow(gl_FragColor.b, 1.0 / gamma);
OldColor.r = pow(OldColor.r, 1.0 / gamma);
OldColor.g = pow(OldColor.g, 1.0 / gamma);
OldColor.b = pow(OldColor.b, 1.0 / gamma);
gl_FragColor.rgb += (ohyes * OldColor.rgb); // dither this stage
//gl_FragColor += ((edge));
}

View File

@@ -10,6 +10,9 @@ uniform float u_CC_Brightness;
uniform float u_CC_Gamma;
uniform float u_CC_Contrast;
uniform float u_CC_Saturation;
uniform float u_ScreenToNextPixelX;
uniform float u_Time;
uniform float u_ScreenToNextPixelY;
void main()
{
scale=0.7;

View File

@@ -1,6 +1,6 @@
// LeiFX shader - Pixel dithering and reduction process
// "LeiFX" shader - Pixel filtering process
//
// Copyright (C) 2013-2014 leilei
// Copyright (C) 2013-2015 leilei
//
// This program is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the Free
@@ -8,6 +8,10 @@
// any later version.
// Dithering method from xTibor (shadertoy)
// New undither version
uniform sampler2D u_Texture0;
varying vec2 texture_coordinate;
uniform float u_ScreenToNextPixelX;
@@ -15,14 +19,20 @@ uniform float u_ScreenToNextPixelY;
uniform float u_ScreenSizeX;
uniform float u_ScreenSizeY;
// This table came from the wikipedia article about Ordered Dithering. NOT MAME. Just to clarify.
float erroredtable[16] = {
16,4,13,1,
8,12,5,9,
14,2,15,3,
6,10,7,11
};
// Rotated
#define DITHERAMOUNT 0 // adjust this to make the dithering more opaque etc
#define DITHERBIAS 0 // adjust this to make the dither more or less in between light/dark
void main()
{
@@ -31,9 +41,11 @@ void main()
vec4 what;
what.x = 1; // shut
what.y = 1; // up
what.z = 1; // warnings
float aht = 1.0f;
what.x = aht; // shut
what.y = aht; // up
what.z = aht; // warnings
vec4 huh;
// *****************
@@ -47,54 +59,24 @@ void main()
vec4 pe1 = texture2D(u_Texture0, texture_coordinate); // first pixel...
// *****************
// STAGE 1
// Ordered dither with lookup table
// *****************
int ditdex = int(mod(gl_FragCoord.x, 4.0)) * 4 + int(mod(gl_FragCoord.y, 4.0)); // 4x4!
vec3 color;
vec3 colord;
int coloredr;
int coloredg;
int coloredb;
color.r = gl_FragColor.r * 255;
color.g = gl_FragColor.g * 255;
color.b = gl_FragColor.b * 255;
int yeh = 0;
float ohyes;
// looping through a lookup table matrix
for (yeh=ditdex; yeh<(ditdex+16); yeh++) ohyes = erroredtable[yeh-15];
//ohyes = pow(ohyes, 0.92f) - 3;
ohyes = floor(ohyes) - 6;
colord.r = color.r + ohyes;
colord.g = color.g + (ohyes / 2);
colord.b = color.b + ohyes;
if (color.r == 0) colord.r = 0;
if (color.g == 0) colord.g = 0;
if (color.b == 0) colord.b = 0;
//if (color.r < colord.r) pe1.r = colord.r / 255;
//if (color.g < colord.g) pe1.g = colord.g / 255;
//if (color.b < colord.b) pe1.b = colord.b / 255;
pe1.rgb = colord.rgb / 255;
// *****************
// STAGE 2
// Reduce color depth of sampled pixels....
// *****************
{
vec4 reduct; // 16 bits per pixel (5-6-5)
reduct.r = 64;
reduct.g = 128; // gotta be 16bpp for that green!
reduct.b = 64;
pe1 = pow(pe1, what); pe1 = pe1 * reduct; pe1 = floor(pe1); pe1 = pe1 / reduct; pe1 = pow(pe1, what);
reduct.r = 32;
reduct.g = 64; // gotta be 16bpp for that green!
reduct.b = 32;
gl_FragColor = pe1;
pe1 = pow(pe1, what); pe1 *= reduct; pe1 = floor(pe1); pe1 = pe1 / reduct; pe1 = pow(pe1, what);
}
}

View File

@@ -1,13 +1,13 @@
// LeiFX shader - Pixel filtering process
// "LeiFX" shader - Pixel filtering process
//
// Copyright (C) 2013-2014 leilei
// Copyright (C) 2013-2015 leilei
//
// This program is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 of the License, or (at your option)
// any later version.
// New undither version
uniform sampler2D u_Texture0;
varying vec2 texture_coordinate;
@@ -16,13 +16,16 @@ uniform float u_ScreenToNextPixelY;
uniform float u_ScreenSizeX;
uniform float u_ScreenSizeY;
#define PIXELWIDTH 0.66f
#define BLURAMOUNT 0.5f
#define PIXELWIDTH 0.66f
#define FILTCAP 0.075 // filtered pixel should not exceed this
#define FILTCAPG (FILTCAP / 2)
void main()
{
vec2 px; // shut
float PIXELWIDTHH = u_ScreenToNextPixelX;
px.x = u_ScreenToNextPixelX;
@@ -30,40 +33,40 @@ void main()
// Sampling The Texture And Passing It To The Frame Buffer
gl_FragColor = texture2D(u_Texture0, texture_coordinate);
// A more direct port from the HLSL code i've written. Which rocks. Yeah.
float blendy; // to blend unblended with blend... trying to smooth the jag :(
float blenda;
float blendfactor;
vec4 pixel1 = texture2D(u_Texture0, texture_coordinate + vec2(px.x * PIXELWIDTH / 4, 0));
vec4 pixel1 = texture2D(u_Texture0, texture_coordinate + vec2(px.x * PIXELWIDTH, 0));
vec4 pixel2 = texture2D(u_Texture0, texture_coordinate + vec2(-px.x * PIXELWIDTH, 0));
vec4 pixel0 = texture2D(u_Texture0, texture_coordinate + vec2(0, 0));
vec4 pixelblend;
vec4 onee = 1; // because I can't just stick 1 in the GLSL dot function
float gary1 = dot(pixel1,onee);
float gary2 = dot(pixel2,onee);
float mean = 1.0;
mean = gary1 - gary2;
if (mean < 0) mean *= -1;
//if (mean > 1) mean = 1;
mean = pow(mean, BLURAMOUNT); // Adjust this value if you want to control the blur...
if (mean > 1) mean = 1;
vec4 pixeldiff; // Pixel difference for the dither check
vec4 pixelmake; // Pixel to make for adding to the buffer
vec4 pixeldiffleft; // Pixel to the left
vec4 pixelblend;
{
// variably BLEND IT ALL TO H*CK!!!!
blendy = 1 - mean;
blenda = 1 - blendy;
pixel0 /= 3;
pixel1 /= 3;
pixel2 /= 3;
pixelblend.rgb = pixel0 + pixel1 + pixel2;
gl_FragColor.rgb = (pixelblend.rgb * blendy) + (gl_FragColor.rgb * blenda);
pixelmake.rgb = 0;
pixeldiff.rgb = pixel2.rgb- gl_FragColor.rgb;
pixeldiffleft.rgb = pixel1.rgb - gl_FragColor.rgb;
if (pixeldiff.r > FILTCAP) pixeldiff.r = FILTCAP;
if (pixeldiff.g > FILTCAPG) pixeldiff.g = FILTCAPG;
if (pixeldiff.b > FILTCAP) pixeldiff.b = FILTCAP;
if (pixeldiff.r < -FILTCAP) pixeldiff.r = -FILTCAP;
if (pixeldiff.g < -FILTCAPG) pixeldiff.g = -FILTCAPG;
if (pixeldiff.b < -FILTCAP) pixeldiff.b = -FILTCAP;
if (pixeldiffleft.r > FILTCAP) pixeldiffleft.r = FILTCAP;
if (pixeldiffleft.g > FILTCAPG) pixeldiffleft.g = FILTCAPG;
if (pixeldiffleft.b > FILTCAP) pixeldiffleft.b = FILTCAP;
if (pixeldiffleft.r < -FILTCAP) pixeldiffleft.r = -FILTCAP;
if (pixeldiffleft.g < -FILTCAPG) pixeldiffleft.g = -FILTCAPG;
if (pixeldiffleft.b < -FILTCAP) pixeldiffleft.b = -FILTCAP;
pixelmake.rgb = (pixeldiff.rgb / 4) + (pixeldiffleft.rgb / 16);
gl_FragColor.rgb= (gl_FragColor.rgb + pixelmake.rgb);
}
}

View File

@@ -5,6 +5,8 @@ varying vec2 texture_coordinate2;
varying vec2 texture_coordinate3;
varying vec2 texture_coordinate4;
varying vec2 texture_coordinate5;
uniform float u_ScreenToNextPixelX;
uniform float u_ScreenToNextPixelY;
uniform float u_ScreenSizeX;
uniform float u_ScreenSizeY;

View File

@@ -1,4 +1,4 @@
// LeiFX shader - Pixel filtering process
// "LeiFX" shader - Pixel filtering process
//
// Copyright (C) 2013-2014 leilei
//
@@ -18,14 +18,24 @@ void main()
vec2 px; // shut
px.x = u_ScreenToNextPixelX;
px.y = u_ScreenToNextPixelX;
float gammaed = 0.09;
float gammaed = 0.3;
float leifx_linegamma = gammaed;
float leifx_liney = 0.0078125;0.01568 / 2; // 0.0390625
// Sampling The Texture And Passing It To The Frame Buffer
gl_FragColor = texture2D(u_Texture0, texture_coordinate);
float lines = mod(gl_FragCoord.y, 2.0);
if (lines < 1.0) leifx_linegamma = 0;
float leifx_gamma = 1.3 - gammaed + leifx_linegamma;
float lines = mod(gl_FragCoord.y, 2.0); // I realize the 3dfx doesn't actually line up the picture in the gamma process
//if (lines < 1.0) leifx_linegamma = 0;
if (lines < 1.0) leifx_liney = 0;
// gl_FragColor.r += leifx_liney; // it's a slight purple line.
// gl_FragColor.b += leifx_liney; // it's a slight purple line.
float leifx_gamma = 1.0 + gammaed;// + leifx_linegamma;
gl_FragColor.r = pow(gl_FragColor.r, 1.0 / leifx_gamma);
gl_FragColor.g = pow(gl_FragColor.g, 1.0 / leifx_gamma);
gl_FragColor.b = pow(gl_FragColor.b, 1.0 / leifx_gamma);

View File

@@ -1664,11 +1664,13 @@ const void *RB_SwapBuffers( const void *data ) {
if (r_motionblur->integer == 1){
RB_DrawAccumBlur ();
}
R_BrightScreen(); // leilei - alternate brightness - do it here so we hit evereything
R_BrightScreen(); // leilei - alternate brightness - do it here so we hit evereything that represents our video buffer
R_RetroAAScreen(); // leilei - then apply 'anti aliasing' (hint: IT'S NOT really antialiasing)
R_PaletteScreen(); // leilei - then we palette our overbrighted antialiased screen.
R_NTSCScreen(); // leilei - then we get it through a DAC
R_NTSCScreen(); // leilei - then we get it through a DAC, degrading our precious VGA signals
R_TVScreen(); // leilei - tv operation comes last, this is a SCREEN

View File

@@ -1378,13 +1378,14 @@ void R_LeiFXPostprocessFilterScreen( void )
// postprocess = 1;
if (r_leifx->integer == 3){
/* if (r_leifx->integer == 3){
leifxmode = 2; // gamma - 1 pass
// The stupidest hack in america
R_LeiFX_Stupid_Hack();
R_Postprocess_BackupScreen();
R_Bloom_RestoreScreen_Postprocessed();
}
*/ // Gamma disabled because r_alternateBrightness 2 makes it redundant now.
if (r_leifx->integer > 3){
leifxmode = 3; // filter - 4 pass
// The stupidest hack in america
@@ -1397,9 +1398,9 @@ void R_LeiFXPostprocessFilterScreen( void )
R_Bloom_RestoreScreen_Postprocessed();
R_Postprocess_BackupScreen();
R_Bloom_RestoreScreen_Postprocessed();
leifxmode = 2;
R_Postprocess_BackupScreen();
R_Bloom_RestoreScreen_Postprocessed();
// leifxmode = 2;
// R_Postprocess_BackupScreen();
// R_Bloom_RestoreScreen_Postprocessed();
}
backEnd.doneleifx = qtrue;
@@ -1543,26 +1544,59 @@ void R_BrightItUp (int dst, int src, float intensity)
}
void R_BrightScreen( void )
{
int mode; // 0 = none; 1 = blend; 2 = shader
if( !r_alternateBrightness->integer)
return;
if ( backEnd.doneAltBrightness)
return;
if( !r_alternateBrightness->value)
return;
if ( backEnd.doneAltBrightness )
return;
if ( !backEnd.projection2D )
if (r_alternateBrightness->integer == 1)
mode = 1; // force use blend
if (r_alternateBrightness->integer == 2)
{
// Automatically determine from capabilities
if ( vertexShaders )
mode = 2;
else
mode = 1;
}
// the modern pixel shader way
if (mode == 2)
{
if ( !vertexShaders )
return; // leilei - cards without support for this should not ever activate this
if( !postproc.started ) {
force32upload = 1;
R_Postprocess_InitTextures();
if( !postproc.started )
return;
}
if ( !backEnd.projection2D )
RB_SetGL2D();
//if (!fakeit)
backEnd.doneAltBrightness = qtrue;
force32upload = 1;
leifxmode = 666; // anime effect - outlines, desat, bloom and other crap to go with it
R_LeiFX_Stupid_Hack();
R_Postprocess_BackupScreen();
R_Bloom_RestoreScreen_Postprocessed();
backEnd.doneAltBrightness = qtrue;
force32upload = 0;
}
// Handle Overbrights first
int eh, ah;
if (r_overBrightBits->integer)
{
// the fixed function quad blending way
else if (mode == 1)
{
int eh, ah;
if ((r_overBrightBits->integer))
{
ah = r_overBrightBits->integer;
if (ah < 1) ah = 1; if (ah > 2) ah = 2; // clamp so it never looks stupid
@@ -1570,32 +1604,17 @@ void R_BrightScreen( void )
// Blend method
// do a loop for every overbright bit enabled
if (r_alternateBrightness->integer == 1)
for (eh=0; eh<ah; eh++){
R_BrightItUp(GLS_SRCBLEND_DST_COLOR, GLS_DSTBLEND_ONE, 1.0f); }
for (eh=0; eh<ah; eh++)
R_BrightItUp(GLS_SRCBLEND_DST_COLOR, GLS_DSTBLEND_ONE, 1.0f);
backEnd.doneAltBrightness = qtrue;
}
}
if ( !backEnd.projection2D )
RB_SetGL2D();
// Fragment shader
if ((r_alternateBrightness->integer == 2) && (vertexShaders))
{
force32upload = 1;
leifxmode = 666;
R_LeiFX_Stupid_Hack();
R_Postprocess_BackupScreen();
R_Bloom_RestoreScreen_Postprocessed();
force32upload = 0;
}
}
void R_AltBrightnessInit( void ) {
r_alternateBrightness = ri.Cvar_Get( "r_alternateBrightness", "0", CVAR_ARCHIVE | CVAR_LATCH);

View File

@@ -199,7 +199,7 @@ cvar_t *r_flaresDlightScale;
cvar_t *r_alternateBrightness; // leilei - linux overbright fix
cvar_t *r_mockvr; // Leilei - for debugging PVR only!
cvar_t *r_leifx; // Leilei - leifx nostalgia filter
cvar_t *r_vertshader; // Leilei
cvar_t *r_modelshader; // Leilei
cvar_t *r_ntsc; // Leilei - ntsc / composite signals
//cvar_t *r_tvMode; // Leilei - tv fake mode
@@ -1277,7 +1277,7 @@ void R_Register( void )
r_mockvr = ri.Cvar_Get( "r_mockvr", "0" , CVAR_ARCHIVE | CVAR_CHEAT);
r_leifx = ri.Cvar_Get( "r_leifx", "0" , CVAR_ARCHIVE | CVAR_LATCH);
r_vertshader = ri.Cvar_Get( "r_vertshader", "0" , CVAR_ARCHIVE | CVAR_LATCH);
r_modelshader = ri.Cvar_Get( "r_modelshader", "0" , CVAR_ARCHIVE | CVAR_LATCH); // leilei - load and use special shaders for lightDiffuse models
r_ntsc = ri.Cvar_Get( "r_ntsc", "0" , CVAR_ARCHIVE | CVAR_LATCH);

View File

@@ -319,6 +319,8 @@ typedef struct {
int mipBias;
int isGLSL;
int isBlend; // leilei - for leifx
qboolean isLeiShade; // leilei - for the automatic shader
qhandle_t program;
} shaderStage_t;
@@ -1334,6 +1336,7 @@ extern cvar_t *r_flaresDlightScale;
extern cvar_t *r_alternateBrightness; // leilei - alternate brightness
extern cvar_t *r_leifx; // Leilei - leifx nostalgia filter
extern cvar_t *r_modelshader; // Leilei - new model shading
extern cvar_t *r_leiwater; // Leilei - water test
extern cvar_t *r_ntsc; // Leilei - ntsc
@@ -2104,6 +2107,7 @@ void RB_CalcDynamicColor( unsigned char *colors );
void RB_CalcDiffuseColor_Specular( unsigned char *colors ); // leilei - specular hack
void RB_CalcFlatAmbient( unsigned char *colors ); // leilei - cel hack
void RB_CalcFlatDirect( unsigned char *colors ); // leilei - cel hack
void RB_CalcNormal( unsigned char *colors ); // leilei - normal hack
/*
=============================================================

View File

@@ -873,6 +873,10 @@ static void ComputeColors( shaderStage_t *pStage )
Com_Memset( tess.svars.colors, tr.identityLightByte, tess.numVertexes * 4 );
break;
case CGEN_LIGHTING_DIFFUSE:
if (r_shownormals->integer > 1 || (pStage->isLeiShade)){
RB_CalcNormal( ( unsigned char * ) tess.svars.colors ); // leilei - debug normals, or use the normals as a color for a lighting shader
break;
}
RB_CalcDiffuseColor( ( unsigned char * ) tess.svars.colors );
if(r_monolightmaps->integer)
{
@@ -1010,6 +1014,10 @@ static void ComputeColors( shaderStage_t *pStage )
RB_CalcColorFromOneMinusEntity( ( unsigned char * ) tess.svars.colors );
break;
case CGEN_LIGHTING_DIFFUSE_SPECULAR: // leilei - specular hack
if (r_shownormals->integer > 1 || (pStage->isLeiShade)){
RB_CalcNormal( ( unsigned char * ) tess.svars.colors ); // leilei - debug normals, or use the normals as a color for a lighting shader
break;
}
RB_CalcDiffuseColor_Specular( ( unsigned char * ) tess.svars.colors );
if(r_monolightmaps->integer)
{
@@ -1949,7 +1957,7 @@ void RB_EndSurface( void ) {
if ( r_showtris->integer ) {
DrawTris (input);
}
if ( r_shownormals->integer ) {
if ( r_shownormals->integer == 1 ) {
DrawNormals (input);
}
// clear shader so we can tell we don't have any unclosed surfaces

View File

@@ -1612,6 +1612,63 @@ static void RB_CalcDiffuseColor_scalar( unsigned char *colors )
}
}
// leilei - reveal normals to GLSL for light processing. HACK HACK HACK HACK HACK HACK
void RB_CalcNormal( unsigned char *colors )
{
int i, j;
float *v;
float *normal = ( float * ) tess.normal;
float incoming;
trRefEntity_t *ent;
int ambientLightInt;
vec3_t ambientLight;
vec3_t lightDir;
vec3_t directedLight;
vec3_t n, m;
int numVertexes;
float mult = r_shownormals->value - 1;
ent = backEnd.currentEntity;
ambientLightInt = ent->ambientLightInt;
v = tess.xyz[0];
//normal = tess.normal[0];
numVertexes = tess.numVertexes;
for (i = 0 ; i < numVertexes ; i++, v += 4, normal += 4) {
int y;
float mid;
for (y=0;y<3;y++){
n[y] = normal[y];
// colors[i*4+y] = n[y];
}
//VectorNormalize(n);
mid = n[1] + n[2];
if (mid < 0) mid *= -1;
// m[0] = 127 - (n[1]*128);
// m[1] = 127 - (n[2]*128);
// m[2] = 255 - (mid*128);
m[0] = 127 + (n[0]*128);
m[1] = 127 + (n[1]*128);
m[2] = 127 + (n[2]*128);
colors[i*4+0] = m[0];
colors[i*4+1] = m[1];
colors[i*4+2] = m[2];
colors[i*4+3] = 255;
}
}
void RB_CalcDiffuseColor_Specular( unsigned char *colors )
{
@@ -1632,7 +1689,9 @@ void RB_CalcDiffuseColor_Specular( unsigned char *colors )
ambientLightInt = ent->ambientLightInt;
VectorCopy( ent->ambientLight, ambientLight );
VectorCopy( ent->directedLight, directedLight );
VectorCopy( ent->directedLight, specularLight );
VectorAdd( ent->ambientLight, directedLight, directedLight );
VectorCopy( ent->lightDir, lightDir );
// averaging colors test
@@ -1701,32 +1760,42 @@ void RB_CalcDiffuseColor_Specular( unsigned char *colors )
} else {
l = l*l;
l = l*l;
spec = l * 0.2f;
if (spec > 1) {
spec = 1;
}
spec = l * 2.2f;
if (spec > 1) spec = 1;
}
// specularLight[0] += spec;
// specularLight[1] += spec;
// specularLight[2] += spec;
// if (specularLight[0] < shadecap) specularLight[0] = 0;
// if (specularLight[1] < shadecap) specularLight[1] = 0;
// if (specularLight[2] < shadecap) specularLight[2] = 0;
// if (specularLight[0]) specularLight[0] = 255;
// if (specularLight[1]) specularLight[1] = 255;
// if (specularLight[2]) specularLight[2] = 255;
}
j = ri.ftol(ambientLight[0] + incoming * directedLight[0]);
if ( j > shadecap ) j = shadecap ;
j += ri.ftol(spec * specularLight[0]);
if ( j > shadecap ) {j = shadecap ; j += ri.ftol(spec * specularLight[0]); }
// j += specularLight[0];
if ( j > 255) j = 255;
colors[i*4+0] = j;
j = ri.ftol(ambientLight[1] + incoming * directedLight[1]);
if ( j > shadecap ) j = shadecap ;
j += ri.ftol(spec * specularLight[1]);
if ( j > shadecap ) { j = shadecap ; j += ri.ftol(spec * specularLight[1]); }
// j += specularLight[1];
if ( j > 255) j = 255;
colors[i*4+1] = j;
j = ri.ftol(ambientLight[2] + incoming * directedLight[2]);
if ( j > shadecap ) j = shadecap ;
j += ri.ftol(spec * specularLight[2]);
if ( j > shadecap ) {j = shadecap ; j += ri.ftol(spec * specularLight[2]); }
// j += specularLight[2];
if ( j > 255) j = 255;
colors[i*4+2] = j;