Merge branch 'raysan5:master' into master
This commit is contained in:
commit
7ac4a2920a
41 changed files with 3476 additions and 2734 deletions
|
|
@ -8,7 +8,7 @@ Here it is a list with the ones I'm aware of:
|
||||||
|:------------------:|:-------------: | :--------:|----------------------------------------------------------------------|
|
|:------------------:|:-------------: | :--------:|----------------------------------------------------------------------|
|
||||||
| raylib | **3.7** | [C](https://en.wikipedia.org/wiki/C_(programming_language)) | https://github.com/raysan5/raylib |
|
| raylib | **3.7** | [C](https://en.wikipedia.org/wiki/C_(programming_language)) | https://github.com/raysan5/raylib |
|
||||||
| raylib-cpp | 3.7 | [C++](https://en.wikipedia.org/wiki/C%2B%2B) | https://github.com/robloach/raylib-cpp |
|
| raylib-cpp | 3.7 | [C++](https://en.wikipedia.org/wiki/C%2B%2B) | https://github.com/robloach/raylib-cpp |
|
||||||
| Raylib-cs | 3.5 | [C#](https://en.wikipedia.org/wiki/C_Sharp_(programming_language)) | https://github.com/ChrisDill/Raylib-cs |
|
| Raylib-cs | 3.7 | [C#](https://en.wikipedia.org/wiki/C_Sharp_(programming_language)) | https://github.com/ChrisDill/Raylib-cs |
|
||||||
| raylib-cppsharp | 2.5 | [C#](https://en.wikipedia.org/wiki/C_Sharp_(programming_language)) | https://github.com/phxvyper/raylib-cppsharp |
|
| raylib-cppsharp | 2.5 | [C#](https://en.wikipedia.org/wiki/C_Sharp_(programming_language)) | https://github.com/phxvyper/raylib-cppsharp |
|
||||||
| raylib-boo | 3.7 | [Boo](http://boo-language.github.io/) | https://github.com/Rabios/raylib-boo |
|
| raylib-boo | 3.7 | [Boo](http://boo-language.github.io/) | https://github.com/Rabios/raylib-boo |
|
||||||
| RaylibFS | 2.5 | [F#](https://fsharp.org/) | https://github.com/dallinbeutler/RaylibFS |
|
| RaylibFS | 2.5 | [F#](https://fsharp.org/) | https://github.com/dallinbeutler/RaylibFS |
|
||||||
|
|
@ -16,7 +16,7 @@ Here it is a list with the ones I'm aware of:
|
||||||
| raylib-d | 3.0 | [D](https://dlang.org/) | https://github.com/onroundit/raylib-d |
|
| raylib-d | 3.0 | [D](https://dlang.org/) | https://github.com/onroundit/raylib-d |
|
||||||
| bindbc-raylib | 3.0 | [D](https://dlang.org/) | https://github.com/o3o/bindbc-raylib |
|
| bindbc-raylib | 3.0 | [D](https://dlang.org/) | https://github.com/o3o/bindbc-raylib |
|
||||||
| dray | 3.5 | [D](https://dlang.org/) | https://github.com/xdrie/dray |
|
| dray | 3.5 | [D](https://dlang.org/) | https://github.com/xdrie/dray |
|
||||||
| raylib-go | 3.0 | [Go](https://golang.org/) | https://github.com/gen2brain/raylib-go |
|
| raylib-go | 3.8-dev | [Go](https://golang.org/) | https://github.com/gen2brain/raylib-go |
|
||||||
| raylib-goplus | 2.6-dev | [Go](https://golang.org/) | https://github.com/Lachee/raylib-goplus |
|
| raylib-goplus | 2.6-dev | [Go](https://golang.org/) | https://github.com/Lachee/raylib-goplus |
|
||||||
| ray-go | 2.6-dev | [Go](https://golang.org/) | https://github.com/hecate-tech/ray-go |
|
| ray-go | 2.6-dev | [Go](https://golang.org/) | https://github.com/hecate-tech/ray-go |
|
||||||
| go-raylib | 3.5 | [Go](https://golang.org/) | https://github.com/chunqian/go-raylib |
|
| go-raylib | 3.5 | [Go](https://golang.org/) | https://github.com/chunqian/go-raylib |
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
|
|
||||||
if(USE_EXTERNAL_GLFW STREQUAL "ON")
|
if(USE_EXTERNAL_GLFW STREQUAL "ON")
|
||||||
find_package(glfw3 3.2.1 REQUIRED)
|
find_package(glfw3 3.3.3 REQUIRED)
|
||||||
elseif(USE_EXTERNAL_GLFW STREQUAL "IF_POSSIBLE")
|
elseif(USE_EXTERNAL_GLFW STREQUAL "IF_POSSIBLE")
|
||||||
find_package(glfw3 3.2.1 QUIET)
|
find_package(glfw3 3.3.3 QUIET)
|
||||||
endif()
|
endif()
|
||||||
if (glfw3_FOUND)
|
if (glfw3_FOUND)
|
||||||
set(LIBS_PRIVATE ${LIBS_PRIVATE} glfw)
|
set(LIBS_PRIVATE ${LIBS_PRIVATE} glfw)
|
||||||
|
|
|
||||||
|
|
@ -257,8 +257,8 @@ ifeq ($(PLATFORM),PLATFORM_WEB)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Define include paths for required headers
|
# Define include paths for required headers
|
||||||
# NOTE: Several external required libraries (stb and others)
|
# NOTE: Some external/extras libraries could be required (stb, physac, easings...)
|
||||||
INCLUDE_PATHS = -I. -I$(RAYLIB_PATH)/src -I$(RAYLIB_PATH)/src/external
|
INCLUDE_PATHS = -I. -I$(RAYLIB_PATH)/src -I$(RAYLIB_PATH)/src/external -I$(RAYLIB_PATH)/src/extras
|
||||||
|
|
||||||
# Define additional directories containing required header files
|
# Define additional directories containing required header files
|
||||||
ifeq ($(PLATFORM),PLATFORM_RPI)
|
ifeq ($(PLATFORM),PLATFORM_RPI)
|
||||||
|
|
@ -277,7 +277,7 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||||
INCLUDE_PATHS += -I/usr/local/include
|
INCLUDE_PATHS += -I/usr/local/include
|
||||||
endif
|
endif
|
||||||
ifeq ($(PLATFORM_OS),LINUX)
|
ifeq ($(PLATFORM_OS),LINUX)
|
||||||
INCLUDE_PATHS = -I$(RAYLIB_H_INSTALL_PATH) -I. -I$(RAYLIB_PATH)/src -I$(RAYLIB_PATH)/src/external
|
INCLUDE_PATHS += -I$(RAYLIB_H_INSTALL_PATH)
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ int main(void)
|
||||||
|
|
||||||
Ray ray = { 0 }; // Picking line ray
|
Ray ray = { 0 }; // Picking line ray
|
||||||
|
|
||||||
bool collision = false;
|
RayCollision collision = { 0 };
|
||||||
|
|
||||||
SetCameraMode(camera, CAMERA_FREE); // Set a free camera mode
|
SetCameraMode(camera, CAMERA_FREE); // Set a free camera mode
|
||||||
|
|
||||||
|
|
@ -49,16 +49,16 @@ int main(void)
|
||||||
|
|
||||||
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT))
|
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT))
|
||||||
{
|
{
|
||||||
if (!collision)
|
if (!collision.hit)
|
||||||
{
|
{
|
||||||
ray = GetMouseRay(GetMousePosition(), camera);
|
ray = GetMouseRay(GetMousePosition(), camera);
|
||||||
|
|
||||||
// Check collision between ray and box
|
// Check collision between ray and box
|
||||||
collision = CheckCollisionRayBox(ray,
|
collision = GetRayCollisionBox(ray,
|
||||||
(BoundingBox){(Vector3){ cubePosition.x - cubeSize.x/2, cubePosition.y - cubeSize.y/2, cubePosition.z - cubeSize.z/2 },
|
(BoundingBox){(Vector3){ cubePosition.x - cubeSize.x/2, cubePosition.y - cubeSize.y/2, cubePosition.z - cubeSize.z/2 },
|
||||||
(Vector3){ cubePosition.x + cubeSize.x/2, cubePosition.y + cubeSize.y/2, cubePosition.z + cubeSize.z/2 }});
|
(Vector3){ cubePosition.x + cubeSize.x/2, cubePosition.y + cubeSize.y/2, cubePosition.z + cubeSize.z/2 }});
|
||||||
}
|
}
|
||||||
else collision = false;
|
else collision.hit = false;
|
||||||
}
|
}
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
@ -70,7 +70,7 @@ int main(void)
|
||||||
|
|
||||||
BeginMode3D(camera);
|
BeginMode3D(camera);
|
||||||
|
|
||||||
if (collision)
|
if (collision.hit)
|
||||||
{
|
{
|
||||||
DrawCube(cubePosition, cubeSize.x, cubeSize.y, cubeSize.z, RED);
|
DrawCube(cubePosition, cubeSize.x, cubeSize.y, cubeSize.z, RED);
|
||||||
DrawCubeWires(cubePosition, cubeSize.x, cubeSize.y, cubeSize.z, MAROON);
|
DrawCubeWires(cubePosition, cubeSize.x, cubeSize.y, cubeSize.z, MAROON);
|
||||||
|
|
@ -90,7 +90,7 @@ int main(void)
|
||||||
|
|
||||||
DrawText("Try selecting the box with mouse!", 240, 10, 20, DARKGRAY);
|
DrawText("Try selecting the box with mouse!", 240, 10, 20, DARKGRAY);
|
||||||
|
|
||||||
if (collision) DrawText("BOX SELECTED", (screenWidth - MeasureText("BOX SELECTED", 30)) / 2, (int)(screenHeight * 0.1f), 30, GREEN);
|
if (collision.hit) DrawText("BOX SELECTED", (screenWidth - MeasureText("BOX SELECTED", 30)) / 2, (int)(screenHeight * 0.1f), 30, GREEN);
|
||||||
|
|
||||||
DrawFPS(10, 10);
|
DrawFPS(10, 10);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#define MAX_MODELS 6
|
#define MAX_MODELS 7
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
|
|
@ -30,7 +30,7 @@ int main(void)
|
||||||
const int screenWidth = 800;
|
const int screenWidth = 800;
|
||||||
const int screenHeight = 450;
|
const int screenHeight = 450;
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [models] example - model animation");
|
InitWindow(screenWidth, screenHeight, "raylib [models] example - model");
|
||||||
|
|
||||||
// Define the camera to look into our 3d world
|
// Define the camera to look into our 3d world
|
||||||
Camera camera = { 0 };
|
Camera camera = { 0 };
|
||||||
|
|
@ -48,6 +48,7 @@ int main(void)
|
||||||
model[3] = LoadModel("resources/gltf/BoxAnimated.glb");
|
model[3] = LoadModel("resources/gltf/BoxAnimated.glb");
|
||||||
model[4] = LoadModel("resources/gltf/AnimatedTriangle.gltf");
|
model[4] = LoadModel("resources/gltf/AnimatedTriangle.gltf");
|
||||||
model[5] = LoadModel("resources/gltf/AnimatedMorphCube.glb");
|
model[5] = LoadModel("resources/gltf/AnimatedMorphCube.glb");
|
||||||
|
model[6] = LoadModel("resources/gltf/vertex_colored_object.glb");
|
||||||
|
|
||||||
int currentModel = 0;
|
int currentModel = 0;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -98,7 +98,7 @@ int main(void)
|
||||||
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT))
|
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT))
|
||||||
{
|
{
|
||||||
// Check collision between ray and box
|
// Check collision between ray and box
|
||||||
if (CheckCollisionRayBox(GetMouseRay(GetMousePosition(), camera), bounds)) selected = !selected;
|
if (GetRayCollisionBox(GetMouseRay(GetMousePosition(), camera), bounds).hit) selected = !selected;
|
||||||
else selected = false;
|
else selected = false;
|
||||||
}
|
}
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -63,53 +63,53 @@ int main(void)
|
||||||
UpdateCamera(&camera); // Update camera
|
UpdateCamera(&camera); // Update camera
|
||||||
|
|
||||||
// Display information about closest hit
|
// Display information about closest hit
|
||||||
RayHitInfo nearestHit = { 0 };
|
RayCollision collision = { 0 };
|
||||||
char *hitObjectName = "None";
|
char *hitObjectName = "None";
|
||||||
nearestHit.distance = FLT_MAX;
|
collision.distance = FLT_MAX;
|
||||||
nearestHit.hit = false;
|
collision.hit = false;
|
||||||
Color cursorColor = WHITE;
|
Color cursorColor = WHITE;
|
||||||
|
|
||||||
// Get ray and test against ground, triangle, and mesh
|
// Get ray and test against ground, triangle, and mesh
|
||||||
ray = GetMouseRay(GetMousePosition(), camera);
|
ray = GetMouseRay(GetMousePosition(), camera);
|
||||||
|
|
||||||
// Check ray collision aginst ground plane
|
// Check ray collision aginst ground plane
|
||||||
RayHitInfo groundHitInfo = GetCollisionRayGround(ray, 0.0f);
|
RayCollision groundHitInfo = GetRayCollisionGround(ray, 0.0f);
|
||||||
|
|
||||||
if ((groundHitInfo.hit) && (groundHitInfo.distance < nearestHit.distance))
|
if ((groundHitInfo.hit) && (groundHitInfo.distance < collision.distance))
|
||||||
{
|
{
|
||||||
nearestHit = groundHitInfo;
|
collision = groundHitInfo;
|
||||||
cursorColor = GREEN;
|
cursorColor = GREEN;
|
||||||
hitObjectName = "Ground";
|
hitObjectName = "Ground";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check ray collision against test triangle
|
// Check ray collision against test triangle
|
||||||
RayHitInfo triHitInfo = GetCollisionRayTriangle(ray, ta, tb, tc);
|
RayCollision triHitInfo = GetRayCollisionTriangle(ray, ta, tb, tc);
|
||||||
|
|
||||||
if ((triHitInfo.hit) && (triHitInfo.distance < nearestHit.distance))
|
if ((triHitInfo.hit) && (triHitInfo.distance < collision.distance))
|
||||||
{
|
{
|
||||||
nearestHit = triHitInfo;
|
collision = triHitInfo;
|
||||||
cursorColor = PURPLE;
|
cursorColor = PURPLE;
|
||||||
hitObjectName = "Triangle";
|
hitObjectName = "Triangle";
|
||||||
|
|
||||||
bary = Vector3Barycenter(nearestHit.position, ta, tb, tc);
|
bary = Vector3Barycenter(collision.point, ta, tb, tc);
|
||||||
hitTriangle = true;
|
hitTriangle = true;
|
||||||
}
|
}
|
||||||
else hitTriangle = false;
|
else hitTriangle = false;
|
||||||
|
|
||||||
RayHitInfo meshHitInfo = { 0 };
|
RayCollision meshHitInfo = { 0 };
|
||||||
|
|
||||||
// Check ray collision against bounding box first, before trying the full ray-mesh test
|
// Check ray collision against bounding box first, before trying the full ray-mesh test
|
||||||
if (CheckCollisionRayBox(ray, towerBBox))
|
if (GetRayCollisionBox(ray, towerBBox).hit)
|
||||||
{
|
{
|
||||||
hitMeshBBox = true;
|
hitMeshBBox = true;
|
||||||
|
|
||||||
// Check ray collision against model
|
// Check ray collision against model
|
||||||
// NOTE: It considers model.transform matrix!
|
// NOTE: It considers model.transform matrix!
|
||||||
meshHitInfo = GetCollisionRayModel(ray, tower);
|
meshHitInfo = GetRayCollisionModel(ray, tower);
|
||||||
|
|
||||||
if ((meshHitInfo.hit) && (meshHitInfo.distance < nearestHit.distance))
|
if ((meshHitInfo.hit) && (meshHitInfo.distance < collision.distance))
|
||||||
{
|
{
|
||||||
nearestHit = meshHitInfo;
|
collision = meshHitInfo;
|
||||||
cursorColor = ORANGE;
|
cursorColor = ORANGE;
|
||||||
hitObjectName = "Mesh";
|
hitObjectName = "Mesh";
|
||||||
}
|
}
|
||||||
|
|
@ -128,7 +128,7 @@ int main(void)
|
||||||
|
|
||||||
// Draw the tower
|
// Draw the tower
|
||||||
// WARNING: If scale is different than 1.0f,
|
// WARNING: If scale is different than 1.0f,
|
||||||
// not considered by GetCollisionRayModel()
|
// not considered by GetRayCollisionModel()
|
||||||
DrawModel(tower, towerPos, 1.0f, WHITE);
|
DrawModel(tower, towerPos, 1.0f, WHITE);
|
||||||
|
|
||||||
// Draw the test triangle
|
// Draw the test triangle
|
||||||
|
|
@ -140,17 +140,17 @@ int main(void)
|
||||||
if (hitMeshBBox) DrawBoundingBox(towerBBox, LIME);
|
if (hitMeshBBox) DrawBoundingBox(towerBBox, LIME);
|
||||||
|
|
||||||
// If we hit something, draw the cursor at the hit point
|
// If we hit something, draw the cursor at the hit point
|
||||||
if (nearestHit.hit)
|
if (collision.hit)
|
||||||
{
|
{
|
||||||
DrawCube(nearestHit.position, 0.3f, 0.3f, 0.3f, cursorColor);
|
DrawCube(collision.point, 0.3f, 0.3f, 0.3f, cursorColor);
|
||||||
DrawCubeWires(nearestHit.position, 0.3f, 0.3f, 0.3f, RED);
|
DrawCubeWires(collision.point, 0.3f, 0.3f, 0.3f, RED);
|
||||||
|
|
||||||
Vector3 normalEnd;
|
Vector3 normalEnd;
|
||||||
normalEnd.x = nearestHit.position.x + nearestHit.normal.x;
|
normalEnd.x = collision.point.x + collision.normal.x;
|
||||||
normalEnd.y = nearestHit.position.y + nearestHit.normal.y;
|
normalEnd.y = collision.point.y + collision.normal.y;
|
||||||
normalEnd.z = nearestHit.position.z + nearestHit.normal.z;
|
normalEnd.z = collision.point.z + collision.normal.z;
|
||||||
|
|
||||||
DrawLine3D(nearestHit.position, normalEnd, RED);
|
DrawLine3D(collision.point, normalEnd, RED);
|
||||||
}
|
}
|
||||||
|
|
||||||
DrawRay(ray, MAROON);
|
DrawRay(ray, MAROON);
|
||||||
|
|
@ -162,21 +162,21 @@ int main(void)
|
||||||
// Draw some debug GUI text
|
// Draw some debug GUI text
|
||||||
DrawText(TextFormat("Hit Object: %s", hitObjectName), 10, 50, 10, BLACK);
|
DrawText(TextFormat("Hit Object: %s", hitObjectName), 10, 50, 10, BLACK);
|
||||||
|
|
||||||
if (nearestHit.hit)
|
if (collision.hit)
|
||||||
{
|
{
|
||||||
int ypos = 70;
|
int ypos = 70;
|
||||||
|
|
||||||
DrawText(TextFormat("Distance: %3.2f", nearestHit.distance), 10, ypos, 10, BLACK);
|
DrawText(TextFormat("Distance: %3.2f", collision.distance), 10, ypos, 10, BLACK);
|
||||||
|
|
||||||
DrawText(TextFormat("Hit Pos: %3.2f %3.2f %3.2f",
|
DrawText(TextFormat("Hit Pos: %3.2f %3.2f %3.2f",
|
||||||
nearestHit.position.x,
|
collision.point.x,
|
||||||
nearestHit.position.y,
|
collision.point.y,
|
||||||
nearestHit.position.z), 10, ypos + 15, 10, BLACK);
|
collision.point.z), 10, ypos + 15, 10, BLACK);
|
||||||
|
|
||||||
DrawText(TextFormat("Hit Norm: %3.2f %3.2f %3.2f",
|
DrawText(TextFormat("Hit Norm: %3.2f %3.2f %3.2f",
|
||||||
nearestHit.normal.x,
|
collision.normal.x,
|
||||||
nearestHit.normal.y,
|
collision.normal.y,
|
||||||
nearestHit.normal.z), 10, ypos + 30, 10, BLACK);
|
collision.normal.z), 10, ypos + 30, 10, BLACK);
|
||||||
|
|
||||||
if (hitTriangle) DrawText(TextFormat("Barycenter: %3.2f %3.2f %3.2f", bary.x, bary.y, bary.z), 10, ypos + 45, 10, BLACK);
|
if (hitTriangle) DrawText(TextFormat("Barycenter: %3.2f %3.2f %3.2f", bary.x, bary.y, bary.z), 10, ypos + 45, 10, BLACK);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ int main(void)
|
||||||
Mesh cube = GenMeshCube(1.0f, 1.0f, 1.0f);
|
Mesh cube = GenMeshCube(1.0f, 1.0f, 1.0f);
|
||||||
Model skybox = LoadModelFromMesh(cube);
|
Model skybox = LoadModelFromMesh(cube);
|
||||||
|
|
||||||
bool useHDR = false;
|
bool useHDR = true;
|
||||||
|
|
||||||
// Load skybox shader and set required locations
|
// Load skybox shader and set required locations
|
||||||
// NOTE: Some locations are automatically set at shader loading
|
// NOTE: Some locations are automatically set at shader loading
|
||||||
|
|
@ -56,12 +56,14 @@ int main(void)
|
||||||
|
|
||||||
char skyboxFileName[256] = { 0 };
|
char skyboxFileName[256] = { 0 };
|
||||||
|
|
||||||
|
Texture2D panorama;
|
||||||
|
|
||||||
if (useHDR)
|
if (useHDR)
|
||||||
{
|
{
|
||||||
TextCopy(skyboxFileName, "resources/dresden_square_2k.hdr");
|
TextCopy(skyboxFileName, "resources/dresden_square_2k.hdr");
|
||||||
|
|
||||||
// Load HDR panorama (sphere) texture
|
// Load HDR panorama (sphere) texture
|
||||||
Texture2D panorama = panorama = LoadTexture(skyboxFileName);
|
panorama = LoadTexture(skyboxFileName);
|
||||||
|
|
||||||
// Generate cubemap (texture with 6 quads-cube-mapping) from panorama HDR texture
|
// Generate cubemap (texture with 6 quads-cube-mapping) from panorama HDR texture
|
||||||
// NOTE 1: New texture is generated rendering to texture, shader calculates the sphere->cube coordinates mapping
|
// NOTE 1: New texture is generated rendering to texture, shader calculates the sphere->cube coordinates mapping
|
||||||
|
|
@ -69,7 +71,7 @@ int main(void)
|
||||||
// despite texture can be successfully created.. so using PIXELFORMAT_UNCOMPRESSED_R8G8B8A8 instead of PIXELFORMAT_UNCOMPRESSED_R32G32B32A32
|
// despite texture can be successfully created.. so using PIXELFORMAT_UNCOMPRESSED_R8G8B8A8 instead of PIXELFORMAT_UNCOMPRESSED_R32G32B32A32
|
||||||
skybox.materials[0].maps[MATERIAL_MAP_CUBEMAP].texture = GenTextureCubemap(shdrCubemap, panorama, 1024, PIXELFORMAT_UNCOMPRESSED_R8G8B8A8);
|
skybox.materials[0].maps[MATERIAL_MAP_CUBEMAP].texture = GenTextureCubemap(shdrCubemap, panorama, 1024, PIXELFORMAT_UNCOMPRESSED_R8G8B8A8);
|
||||||
|
|
||||||
UnloadTexture(panorama); // Texture not required anymore, cubemap already generated
|
//UnloadTexture(panorama); // Texture not required anymore, cubemap already generated
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -144,10 +146,10 @@ int main(void)
|
||||||
|
|
||||||
EndMode3D();
|
EndMode3D();
|
||||||
|
|
||||||
if (useHDR)
|
//DrawTextureEx(panorama, (Vector2){ 0, 0 }, 0.0f, 0.5f, WHITE);
|
||||||
DrawText(TextFormat("Panorama image from hdrihaven.com: %s", GetFileName(skyboxFileName)), 10, GetScreenHeight() - 20, 10, BLACK);
|
|
||||||
else
|
if (useHDR) DrawText(TextFormat("Panorama image from hdrihaven.com: %s", GetFileName(skyboxFileName)), 10, GetScreenHeight() - 20, 10, BLACK);
|
||||||
DrawText(TextFormat(": %s", GetFileName(skyboxFileName)), 10, GetScreenHeight() - 20, 10, BLACK);
|
else DrawText(TextFormat(": %s", GetFileName(skyboxFileName)), 10, GetScreenHeight() - 20, 10, BLACK);
|
||||||
|
|
||||||
DrawFPS(10, 10);
|
DrawFPS(10, 10);
|
||||||
|
|
||||||
|
|
@ -209,17 +211,31 @@ static TextureCubemap GenTextureCubemap(Shader shader, Texture2D panorama, int s
|
||||||
|
|
||||||
rlViewport(0, 0, size, size); // Set viewport to current fbo dimensions
|
rlViewport(0, 0, size, size); // Set viewport to current fbo dimensions
|
||||||
|
|
||||||
|
// Activate and enable texture for drawing to cubemap faces
|
||||||
|
rlActiveTextureSlot(0);
|
||||||
|
rlEnableTexture(panorama.id);
|
||||||
|
|
||||||
for (int i = 0; i < 6; i++)
|
for (int i = 0; i < 6; i++)
|
||||||
{
|
{
|
||||||
|
// Set the view matrix for the current cube face
|
||||||
rlSetUniformMatrix(shader.locs[SHADER_LOC_MATRIX_VIEW], fboViews[i]);
|
rlSetUniformMatrix(shader.locs[SHADER_LOC_MATRIX_VIEW], fboViews[i]);
|
||||||
|
|
||||||
|
// Select the current cubemap face attachment for the fbo
|
||||||
|
// WARNING: This function by default enables->attach->disables fbo!!!
|
||||||
rlFramebufferAttach(fbo, cubemap.id, RL_ATTACHMENT_COLOR_CHANNEL0, RL_ATTACHMENT_CUBEMAP_POSITIVE_X + i, 0);
|
rlFramebufferAttach(fbo, cubemap.id, RL_ATTACHMENT_COLOR_CHANNEL0, RL_ATTACHMENT_CUBEMAP_POSITIVE_X + i, 0);
|
||||||
|
|
||||||
rlEnableFramebuffer(fbo);
|
rlEnableFramebuffer(fbo);
|
||||||
rlSetTexture(panorama.id); // WARNING: It must be called after enabling current framebuffer if using internal batch system!
|
|
||||||
|
|
||||||
|
// Load and draw a cube, it uses the current enabled texture
|
||||||
rlClearScreenBuffers();
|
rlClearScreenBuffers();
|
||||||
DrawCubeV(Vector3Zero(), Vector3One(), WHITE);
|
rlLoadDrawCube();
|
||||||
rlDrawRenderBatchActive();
|
|
||||||
|
// ALTERNATIVE: Try to use internal batch system to draw the cube instead of rlLoadDrawCube
|
||||||
|
// for some reason this method does not work, maybe due to cube triangles definition? normals pointing out?
|
||||||
|
// TODO: Investigate this issue...
|
||||||
|
//rlSetTexture(panorama.id); // WARNING: It must be called after enabling current framebuffer if using internal batch system!
|
||||||
|
//rlClearScreenBuffers();
|
||||||
|
//DrawCubeV(Vector3Zero(), Vector3One(), WHITE);
|
||||||
|
//rlDrawRenderBatchActive();
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
@ -238,7 +254,7 @@ static TextureCubemap GenTextureCubemap(Shader shader, Texture2D panorama, int s
|
||||||
cubemap.width = size;
|
cubemap.width = size;
|
||||||
cubemap.height = size;
|
cubemap.height = size;
|
||||||
cubemap.mipmaps = 1;
|
cubemap.mipmaps = 1;
|
||||||
cubemap.format = PIXELFORMAT_UNCOMPRESSED_R32G32B32;
|
cubemap.format = format;
|
||||||
|
|
||||||
return cubemap;
|
return cubemap;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
BIN
examples/models/resources/gltf/vertex_colored_object.glb
Normal file
BIN
examples/models/resources/gltf/vertex_colored_object.glb
Normal file
Binary file not shown.
BIN
examples/models/resources/models/vertex_colored_object.iqm
Normal file
BIN
examples/models/resources/models/vertex_colored_object.iqm
Normal file
Binary file not shown.
|
|
@ -1,16 +1,5 @@
|
||||||
/*******************************************************************************************
|
|
||||||
*
|
|
||||||
* BRDF LUT Generation - Bidirectional reflectance distribution function fragment shader
|
|
||||||
*
|
|
||||||
* REF: https://github.com/HectorMF/BRDFGenerator
|
|
||||||
*
|
|
||||||
* Copyright (c) 2017 Victor Fisac
|
|
||||||
*
|
|
||||||
**********************************************************************************************/
|
|
||||||
|
|
||||||
#version 330
|
#version 330
|
||||||
|
|
||||||
|
|
||||||
// Input vertex attributes (from vertex shader)
|
// Input vertex attributes (from vertex shader)
|
||||||
in vec2 fragTexCoord;
|
in vec2 fragTexCoord;
|
||||||
|
|
||||||
|
|
@ -86,6 +75,8 @@ float GeometrySmith(vec3 N, vec3 V, vec3 L, float roughness)
|
||||||
return ggx1*ggx2;
|
return ggx1*ggx2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Bidirectional reflectance distribution function
|
||||||
|
// Ref: https://github.com/HectorMF/BRDFGenerator
|
||||||
vec2 IntegrateBRDF(float NdotV, float roughness)
|
vec2 IntegrateBRDF(float NdotV, float roughness)
|
||||||
{
|
{
|
||||||
float A = 0.0;
|
float A = 0.0;
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,3 @@
|
||||||
/*******************************************************************************************
|
|
||||||
*
|
|
||||||
* rPBR [shader] - Bidirectional reflectance distribution function vertex shader
|
|
||||||
*
|
|
||||||
* Copyright (c) 2017 Victor Fisac
|
|
||||||
*
|
|
||||||
**********************************************************************************************/
|
|
||||||
|
|
||||||
#version 330
|
#version 330
|
||||||
|
|
||||||
// Input vertex attributes
|
// Input vertex attributes
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,3 @@
|
||||||
/*******************************************************************************************
|
|
||||||
*
|
|
||||||
* rPBR [shader] - Equirectangular to cubemap vertex shader
|
|
||||||
*
|
|
||||||
* Copyright (c) 2017 Victor Fisac
|
|
||||||
*
|
|
||||||
**********************************************************************************************/
|
|
||||||
|
|
||||||
#version 330
|
#version 330
|
||||||
|
|
||||||
// Input vertex attributes
|
// Input vertex attributes
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,3 @@
|
||||||
/*******************************************************************************************
|
|
||||||
*
|
|
||||||
* rPBR [shader] - Irradiance cubemap fragment shader
|
|
||||||
*
|
|
||||||
* Copyright (c) 2017 Victor Fisac
|
|
||||||
*
|
|
||||||
**********************************************************************************************/
|
|
||||||
|
|
||||||
#version 330
|
#version 330
|
||||||
|
|
||||||
// Input vertex attributes (from vertex shader)
|
// Input vertex attributes (from vertex shader)
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,3 @@
|
||||||
/*******************************************************************************************
|
|
||||||
*
|
|
||||||
* rPBR [shader] - Physically based rendering fragment shader
|
|
||||||
*
|
|
||||||
* Copyright (c) 2017 Victor Fisac
|
|
||||||
*
|
|
||||||
**********************************************************************************************/
|
|
||||||
|
|
||||||
#version 330
|
#version 330
|
||||||
|
|
||||||
#define MAX_REFLECTION_LOD 4.0
|
#define MAX_REFLECTION_LOD 4.0
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,3 @@
|
||||||
/*******************************************************************************************
|
|
||||||
*
|
|
||||||
* rPBR [shader] - Physically based rendering vertex shader
|
|
||||||
*
|
|
||||||
* Copyright (c) 2017 Victor Fisac
|
|
||||||
*
|
|
||||||
**********************************************************************************************/
|
|
||||||
|
|
||||||
#version 330
|
#version 330
|
||||||
|
|
||||||
// Input vertex attributes
|
// Input vertex attributes
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,5 @@
|
||||||
/*******************************************************************************************
|
|
||||||
*
|
|
||||||
* rPBR [shader] - Prefiltered environment for reflections fragment shader
|
|
||||||
*
|
|
||||||
* Copyright (c) 2017 Victor Fisac
|
|
||||||
*
|
|
||||||
**********************************************************************************************/
|
|
||||||
|
|
||||||
#version 330
|
#version 330
|
||||||
|
|
||||||
#define MAX_SAMPLES 1024u
|
#define MAX_SAMPLES 1024u
|
||||||
#define CUBEMAP_RESOLUTION 1024.0
|
#define CUBEMAP_RESOLUTION 1024.0
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,3 @@
|
||||||
/*******************************************************************************************
|
|
||||||
*
|
|
||||||
* rPBR [shader] - Background skybox fragment shader
|
|
||||||
*
|
|
||||||
* Copyright (c) 2017 Victor Fisac
|
|
||||||
*
|
|
||||||
* 19-Jun-2020 - modified by Giuseppe Mastrangelo (@peppemas) - VFlip Support
|
|
||||||
*
|
|
||||||
**********************************************************************************************/
|
|
||||||
|
|
||||||
#version 330
|
#version 330
|
||||||
|
|
||||||
// Input vertex attributes (from vertex shader)
|
// Input vertex attributes (from vertex shader)
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,3 @@
|
||||||
/*******************************************************************************************
|
|
||||||
*
|
|
||||||
* rPBR [shader] - Background skybox vertex shader
|
|
||||||
*
|
|
||||||
* Copyright (c) 2017 Victor Fisac
|
|
||||||
*
|
|
||||||
**********************************************************************************************/
|
|
||||||
|
|
||||||
#version 330
|
#version 330
|
||||||
|
|
||||||
// Input vertex attributes
|
// Input vertex attributes
|
||||||
|
|
|
||||||
|
|
@ -191,10 +191,10 @@ int main(void)
|
||||||
Ray ray = GetMouseRay(GetMousePosition(), camera);
|
Ray ray = GetMouseRay(GetMousePosition(), camera);
|
||||||
|
|
||||||
// Check collision between ray and box
|
// Check collision between ray and box
|
||||||
bool collision = CheckCollisionRayBox(ray,
|
RayCollision collision = GetRayCollisionBox(ray,
|
||||||
(BoundingBox){(Vector3){ cubePosition.x - cubeSize.x/2, cubePosition.y - cubeSize.y/2, cubePosition.z - cubeSize.z/2 },
|
(BoundingBox){(Vector3){ cubePosition.x - cubeSize.x/2, cubePosition.y - cubeSize.y/2, cubePosition.z - cubeSize.z/2 },
|
||||||
(Vector3){ cubePosition.x + cubeSize.x/2, cubePosition.y + cubeSize.y/2, cubePosition.z + cubeSize.z/2 }});
|
(Vector3){ cubePosition.x + cubeSize.x/2, cubePosition.y + cubeSize.y/2, cubePosition.z + cubeSize.z/2 }});
|
||||||
if (collision)
|
if (collision.hit)
|
||||||
{
|
{
|
||||||
// Generate new random colors
|
// Generate new random colors
|
||||||
light = GenerateRandomColor(0.5f, 0.78f);
|
light = GenerateRandomColor(0.5f, 0.78f);
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue