Reviewed models and examples
22251
examples/shaders/resources/models/barracks.obj
Normal file
BIN
examples/shaders/resources/models/barracks_diffuse.png
Normal file
After Width: | Height: | Size: 363 KiB |
5116
examples/shaders/resources/models/church.obj
Normal file
BIN
examples/shaders/resources/models/church_diffuse.png
Normal file
After Width: | Height: | Size: 350 KiB |
5316
examples/shaders/resources/models/watermill.obj
Normal file
BIN
examples/shaders/resources/models/watermill_diffuse.png
Normal file
After Width: | Height: | Size: 437 KiB |
|
@ -31,15 +31,15 @@ int main()
|
|||
|
||||
// Define the camera to look into our 3d world
|
||||
Camera camera = { 0 };
|
||||
camera.position = (Vector3){ 3.0f, 3.0f, 3.0f };
|
||||
camera.position = (Vector3){ 8.0f, 8.0f, 8.0f };
|
||||
camera.target = (Vector3){ 0.0f, 1.5f, 0.0f };
|
||||
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };
|
||||
camera.fovy = 45.0f;
|
||||
camera.type = CAMERA_PERSPECTIVE;
|
||||
|
||||
Model dwarf = LoadModel("resources/model/dwarf.obj"); // Load OBJ model
|
||||
Texture2D texture = LoadTexture("resources/model/dwarf_diffuse.png"); // Load model texture (diffuse map)
|
||||
dwarf.material.maps[MAP_DIFFUSE].texture = texture; // Set dwarf model diffuse texture
|
||||
Model model = LoadModel("resources/models/barracks.obj"); // Load OBJ model
|
||||
Texture2D texture = LoadTexture("resources/models/barracks_diffuse.png"); // Load model texture (diffuse map)
|
||||
model.material.maps[MAP_DIFFUSE].texture = texture; // Set model diffuse texture
|
||||
|
||||
Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position
|
||||
|
||||
|
@ -87,7 +87,7 @@ int main()
|
|||
|
||||
BeginMode3D(camera);
|
||||
|
||||
DrawModel(dwarf, position, 2.0f, WHITE); // Draw 3d model with texture
|
||||
DrawModel(model, position, 0.5f, WHITE); // Draw 3d model with texture
|
||||
|
||||
DrawGrid(10, 1.0f); // Draw a grid
|
||||
|
||||
|
@ -104,8 +104,8 @@ int main()
|
|||
|
||||
EndShaderMode();
|
||||
|
||||
DrawText("(c) Dwarf 3D model by David Moreno", screenWidth - 200, screenHeight - 20, 10, GRAY);
|
||||
|
||||
DrawText("(c) Barracks 3D model by Alberto Cano", screenWidth - 220, screenHeight - 20, 10, GRAY);
|
||||
|
||||
DrawFPS(10, 10);
|
||||
|
||||
EndDrawing();
|
||||
|
@ -116,7 +116,7 @@ int main()
|
|||
//--------------------------------------------------------------------------------------
|
||||
UnloadShader(shader); // Unload shader
|
||||
UnloadTexture(texture); // Unload texture
|
||||
UnloadModel(dwarf); // Unload model
|
||||
UnloadModel(model); // Unload model
|
||||
UnloadRenderTexture(target); // Unload render texture
|
||||
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
|
|
Before Width: | Height: | Size: 252 KiB After Width: | Height: | Size: 324 KiB |
|
@ -31,19 +31,19 @@ int main()
|
|||
|
||||
// Define the camera to look into our 3d world
|
||||
Camera camera = { 0 };
|
||||
camera.position = (Vector3){ 3.0f, 3.0f, 3.0f };
|
||||
camera.target = (Vector3){ 0.0f, 1.5f, 0.0f };
|
||||
camera.position = (Vector3){ 4.0f, 4.0f, 4.0f };
|
||||
camera.target = (Vector3){ 0.0f, 1.0f, -1.0f };
|
||||
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };
|
||||
camera.fovy = 45.0f;
|
||||
camera.type = CAMERA_PERSPECTIVE;
|
||||
|
||||
Model dwarf = LoadModel("resources/model/dwarf.obj"); // Load OBJ model
|
||||
Texture2D texture = LoadTexture("resources/model/dwarf_diffuse.png"); // Load model texture
|
||||
Model model = LoadModel("resources/models/watermill.obj"); // Load OBJ model
|
||||
Texture2D texture = LoadTexture("resources/models/watermill_diffuse.png"); // Load model texture
|
||||
Shader shader = LoadShader("resources/shaders/glsl330/base.vs",
|
||||
"resources/shaders/glsl330/grayscale.fs"); // Load model shader
|
||||
|
||||
dwarf.material.shader = shader; // Set shader effect to 3d model
|
||||
dwarf.material.maps[MAP_DIFFUSE].texture = texture; // Bind texture to model
|
||||
model.material.shader = shader; // Set shader effect to 3d model
|
||||
model.material.maps[MAP_DIFFUSE].texture = texture; // Bind texture to model
|
||||
|
||||
Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position
|
||||
|
||||
|
@ -68,13 +68,13 @@ int main()
|
|||
|
||||
BeginMode3D(camera);
|
||||
|
||||
DrawModel(dwarf, position, 2.0f, WHITE); // Draw 3d model with texture
|
||||
DrawModel(model, position, 0.2f, WHITE); // Draw 3d model with texture
|
||||
|
||||
DrawGrid(10, 1.0f); // Draw a grid
|
||||
|
||||
EndMode3D();
|
||||
|
||||
DrawText("(c) Dwarf 3D model by David Moreno", screenWidth - 200, screenHeight - 20, 10, GRAY);
|
||||
DrawText("(c) Watermill 3D model by Alberto Cano", screenWidth - 210, screenHeight - 20, 10, GRAY);
|
||||
|
||||
DrawText(FormatText("Camera position: (%.2f, %.2f, %.2f)", camera.position.x, camera.position.y, camera.position.z), 600, 20, 10, BLACK);
|
||||
DrawText(FormatText("Camera target: (%.2f, %.2f, %.2f)", camera.target.x, camera.target.y, camera.target.z), 600, 40, 10, GRAY);
|
||||
|
@ -89,7 +89,7 @@ int main()
|
|||
//--------------------------------------------------------------------------------------
|
||||
UnloadShader(shader); // Unload shader
|
||||
UnloadTexture(texture); // Unload texture
|
||||
UnloadModel(dwarf); // Unload model
|
||||
UnloadModel(model); // Unload model
|
||||
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
|
Before Width: | Height: | Size: 139 KiB After Width: | Height: | Size: 214 KiB |
|
@ -70,13 +70,13 @@ int main()
|
|||
InitWindow(screenWidth, screenHeight, "raylib [shaders] example - postprocessing shader");
|
||||
|
||||
// Define the camera to look into our 3d world
|
||||
Camera camera = {{ 3.0f, 3.0f, 3.0f }, { 0.0f, 1.5f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 };
|
||||
Camera camera = {{ 2.0f, 3.0f, 2.0f }, { 0.0f, 1.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 };
|
||||
|
||||
Model dwarf = LoadModel("resources/model/dwarf.obj"); // Load OBJ model
|
||||
Texture2D texture = LoadTexture("resources/model/dwarf_diffuse.png"); // Load model texture (diffuse map)
|
||||
dwarf.material.maps[MAP_DIFFUSE].texture = texture; // Set dwarf model diffuse texture
|
||||
Model model = LoadModel("resources/models/church.obj"); // Load OBJ model
|
||||
Texture2D texture = LoadTexture("resources/models/church_diffuse.png"); // Load model texture (diffuse map)
|
||||
model.material.maps[MAP_DIFFUSE].texture = texture; // Set model diffuse texture
|
||||
|
||||
Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position
|
||||
Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position
|
||||
|
||||
// Load all postpro shaders
|
||||
// NOTE 1: All postpro shader use the base vertex shader (DEFAULT_VERTEX_SHADER)
|
||||
|
@ -132,7 +132,7 @@ int main()
|
|||
|
||||
BeginMode3D(camera);
|
||||
|
||||
DrawModel(dwarf, position, 2.0f, WHITE); // Draw 3d model with texture
|
||||
DrawModel(model, position, 0.1f, WHITE); // Draw 3d model with texture
|
||||
|
||||
DrawGrid(10, 1.0f); // Draw a grid
|
||||
|
||||
|
@ -150,7 +150,7 @@ int main()
|
|||
|
||||
DrawRectangle(0, 9, 580, 30, Fade(LIGHTGRAY, 0.7f));
|
||||
|
||||
DrawText("(c) Dwarf 3D model by David Moreno", screenWidth - 200, screenHeight - 20, 10, DARKGRAY);
|
||||
DrawText("(c) Church 3D model by Alberto Cano", screenWidth - 200, screenHeight - 20, 10, GRAY);
|
||||
|
||||
DrawText("CURRENT POSTPRO SHADER:", 10, 15, 20, BLACK);
|
||||
DrawText(postproShaderText[currentShader], 330, 15, 20, RED);
|
||||
|
@ -169,7 +169,7 @@ int main()
|
|||
for (int i = 0; i < MAX_POSTPRO_SHADERS; i++) UnloadShader(shaders[i]);
|
||||
|
||||
UnloadTexture(texture); // Unload texture
|
||||
UnloadModel(dwarf); // Unload model
|
||||
UnloadModel(model); // Unload model
|
||||
UnloadRenderTexture(target); // Unload render texture
|
||||
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
|
|
Before Width: | Height: | Size: 189 KiB After Width: | Height: | Size: 139 KiB |