From f9e4faff09c59b18ca291413a621eae33d64a8c3 Mon Sep 17 00:00:00 2001 From: Ray Date: Sun, 16 Dec 2018 00:35:30 +0100 Subject: [PATCH] Review standard lighting sample -WIP- It's broken. --- .../resources/shaders/glsl330/standard.vs | 8 ++++---- examples/others/standard_lighting.c | 20 ++++++++----------- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/examples/others/resources/shaders/glsl330/standard.vs b/examples/others/resources/shaders/glsl330/standard.vs index 7fbdbf5e..e2022201 100644 --- a/examples/others/resources/shaders/glsl330/standard.vs +++ b/examples/others/resources/shaders/glsl330/standard.vs @@ -1,14 +1,14 @@ #version 330 in vec3 vertexPosition; -in vec3 vertexNormal; in vec2 vertexTexCoord; +in vec3 vertexNormal; in vec4 vertexColor; out vec3 fragPosition; out vec2 fragTexCoord; -out vec4 fragColor; out vec3 fragNormal; +out vec4 fragColor; uniform mat4 mvp; @@ -16,8 +16,8 @@ void main() { fragPosition = vertexPosition; fragTexCoord = vertexTexCoord; - fragColor = vertexColor; fragNormal = vertexNormal; - + fragColor = vertexColor; + gl_Position = mvp*vec4(vertexPosition, 1.0); } \ No newline at end of file diff --git a/examples/others/standard_lighting.c b/examples/others/standard_lighting.c index 4e973b96..72890436 100644 --- a/examples/others/standard_lighting.c +++ b/examples/others/standard_lighting.c @@ -97,9 +97,9 @@ int main() Camera camera = {{ 4.0f, 4.0f, 4.0f }, { 0.0f, 1.5f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f }; Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position - Model dwarf = LoadModel("resources/model/dwarf.obj"); // Load OBJ model + Model model = LoadModel("../models/resources/pbr/trooper.obj"); // Load OBJ model - Material material;// = LoadStandardMaterial(); + Material material = { 0 }; material.shader = LoadShader("resources/shaders/glsl330/standard.vs", "resources/shaders/glsl330/standard.fs"); @@ -107,13 +107,13 @@ int main() // Try to get lights location points (if available) GetShaderLightsLocations(material.shader); - material.maps[MAP_DIFFUSE].texture = LoadTexture("resources/model/dwarf_diffuse.png"); // Load model diffuse texture - material.maps[MAP_NORMAL].texture = LoadTexture("resources/model/dwarf_normal.png"); // Load model normal texture - material.maps[MAP_SPECULAR].texture = LoadTexture("resources/model/dwarf_specular.png"); // Load model specular texture + material.maps[MAP_DIFFUSE].texture = LoadTexture("../models/resources/pbr/trooper_albedo.png"); // Load model diffuse texture + material.maps[MAP_NORMAL].texture = LoadTexture("../models/resources/pbr/trooper_normals.png"); // Load model normal texture + material.maps[MAP_SPECULAR].texture = LoadTexture("../models/resources/pbr/trooper_roughness.png"); // Load model specular texture material.maps[MAP_DIFFUSE].color = WHITE; material.maps[MAP_SPECULAR].color = WHITE; - dwarf.material = material; // Apply material to model + model.material = material; // Apply material to 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}; @@ -135,8 +135,6 @@ int main() // NOTE: If values are not changed in real time, they can be set at initialization!!! SetShaderLightsValues(material.shader); - //SetShaderActive(0); - // Setup orbital camera SetCameraMode(camera, CAMERA_ORBITAL); // Set an orbital camera mode @@ -159,7 +157,7 @@ int main() BeginMode3D(camera); - DrawModel(dwarf, position, 2.0f, WHITE); // Draw 3d model with texture + DrawModel(model, position, 2.0f, WHITE); // Draw 3d model with texture DrawLight(spotLight); // Draw spot light DrawLight(dirLight); // Draw directional light @@ -169,8 +167,6 @@ int main() EndMode3D(); - DrawText("(c) Dwarf 3D model by David Moreno", screenWidth - 200, screenHeight - 20, 10, GRAY); - DrawFPS(10, 10); EndDrawing(); @@ -180,7 +176,7 @@ int main() // De-Initialization //-------------------------------------------------------------------------------------- UnloadMaterial(material); // Unload material and assigned textures - UnloadModel(dwarf); // Unload model + UnloadModel(model); // Unload model // Destroy all created lights DestroyLight(pointLight);