mirror of
https://github.com/RetroDECK/Supermodel.git
synced 2025-03-06 14:27:44 +00:00
basic spotlight code
This commit is contained in:
parent
a0910f96fb
commit
89c987fae1
|
@ -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
|
||||
|
|
|
@ -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"
|
||||
|
||||
|
|
Loading…
Reference in a new issue