aboutsummaryrefslogtreecommitdiff
path: root/src/rlgl.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/rlgl.c')
-rw-r--r--src/rlgl.c30
1 files changed, 21 insertions, 9 deletions
diff --git a/src/rlgl.c b/src/rlgl.c
index cc4c4c2f..0f68953e 100644
--- a/src/rlgl.c
+++ b/src/rlgl.c
@@ -204,8 +204,8 @@ static bool texCompPVRTSupported = false; // PVR texture compression support
static bool texCompASTCSupported = false; // ASTC texture compression support
// Lighting data
-static Light lights[MAX_LIGHTS]; // Lights pool
-static int lightsCount; // Counts current enabled physic objects
+static Light lights[MAX_LIGHTS]; // Lights pool
+static int lightsCount; // Counts current enabled physic objects
#endif
// Compressed textures support flags
@@ -1793,6 +1793,9 @@ void rlglDrawMesh(Mesh mesh, Material material, Matrix transform)
// Setup shader uniforms for lights
SetShaderLights(material.shader);
+ // Upload to shader material.colSpecular
+ glUniform4f(glGetUniformLocation(material.shader.id, "colTint"), (float)material.colTint.r/255, (float)material.colTint.g/255, (float)material.colTint.b/255, (float)material.colTint.a/255);
+
// Upload to shader material.colAmbient
glUniform4f(glGetUniformLocation(material.shader.id, "colAmbient"), (float)material.colAmbient.r/255, (float)material.colAmbient.g/255, (float)material.colAmbient.b/255, (float)material.colAmbient.a/255);
@@ -1810,16 +1813,19 @@ void rlglDrawMesh(Mesh mesh, Material material, Matrix transform)
if ((material.texNormal.id != 0) && (material.shader.mapTexture1Loc != -1))
{
+ // Upload to shader specular map flag
+ glUniform1i(glGetUniformLocation(material.shader.id, "useNormal"), 1);
+
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, material.texNormal.id);
glUniform1i(material.shader.mapTexture1Loc, 1); // Normal texture fits in active texture unit 1
-
- // TODO: Upload to shader normalDepth
- //glUniform1f(???, material.normalDepth);
}
if ((material.texSpecular.id != 0) && (material.shader.mapTexture2Loc != -1))
{
+ // Upload to shader specular map flag
+ glUniform1i(glGetUniformLocation(material.shader.id, "useSpecular"), 1);
+
glActiveTexture(GL_TEXTURE2);
glBindTexture(GL_TEXTURE_2D, material.texSpecular.id);
glUniform1i(material.shader.mapTexture2Loc, 2); // Specular texture fits in active texture unit 2
@@ -2293,7 +2299,13 @@ void DrawLights(void)
{
switch (lights[i]->type)
{
- case LIGHT_POINT: DrawSphereWires(lights[i]->position, 0.3f*lights[i]->intensity, 4, 8, (lights[i]->enabled ? lights[i]->diffuse : BLACK)); break;
+ case LIGHT_POINT:
+ {
+ DrawSphereWires(lights[i]->position, 0.3f*lights[i]->intensity, 4, 8, (lights[i]->enabled ? lights[i]->diffuse : BLACK));
+ Draw3DCircle(lights[i]->position, lights[i]->radius, 0.0f, (Vector3){ 0, 0, 0 }, (lights[i]->enabled ? lights[i]->diffuse : BLACK));
+ Draw3DCircle(lights[i]->position, lights[i]->radius, 90.0f, (Vector3){ 1, 0, 0 }, (lights[i]->enabled ? lights[i]->diffuse : BLACK));
+ Draw3DCircle(lights[i]->position, lights[i]->radius, 90.0f, (Vector3){ 0, 1, 0 }, (lights[i]->enabled ? lights[i]->diffuse : BLACK));
+ } break;
case LIGHT_DIRECTIONAL:
{
Draw3DLine(lights[i]->position, lights[i]->target, (lights[i]->enabled ? lights[i]->diffuse : BLACK));
@@ -2553,7 +2565,7 @@ static Shader LoadDefaultShader(void)
// Load standard shader
// NOTE: This shader supports:
// - Up to 3 different maps: diffuse, normal, specular
-// - Material properties: colAmbient, colDiffuse, colSpecular, glossiness, normalDepth
+// - Material properties: colAmbient, colDiffuse, colSpecular, glossiness
// - Up to 8 lights: Point, Directional or Spot
static Shader LoadStandardShader(void)
{
@@ -3105,9 +3117,9 @@ static void SetShaderLights(Shader shader)
locPoint = GetShaderLocation(shader, locName);
glUniform3f(locPoint, lights[i]->position.x, lights[i]->position.y, lights[i]->position.z);
- memcpy(&locName[10], "attenuation\0", strlen("attenuation\0"));
+ memcpy(&locName[10], "radius\0", strlen("radius\0") + 2);
locPoint = GetShaderLocation(shader, locName);
- glUniform1f(locPoint, lights[i]->attenuation);
+ glUniform1f(locPoint, lights[i]->radius);
} break;
case LIGHT_DIRECTIONAL:
{