Added normal and specular maps logic to standard...
...shader and updated example.
This commit is contained in:
parent
5c32cf2095
commit
0ff26f527f
1 changed files with 15 additions and 8 deletions
|
@ -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,7 +36,10 @@ 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};
|
||||
|
@ -44,6 +47,8 @@ int main()
|
|||
|
||||
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};
|
||||
spotLight->intensity = 2.0f;
|
||||
|
@ -58,13 +63,15 @@ 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
|
||||
|
@ -84,7 +93,7 @@ int main()
|
|||
|
||||
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();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue