summaryrefslogtreecommitdiffhomepage
path: root/examples/shaders
diff options
context:
space:
mode:
authorRay <[email protected]>2023-12-23 18:16:06 +0100
committerRay <[email protected]>2023-12-23 18:16:06 +0100
commit36df9c5bd6999d5a047cf94097f258a27aaafc52 (patch)
tree4b1107f2106d32d5bded4592050940251b910028 /examples/shaders
parente039a221a3cf45d115aa9d9489e7d7e03d92b91e (diff)
downloadraylib-36df9c5bd6999d5a047cf94097f258a27aaafc52.tar.gz
raylib-36df9c5bd6999d5a047cf94097f258a27aaafc52.zip
Update shaders_basic_pbr.c
Diffstat (limited to 'examples/shaders')
-rw-r--r--examples/shaders/shaders_basic_pbr.c24
1 files changed, 11 insertions, 13 deletions
diff --git a/examples/shaders/shaders_basic_pbr.c b/examples/shaders/shaders_basic_pbr.c
index e630fbc4..d025ab8a 100644
--- a/examples/shaders/shaders_basic_pbr.c
+++ b/examples/shaders/shaders_basic_pbr.c
@@ -19,10 +19,6 @@
#include "raylib.h"
-#if defined(PLATFORM_WEB)
- #include <emscripten/emscripten.h>
-#endif
-
#if defined(PLATFORM_DESKTOP)
#define GLSL_VERSION 330
#else // PLATFORM_ANDROID, PLATFORM_WEB
@@ -181,10 +177,10 @@ int main()
// Create some lights
Light lights[MAX_LIGHTS] = { 0 };
- lights[0] = CreateLight(LIGHT_POINT, (Vector3){ -1, 1, -2 }, (Vector3){0,0,0}, YELLOW,4, shader);
- lights[1] = CreateLight(LIGHT_POINT, (Vector3){ 2, 1, 1 }, (Vector3){0,0,0}, GREEN,3.3, shader);
- lights[2] = CreateLight(LIGHT_POINT, (Vector3){ -2, 1, 1 }, (Vector3){0,0,0}, RED,8.3, shader);
- lights[3] = CreateLight(LIGHT_POINT, (Vector3){ 1, 1, -2 }, (Vector3){0,0,0}, BLUE,2, shader);
+ lights[0] = CreateLight(LIGHT_POINT, (Vector3){ -1.0f, 1.0f, -2.0f }, (Vector3){ 0.0f, 0.0f, 0.0f }, YELLOW, 4.0f, shader);
+ lights[1] = CreateLight(LIGHT_POINT, (Vector3){ 2.0f, 1.0f, 1.0f }, (Vector3){ 0.0f, 0.0f, 0.0f }, GREEN, 3.3f, shader);
+ lights[2] = CreateLight(LIGHT_POINT, (Vector3){ -2.0f, 1.0f, 1.0f }, (Vector3){ 0.0f, 0.0f, 0.0f }, RED, 8.3f, shader);
+ lights[3] = CreateLight(LIGHT_POINT, (Vector3){ 1.0f, 1.0f, -2.0f }, (Vector3){ 0.0f, 0.0f, 0.0f }, BLUE, 2.0f, shader);
// Setup material texture maps usage in shader
// NOTE: By default, the texture maps are always used
@@ -297,18 +293,20 @@ static Light CreateLight(int type, Vector3 position, Vector3 target, Color color
light.type = type;
light.position = position;
light.target = target;
- light.color[0] = (float)color.r / (float)255;
- light.color[1] = (float)color.g / (float)255;
- light.color[2] = (float)color.b / (float)255;
- light.color[3] = (float)color.a / (float)255;
+ light.color[0] = (float)color.r/255.0f;
+ light.color[1] = (float)color.g/255.0f;
+ light.color[2] = (float)color.b/255.0f;
+ light.color[3] = (float)color.a/255.0f;
light.intensity = intensity;
- // NOTE: Lighting shader naming must be the provided ones
+
+ // NOTE: Shader parameters names for lights must match the requested ones
light.enabledLoc = GetShaderLocation(shader, TextFormat("lights[%i].enabled", lightCount));
light.typeLoc = GetShaderLocation(shader, TextFormat("lights[%i].type", lightCount));
light.positionLoc = GetShaderLocation(shader, TextFormat("lights[%i].position", lightCount));
light.targetLoc = GetShaderLocation(shader, TextFormat("lights[%i].target", lightCount));
light.colorLoc = GetShaderLocation(shader, TextFormat("lights[%i].color", lightCount));
light.intensityLoc = GetShaderLocation(shader, TextFormat("lights[%i].intensity", lightCount));
+
UpdateLight(shader, light);
lightCount++;