Review standard lighting sample -WIP-
It's broken.
This commit is contained in:
parent
7d81e673ed
commit
f9e4faff09
2 changed files with 12 additions and 16 deletions
|
@ -1,14 +1,14 @@
|
||||||
#version 330
|
#version 330
|
||||||
|
|
||||||
in vec3 vertexPosition;
|
in vec3 vertexPosition;
|
||||||
in vec3 vertexNormal;
|
|
||||||
in vec2 vertexTexCoord;
|
in vec2 vertexTexCoord;
|
||||||
|
in vec3 vertexNormal;
|
||||||
in vec4 vertexColor;
|
in vec4 vertexColor;
|
||||||
|
|
||||||
out vec3 fragPosition;
|
out vec3 fragPosition;
|
||||||
out vec2 fragTexCoord;
|
out vec2 fragTexCoord;
|
||||||
out vec4 fragColor;
|
|
||||||
out vec3 fragNormal;
|
out vec3 fragNormal;
|
||||||
|
out vec4 fragColor;
|
||||||
|
|
||||||
uniform mat4 mvp;
|
uniform mat4 mvp;
|
||||||
|
|
||||||
|
@ -16,8 +16,8 @@ void main()
|
||||||
{
|
{
|
||||||
fragPosition = vertexPosition;
|
fragPosition = vertexPosition;
|
||||||
fragTexCoord = vertexTexCoord;
|
fragTexCoord = vertexTexCoord;
|
||||||
fragColor = vertexColor;
|
|
||||||
fragNormal = vertexNormal;
|
fragNormal = vertexNormal;
|
||||||
|
fragColor = vertexColor;
|
||||||
|
|
||||||
gl_Position = mvp*vec4(vertexPosition, 1.0);
|
gl_Position = mvp*vec4(vertexPosition, 1.0);
|
||||||
}
|
}
|
|
@ -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 };
|
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
|
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",
|
material.shader = LoadShader("resources/shaders/glsl330/standard.vs",
|
||||||
"resources/shaders/glsl330/standard.fs");
|
"resources/shaders/glsl330/standard.fs");
|
||||||
|
@ -107,13 +107,13 @@ int main()
|
||||||
// Try to get lights location points (if available)
|
// Try to get lights location points (if available)
|
||||||
GetShaderLightsLocations(material.shader);
|
GetShaderLightsLocations(material.shader);
|
||||||
|
|
||||||
material.maps[MAP_DIFFUSE].texture = LoadTexture("resources/model/dwarf_diffuse.png"); // Load model diffuse texture
|
material.maps[MAP_DIFFUSE].texture = LoadTexture("../models/resources/pbr/trooper_albedo.png"); // Load model diffuse texture
|
||||||
material.maps[MAP_NORMAL].texture = LoadTexture("resources/model/dwarf_normal.png"); // Load model normal texture
|
material.maps[MAP_NORMAL].texture = LoadTexture("../models/resources/pbr/trooper_normals.png"); // Load model normal texture
|
||||||
material.maps[MAP_SPECULAR].texture = LoadTexture("resources/model/dwarf_specular.png"); // Load model specular 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_DIFFUSE].color = WHITE;
|
||||||
material.maps[MAP_SPECULAR].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});
|
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->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!!!
|
// NOTE: If values are not changed in real time, they can be set at initialization!!!
|
||||||
SetShaderLightsValues(material.shader);
|
SetShaderLightsValues(material.shader);
|
||||||
|
|
||||||
//SetShaderActive(0);
|
|
||||||
|
|
||||||
// Setup orbital camera
|
// Setup orbital camera
|
||||||
SetCameraMode(camera, CAMERA_ORBITAL); // Set an orbital camera mode
|
SetCameraMode(camera, CAMERA_ORBITAL); // Set an orbital camera mode
|
||||||
|
|
||||||
|
@ -159,7 +157,7 @@ int main()
|
||||||
|
|
||||||
BeginMode3D(camera);
|
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(spotLight); // Draw spot light
|
||||||
DrawLight(dirLight); // Draw directional light
|
DrawLight(dirLight); // Draw directional light
|
||||||
|
@ -169,8 +167,6 @@ int main()
|
||||||
|
|
||||||
EndMode3D();
|
EndMode3D();
|
||||||
|
|
||||||
DrawText("(c) Dwarf 3D model by David Moreno", screenWidth - 200, screenHeight - 20, 10, GRAY);
|
|
||||||
|
|
||||||
DrawFPS(10, 10);
|
DrawFPS(10, 10);
|
||||||
|
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
|
@ -180,7 +176,7 @@ int main()
|
||||||
// De-Initialization
|
// De-Initialization
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
UnloadMaterial(material); // Unload material and assigned textures
|
UnloadMaterial(material); // Unload material and assigned textures
|
||||||
UnloadModel(dwarf); // Unload model
|
UnloadModel(model); // Unload model
|
||||||
|
|
||||||
// Destroy all created lights
|
// Destroy all created lights
|
||||||
DestroyLight(pointLight);
|
DestroyLight(pointLight);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue