Keep working on PBR...

Broken skybox sample!
This commit is contained in:
Ray 2017-07-15 14:29:09 +02:00
commit 85507bcfc3

View file

@ -24,23 +24,17 @@ int main()
// Define the camera to look into our 3d world
Camera camera = {{ 1.0f, 1.0f, 1.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f };
// Load skybox model and shader
#define PATH_SKYBOX_VS "resources/shaders/skybox.vs" // Path to skybox vertex shader
#define PATH_SKYBOX_FS "resources/shaders/skybox.fs" // Path to skybox vertex shader
#define PATH_TEXTURES_HDR "resources/pinetree.hdr"
#define LOC_CUSTOM_SKYRESOLUTION 15
Mesh cube = GenMeshCube(1.0f, 1.0f, 1.0f);
Model skybox = LoadModelFromMesh(cube, false);
skybox.material.shader = LoadShader(PATH_SKYBOX_VS, PATH_SKYBOX_FS);
skybox.material.shader = LoadShader("resources/shaders/skybox.vs", "resources/shaders/skybox.fs");
Texture2D texHDR = LoadTexture(PATH_TEXTURES_HDR);
Texture2D texHDR = LoadTexture("resources/pinetree.hdr");
skybox.material.maps[TEXMAP_CUBEMAP].tex = rlGenMapCubemap(texHDR, 512);
SetShaderValuei(skybox.material.shader, GetShaderLocation(skybox.material.shader, "environmentMap"), (int[1]){ TEXMAP_CUBEMAP }, 1);
// Get skybox shader locations
int skyProjectionLoc = GetShaderLocation(skybox.material.shader, "projection");
skybox.material.shader.locs[LOC_MATRIX_VIEW] = GetShaderLocation(skybox.material.shader, "view");
int skyViewLoc = GetShaderLocation(skybox.material.shader, "view");
// Then before rendering, configure the viewport to the actual screen dimensions
Matrix proj = MatrixPerspective(60.0, (double)GetScreenWidth()/(double)GetScreenHeight(), 0.01, 1000.0);
@ -60,7 +54,7 @@ int main()
UpdateCamera(&camera); // Update camera
Matrix view = MatrixLookAt(camera.position, camera.target, camera.up);
SetShaderValueMatrix(skybox.material.shader, skybox.material.shader.locs[LOC_MATRIX_VIEW], view);
SetShaderValueMatrix(skybox.material.shader, skyViewLoc, view);
//----------------------------------------------------------------------------------
// Draw