basic spotlight code

This commit is contained in:
Ian Curtis 2016-05-26 00:08:12 +00:00
parent a0910f96fb
commit 89c987fae1
2 changed files with 13 additions and 18 deletions

View file

@ -674,7 +674,7 @@ void CLegacy3D::InsertVertex(ModelCache *Cache, const Vertex *V, const Poly *P,
// Specular shininess
GLfloat specularCoefficient = (GLfloat) ((P->header[0]>>26) & 0x3F) * (1.0f/63.0f);
int shinyBits = (P->header[6] >> 5) & 3;
float shininess = pow(2.0, 1+shinyBits);
float shininess = pow(2.0f, 1+shinyBits);
if (!(P->header[0]&0x80)) //|| (shininess == 0)) // bit 0x80 seems to enable specular lighting
{
specularCoefficient = 0.; // disable

View file

@ -102,6 +102,18 @@ static const char *fragmentShaderBasic =
// Total light intensity: sum of all components
"lightIntensity = vec3(sunFactor*lighting[1].x + lighting[1].y);\n" // ambient + diffuse
"vec2 ellipse;\n"
"float insideSpot;\n"
// Compute spotlight and apply lighting
"ellipse = (gl_FragCoord.xy - spotEllipse.xy) / spotEllipse.zw;\n"
"insideSpot = dot(ellipse, ellipse);\n"
"if ((insideSpot <= 1.0) && (-fsViewVertex.z >= spotRange.x)) {\n"
"lightIntensity.rgb += (1.0 - insideSpot)*spotColor;\n"
"}\n"
"lightIntensity = clamp(lightIntensity,0.0,1.0);\n"
"finalData.rgb *= lightIntensity;\n"
@ -117,23 +129,6 @@ static const char *fragmentShaderBasic =
"}\n"
"}\n"
/*
"vec2 ellipse;\n"
"vec3 lightIntensity;\n"
"float insideSpot;\n"
// Compute spotlight and apply lighting
"ellipse = (gl_FragCoord.xy - spotEllipse.xy) / spotEllipse.zw;\n"
"insideSpot = dot(ellipse, ellipse);\n"
"if ((insideSpot <= 1.0) && (fsViewZ >= spotRange.x) && (fsViewZ<spotRange.y)) {\n"
"lightIntensity = fsLightIntensity + (1.0 - insideSpot)*spotColor;\n"
"}\n"
"else {\n"
"lightIntensity = fsLightIntensity;\n"
"}\n"
*/
"finalData.rgb = mix(finalData.rgb, fogColour, fsFogFactor);\n"