aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvictorfisac <victorfisac@gmail.com>2016-05-30 19:26:17 +0200
committervictorfisac <victorfisac@gmail.com>2016-05-30 19:26:17 +0200
commit0ff26f527fbdb090beec341cc60b8bb38bdf2439 (patch)
tree52014f488739926dc9dddb0825cf00f1417bad09
parent5c32cf20959e5457665c8da904e4528ccb255e53 (diff)
downloadraylib-0ff26f527fbdb090beec341cc60b8bb38bdf2439.tar.gz
raylib-0ff26f527fbdb090beec341cc60b8bb38bdf2439.zip
Added normal and specular maps logic to standard...
...shader and updated example.
-rw-r--r--examples/shaders_standard_lighting.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/examples/shaders_standard_lighting.c b/examples/shaders_standard_lighting.c
index 2dde7193..6f45ca61 100644
--- a/examples/shaders_standard_lighting.c
+++ b/examples/shaders_standard_lighting.c
@@ -22,8 +22,8 @@ int main()
{
// Initialization
//--------------------------------------------------------------------------------------
- int screenWidth = 800;
- int screenHeight = 450;
+ int screenWidth = 1280;
+ int screenHeight = 720;
SetConfigFlags(FLAG_MSAA_4X_HINT); // Enable Multi Sampling Anti Aliasing 4x (if available)
@@ -36,13 +36,18 @@ int main()
Model dwarf = LoadModel("resources/model/dwarf.obj"); // Load OBJ model
Material material = LoadStandardMaterial();
+
material.texDiffuse = LoadTexture("resources/model/dwarf_diffuse.png"); // Load model diffuse texture
+ material.texNormal = LoadTexture("resources/model/dwarf_normal.png"); // Load model normal texture
+ material.texSpecular = LoadTexture("resources/model/dwarf_specular.png"); // Load model specular texture
material.colDiffuse = (Color){255, 255, 255, 255};
material.colAmbient = (Color){0, 0, 10, 255};
material.colSpecular = (Color){255, 255, 255, 255};
material.glossiness = 50.0f;
dwarf.material = material; // Apply material to model
+
+ Model dwarf2 = LoadModel("resources/model/dwarf.obj"); // Load OBJ model
Light spotLight = CreateLight(LIGHT_SPOT, (Vector3){3.0f, 5.0f, 2.0f}, (Color){255, 255, 255, 255});
spotLight->target = (Vector3){0.0f, 0.0f, 0.0f};
@@ -58,12 +63,14 @@ int main()
Light pointLight = CreateLight(LIGHT_POINT, (Vector3){0.0f, 4.0f, 5.0f}, (Color){255, 255, 255, 255});
pointLight->intensity = 2.0f;
pointLight->diffuse = (Color){100, 100, 255, 255};
- pointLight->attenuation = 3.0f;
+ pointLight->radius = 3.0f;
// Setup orbital camera
- SetCameraMode(CAMERA_ORBITAL); // Set a orbital camera mode
+ SetCameraMode(CAMERA_ORBITAL); // Set an orbital camera mode
SetCameraPosition(camera.position); // Set internal camera position to match our camera position
SetCameraTarget(camera.target); // Set internal camera target to match our camera target
+
+ float framesCounter = 0; // Define frames counter to update model rotation
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
@@ -74,6 +81,8 @@ int main()
// Update
//----------------------------------------------------------------------------------
UpdateCamera(&camera); // Update internal camera and our camera
+
+ framesCounter += 0.5f;
//----------------------------------------------------------------------------------
// Draw
@@ -83,8 +92,8 @@ int main()
ClearBackground(RAYWHITE);
Begin3dMode(camera);
-
- DrawModel(dwarf, position, 2.0f, WHITE); // Draw 3d model with texture
+
+ DrawModelEx(dwarf, position, (Vector3){ 0.0f, 1.0f, 0.0f }, framesCounter, (Vector3){ 2.0f, 2.0f, 2.0f}, RED); // Draw 3d model with texture
DrawLights(); // Draw all created lights in 3D world
@@ -94,8 +103,6 @@ int main()
DrawText("(c) Dwarf 3D model by David Moreno", screenWidth - 200, screenHeight - 20, 10, GRAY);
- DrawFPS(10, 10);
-
EndDrawing();
//----------------------------------------------------------------------------------
}