actually add vendor folder

This commit is contained in:
2025-08-30 18:07:11 +02:00
parent cb954445a2
commit f9b0bca4be
1074 changed files with 457227 additions and 0 deletions
+54
View File
@@ -0,0 +1,54 @@
/*******************************************************************************************
*
* raylib [core] example - Basic window
*
* Welcome to raylib!
*
* To test examples, just press F6 and execute raylib_compile_execute script
* Note that compiled executable is placed in the same folder as .c file
*
* You can find all basic examples on C:\raylib\raylib\examples folder or
* raylib official webpage: www.raylib.com
*
* Enjoy using raylib. :)
*
* This example has been created using raylib 1.0 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*
* Copyright (c) 2014 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
#include "raylib-cpp.hpp"
int main() {
// Initialization
//--------------------------------------------------------------------------------------
int screenWidth = 800;
int screenHeight = 450;
raylib::Color textColor = raylib::Color::LightGray();
raylib::Window window(screenWidth, screenHeight, "raylib [core] example - basic window");
SetTargetFPS(60);
//--------------------------------------------------------------------------------------
// Main game loop
while (!window.ShouldClose()) { // Detect window close button or ESC key
// Update
//----------------------------------------------------------------------------------
// Update your variables here
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
{
window.ClearBackground(RAYWHITE);
textColor.DrawText("Congrats! You created your first window!", 190, 200, 20);
}
EndDrawing();
//----------------------------------------------------------------------------------
}
return 0;
}
@@ -0,0 +1,78 @@
/*******************************************************************************************
*
* raylib-cpp [core] example - Basic window (adapted for HTML5 platform)
*
* This example is prepared to compile for PLATFORM_WEB, PLATFORM_DESKTOP and PLATFORM_RPI
* As you will notice, code structure is slightly diferent to the other examples...
* To compile it for PLATFORM_WEB just uncomment #define PLATFORM_WEB at beginning
*
* This example has been created using raylib 1.3 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*
* Copyright (c) 2015 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
#include "raylib-cpp.hpp"
#if defined(PLATFORM_WEB)
#include <emscripten/emscripten.h>
#endif
//----------------------------------------------------------------------------------
// Global Variables Definition
//----------------------------------------------------------------------------------
int screenWidth = 800;
int screenHeight = 450;
//----------------------------------------------------------------------------------
// Module Functions Declaration
//----------------------------------------------------------------------------------
void UpdateDrawFrame(void); // Update and Draw one frame
//----------------------------------------------------------------------------------
// Main Enry Point
//----------------------------------------------------------------------------------
int main()
{
// Initialization
//--------------------------------------------------------------------------------------
raylib::Window window(screenWidth, screenHeight, "raylib-cpp [core] example - basic window");
#if defined(PLATFORM_WEB)
emscripten_set_main_loop(UpdateDrawFrame, 0, 1);
#else
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
// Main game loop
while (!window.ShouldClose()) // Detect window close button or ESC key
{
UpdateDrawFrame();
}
#endif
return 0;
}
//----------------------------------------------------------------------------------
// Module Functions Definition
//----------------------------------------------------------------------------------
void UpdateDrawFrame(void)
{
// Update
//----------------------------------------------------------------------------------
// TODO: Update your variables here
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(RAYWHITE);
raylib::DrawText("Congrats! You created your first raylib-cpp window!", 190, 200, 20, LIGHTGRAY);
EndDrawing();
//----------------------------------------------------------------------------------
}
+69
View File
@@ -0,0 +1,69 @@
/*******************************************************************************************
*
* raylib [core] example - Windows drop files
*
* This example only works on platforms that support drag & drop (Windows, Linux, OSX, Html5?)
*
* This example has been created using raylib-cpp (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*
* Copyright (c) 2020 Rob Loach (@RobLoach)
*
********************************************************************************************/
#include "raylib-cpp.hpp"
int main() {
// Initialization
//--------------------------------------------------------------------------------------
const int screenWidth = 800;
const int screenHeight = 450;
raylib::Window window(screenWidth, screenHeight, "raylib [core] example - drop files");
std::vector<std::string> droppedFiles;
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
// Main game loop
while (!window.ShouldClose()) { // Detect window close button or ESC key
// Update
//----------------------------------------------------------------------------------
if (IsFileDropped()) {
droppedFiles = raylib::LoadDroppedFiles();
}
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
{
window.ClearBackground(RAYWHITE);
// Check if there are files to process.
if (droppedFiles.empty()) {
raylib::DrawText("Drop your files to this window!", 100, 40, 20, DARKGRAY);
} else {
raylib::DrawText("Dropped files:", 100, 40, 20, DARKGRAY);
// Iterate through all the dropped files.
for (int i = 0; i < droppedFiles.size(); i++) {
if (i % 2 == 0)
DrawRectangle(0, 85 + 40*i, screenWidth, 40, Fade(LIGHTGRAY, 0.5f));
else
DrawRectangle(0, 85 + 40*i, screenWidth, 40, Fade(LIGHTGRAY, 0.3f));
// Display the path to the dropped file.
raylib::DrawText(droppedFiles[i].c_str(), 120, 100 + 40 * i, 10, GRAY);
}
raylib::DrawText("Drop new files...", 100, 110 + 40 * droppedFiles.size(), 20, DARKGRAY);
}
}
EndDrawing();
//----------------------------------------------------------------------------------
}
return 0;
}
+55
View File
@@ -0,0 +1,55 @@
/*******************************************************************************************
*
* raylib [core] example - Mouse input
*
* This example has been created using raylib 1.0 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*
* Copyright (c) 2014 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
#include "raylib-cpp.hpp"
int main() {
// Initialization
//--------------------------------------------------------------------------------------
const int screenWidth = 800;
const int screenHeight = 450;
raylib::Window window(screenWidth, screenHeight, "raylib [core] example - mouse input");
raylib::Vector2 ballPosition(-100.0f, -100.0f);
raylib::Color ballColor = raylib::Color::DarkBlue();
raylib::Color textColor = raylib::Color::DarkGray();
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//---------------------------------------------------------------------------------------
// Main game loop
while (!window.ShouldClose()) { // Detect window close button or ESC key
// Update
//----------------------------------------------------------------------------------
ballPosition = GetMousePosition();
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) ballColor = MAROON;
else if (IsMouseButtonPressed(MOUSE_MIDDLE_BUTTON)) ballColor = LIME;
else if (IsMouseButtonPressed(MOUSE_RIGHT_BUTTON)) ballColor = DARKBLUE;
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
{
window.ClearBackground(RAYWHITE);
ballPosition.DrawCircle(40, ballColor);
textColor.DrawText("move ball with mouse and click mouse button to change color", 10, 10, 20);
}
EndDrawing();
//----------------------------------------------------------------------------------
}
return 0;
}
+150
View File
@@ -0,0 +1,150 @@
/*******************************************************************************
*
* raylib example - loading thread
*
* This example has been created using raylib-cpp (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license
* (View raylib.h for details)
*
* Copyright (c) 2014-2019 Ramon Santamaria (@raysan5)
* Copyright (c) 2021 Paul Keir (University of the West of Scotland)
*
*******************************************************************************/
#include <thread> // C++11 standard library threads
#include <atomic> // C++ atomic data types
#include <chrono> // For: chrono::steady_clock::now()
#include <system_error> // May be thrown by thread c'tor
#include "raylib-cpp.hpp"
// Using C++ std::atomic_bool (aka. std::atomic<bool>) for synchronization.
// n.b. A plain built-in type can't be used for inter-thread synchronization
std::atomic_bool dataLoaded{false};
static void LoadDataThread(); // Loading data thread function declaration
static int dataProgress = 0; // Data progress accumulator
int main(void)
{
// Initialization
//--------------------------------------------------------------------------
const int screenWidth = 800;
const int screenHeight = 450;
raylib::Window window(screenWidth, screenHeight,
"raylib [core] example - loading thread");
std::thread threadId; // Loading data thread id
enum { STATE_WAITING, STATE_LOADING, STATE_FINISHED } state = STATE_WAITING;
int framesCounter = 0;
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------
// Main game loop
while (!window.ShouldClose()) { // Detect window close button or ESC key
// Update
//----------------------------------------------------------------------
switch (state)
{
case STATE_WAITING:
if (IsKeyPressed(KEY_ENTER))
{
try {
threadId = std::thread(LoadDataThread);
TraceLog(LOG_INFO,
"Loading thread initialized successfully");
} catch (std::system_error e) {
TraceLog(LOG_ERROR, "Error: %s", e.what());
}
state = STATE_LOADING;
}
break;
case STATE_LOADING:
framesCounter++;
if (dataLoaded.load())
{
framesCounter = 0;
state = STATE_FINISHED;
}
break;
case STATE_FINISHED:
if (IsKeyPressed(KEY_ENTER))
{
// Reset everything to launch again
dataLoaded = false;
dataProgress = 0;
state = STATE_WAITING;
}
break;
default:
break;
}
//----------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------
BeginDrawing();
{
window.ClearBackground(RAYWHITE);
switch (state)
{
case STATE_WAITING:
raylib::DrawText("PRESS ENTER to START LOADING DATA",
150, 170, 20, DARKGRAY);
break;
case STATE_LOADING:
DrawRectangle(150, 200, dataProgress, 60, SKYBLUE);
if ((framesCounter/15)%2)
raylib::DrawText("LOADING DATA...", 240, 210, 40, DARKBLUE);
break;
case STATE_FINISHED:
DrawRectangle(150, 200, 500, 60, LIME);
raylib::DrawText("DATA LOADED!", 250, 210, 40, GREEN);
break;
}
DrawRectangleLines(150, 200, 500, 60, DARKGRAY);
}
EndDrawing();
//----------------------------------------------------------------------
}
if (threadId.joinable()) // The user might quit without creating a thread.
threadId.join(); // Good etiquette, but may take a second.
return 0;
}
// Loading data thread function definition
static void LoadDataThread()
{
using namespace std::chrono;
int timeCounter = 0; // Time counted in ms
auto prevTime = steady_clock::now();
// We simulate data loading with a time counter for 5 seconds
while (timeCounter < 5000)
{
auto currentTime = steady_clock::now() - prevTime;
timeCounter = duration_cast<milliseconds>(currentTime).count();
// We accumulate time over a global variable to be used in
// main thread as a progress bar
dataProgress = timeCounter/10;
}
// When data has finished loading, we set global variable
dataLoaded = true;
}
+57
View File
@@ -0,0 +1,57 @@
/*******************************************************************************************
*
* raylib [core] example - Generate random values
*
* This example has been created using raylib 1.1 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*
* Copyright (c) 2014 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
#include "raylib-cpp.hpp"
int main() {
// Initialization
//--------------------------------------------------------------------------------------
const int screenWidth = 800;
const int screenHeight = 450;
raylib::Window window(screenWidth, screenHeight, "raylib [core] example - generate random values");
int framesCounter = 0; // Variable used to count frames
int randValue = GetRandomValue(-8, 5); // Get a random integer number between -8 and 5 (both included)
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
// Main game loop
while (!window.ShouldClose()) { // Detect window close button or ESC key
// Update
//----------------------------------------------------------------------------------
framesCounter++;
// Every two seconds (120 frames) a new random value is generated
if (((framesCounter / 120) % 2) == 1) {
randValue = GetRandomValue(-8, 5);
framesCounter = 0;
}
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
{
window.ClearBackground(RAYWHITE);
raylib::DrawText("Every 2 seconds a new random value is generated:", 130, 100, 20, MAROON);
raylib::DrawText(TextFormat("%i", randValue), 360, 180, 80, LIGHTGRAY);
}
EndDrawing();
//----------------------------------------------------------------------------------
}
return 0;
}
@@ -0,0 +1,108 @@
/*******************************************************************************************
*
* raylib [core] example - window scale letterbox (and virtual mouse)
*
* Example originally created with raylib 2.5, last time updated with raylib 4.0
*
* Example contributed by Anata (@anatagawa) and reviewed by Ramon Santamaria (@raysan5)
*
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
* Copyright (c) 2019-2023 Anata (@anatagawa) and Ramon Santamaria (@raysan5)
*
********************************************************************************************/
#include "raylib-cpp.hpp"
#include "raymath.hpp" // Required for: Vector2Clamp()
#define MAX(a, b) ((a)>(b)? (a) : (b))
#define MIN(a, b) ((a)<(b)? (a) : (b))
//------------------------------------------------------------------------------------
// Program main entry point
//------------------------------------------------------------------------------------
int main(void)
{
const int windowWidth = 800;
const int windowHeight = 450;
// Enable config flags for resizable window and vertical synchro
raylib::Window window(windowWidth, windowHeight,
"raylib [core] example - window scale letterbox",
FLAG_WINDOW_RESIZABLE | FLAG_VSYNC_HINT);
window.SetMinSize(320, 240);
int gameScreenWidth = 640;
int gameScreenHeight = 480;
// Render texture initialization, used to hold the rendering result so we can easily resize it
raylib::RenderTexture2D target(gameScreenWidth, gameScreenHeight);
target.GetTexture().SetFilter(TEXTURE_FILTER_BILINEAR); // Texture scale filter to use
raylib::Color colors[10] = { 0 };
for (int i = 0; i < 10; i++) {
colors[i] = raylib::Color((unsigned char)GetRandomValue(100, 250), (unsigned char)GetRandomValue(50, 150), (unsigned char)GetRandomValue(10, 100), 255);
}
window.SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
// Main game loop
while (!window.ShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
// Compute required framebuffer scaling
float scale = MIN((float)GetScreenWidth()/gameScreenWidth, (float)GetScreenHeight()/gameScreenHeight);
if (IsKeyPressed(KEY_SPACE))
{
// Recalculate random colors for the bars
for (int i = 0; i < 10; i++) colors[i] = (Color){ (unsigned char)GetRandomValue(100, 250), (unsigned char)GetRandomValue(50, 150), (unsigned char)GetRandomValue(10, 100), 255 };
}
// Update virtual mouse (clamped mouse value behind game screen)
raylib::Vector2 mouse = raylib::Mouse::GetPosition();
raylib::Vector2 virtualMouse(
(mouse.x - (GetScreenWidth() - (gameScreenWidth*scale))*0.5f)/scale,
(mouse.y - (GetScreenHeight() - (gameScreenHeight*scale))*0.5f)/scale
);
virtualMouse = virtualMouse.Clamp(raylib::Vector2::Zero(), raylib::Vector2(gameScreenWidth, gameScreenHeight));
// Apply the same transformation as the virtual mouse to the real mouse (i.e. to work with raygui)
//SetMouseOffset(-(GetScreenWidth() - (gameScreenWidth*scale))*0.5f, -(GetScreenHeight() - (gameScreenHeight*scale))*0.5f);
//SetMouseScale(1/scale, 1/scale);
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
// Draw everything in the render texture, note this will not be rendered on screen, yet
target.BeginMode();
ClearBackground(RAYWHITE); // Clear render texture background color
for (int i = 0; i < 10; i++) DrawRectangle(0, (gameScreenHeight/10)*i, gameScreenWidth, gameScreenHeight/10, colors[i]);
DrawText("If executed inside a window,\nyou can resize the window,\nand see the screen scaling!", 10, 25, 20, WHITE);
DrawText(TextFormat("Default Mouse: [%i , %i]", (int)mouse.x, (int)mouse.y), 350, 25, 20, GREEN);
DrawText(TextFormat("Virtual Mouse: [%i , %i]", (int)virtualMouse.x, (int)virtualMouse.y), 350, 55, 20, YELLOW);
target.EndMode();
BeginDrawing();
ClearBackground(BLACK); // Clear screen background
// Draw render texture to screen, properly scaled
target.GetTexture().Draw(raylib::Rectangle(0.0f, 0.0f, target.texture.width, -target.texture.height),
raylib::Rectangle(
(GetScreenWidth() - (gameScreenWidth*scale))*0.5f,
(GetScreenHeight() - (gameScreenHeight*scale))*0.5f,
gameScreenWidth*scale, gameScreenHeight*scale
),
raylib::Vector2::Zero(), 0.0f, WHITE);
EndDrawing();
//--------------------------------------------------------------------------------------
}
return 0;
}
+74
View File
@@ -0,0 +1,74 @@
/*******************************************************************************************
*
* raylib [core] example - World to screen
*
* This example has been created using raylib 1.3 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*
* Copyright (c) 2015 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
#include "raylib-cpp.hpp"
int main() {
// Initialization
//--------------------------------------------------------------------------------------
const int screenWidth = 800;
const int screenHeight = 450;
raylib::Window window(screenWidth, screenHeight, "raylib [core] example - 3d camera free");
// Define the camera to look into our 3d world
raylib::Camera camera(
raylib::Vector3(10.0f, 10.0f, 10.0f),
raylib::Vector3(),
raylib::Vector3(0.0f, 1.0f, 0.0f),
45.0f,
CAMERA_PERSPECTIVE);
Vector3 cubePosition;
Vector2 cubeScreenPosition;
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
// Main game loop
while (!window.ShouldClose()) { // Detect window close button or ESC key
// Update
//----------------------------------------------------------------------------------
camera.Update(CAMERA_THIRD_PERSON); // Update camera
// Calculate cube screen space position (with a little offset to be in top)
cubeScreenPosition = GetWorldToScreen(Vector3{cubePosition.x, cubePosition.y + 2.5f, cubePosition.z}, camera);
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
{
window.ClearBackground(RAYWHITE);
camera.BeginMode();
{
DrawCube(cubePosition, 2.0f, 2.0f, 2.0f, RED);
DrawCubeWires(cubePosition, 2.0f, 2.0f, 2.0f, MAROON);
DrawGrid(10, 1.0f);
}
camera.EndMode();
raylib::DrawText("Enemy: 100 / 100",
cubeScreenPosition.x - MeasureText("Enemy: 100/100", 20) / 2,
cubeScreenPosition.y, 20,
BLACK);
raylib::DrawText("Text is always on top of the cube",
(screenWidth - MeasureText("Text is always on top of the cube", 20)) / 2,
25, 20, GRAY);
}
EndDrawing();
//----------------------------------------------------------------------------------
}
return 0;
}
+4
View File
@@ -0,0 +1,4 @@
| resource | author | licence | notes |
| :------------ | :---------: | :------ | :---- |
| ps3.png | [@raysan5](https://github.com/raysan5) | [CC0](https://creativecommons.org/publicdomain/zero/1.0/) | - |
| xbox.png | [@raysan5](https://github.com/raysan5) | [CC0](https://creativecommons.org/publicdomain/zero/1.0/) | - |
@@ -0,0 +1,57 @@
<!DOCTYPE html>
<html>
<head>
<title>raylib-cpp [core] example - basic window</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="title" content="raylib-cpp [core] example - basic window">
<meta name="description" content="raylib is a simple and easy-to-use library to enjoy videogames programming. This a small example of what you can do.">
<meta name="viewport" content="width=device-width">
<style>
body {
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
margin: 0;
padding: 0;
background-color: black;
display: flex;
justify-content: center;
align-items: center;
}
body canvas {
object-fit: contain;
max-height: 100%;
max-width: 100%;
}
</style>
<script type='text/javascript' src="https://cdn.jsdelivr.net/gh/eligrey/FileSaver.js/dist/FileSaver.min.js"> </script>
<script type='text/javascript'>
function saveFileFromMEMFSToDisk(memoryFSname, localFSname) {
var isSafari = false;
var data = FS.readFile(memoryFSname);
var blob;
if (isSafari) blob = new Blob([data.buffer], { type: "application/octet-stream" });
else blob = new Blob([data.buffer], { type: "application/octet-binary" });
saveAs(blob, localFSname);
}
</script>
</head>
<body>
<canvas id="canvas" width="800" height="450"></canvas>
<script>
var Module = {
print: console.log,
printErr: console.error,
canvas: (function() {
return document.getElementById('canvas');
})()
}
</script>
<script type="text/javascript" src="../core_basic_window_web.js"></script>
</body>
</html>
@@ -0,0 +1,52 @@
#version 100
precision mediump float;
// Input vertex attributes (from vertex shader)
varying vec2 fragTexCoord;
varying vec4 fragColor;
// Input uniform values
uniform sampler2D texture0;
uniform vec4 colDiffuse;
// NOTE: Add here your custom variables
uniform vec2 leftLensCenter;
uniform vec2 rightLensCenter;
uniform vec2 leftScreenCenter;
uniform vec2 rightScreenCenter;
uniform vec2 scale;
uniform vec2 scaleIn;
uniform vec4 hmdWarpParam;
uniform vec4 chromaAbParam;
void main()
{
// Compute lens distortion
vec2 lensCenter = fragTexCoord.x < 0.5? leftLensCenter : rightLensCenter;
vec2 screenCenter = fragTexCoord.x < 0.5? leftScreenCenter : rightScreenCenter;
vec2 theta = (fragTexCoord - lensCenter)*scaleIn;
float rSq = theta.x*theta.x + theta.y*theta.y;
vec2 theta1 = theta*(hmdWarpParam.x + hmdWarpParam.y*rSq + hmdWarpParam.z*rSq*rSq + hmdWarpParam.w*rSq*rSq*rSq);
vec2 thetaBlue = theta1*(chromaAbParam.z + chromaAbParam.w*rSq);
vec2 tcBlue = lensCenter + scale*thetaBlue;
if (any(bvec2(clamp(tcBlue, screenCenter - vec2(0.25, 0.5), screenCenter + vec2(0.25, 0.5)) - tcBlue)))
{
// Set black fragment for everything outside the lens border
gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);
}
else
{
// Compute color chroma aberration
float blue = texture2D(texture0, tcBlue).b;
vec2 tcGreen = lensCenter + scale*theta1;
float green = texture2D(texture0, tcGreen).g;
vec2 thetaRed = theta1*(chromaAbParam.x + chromaAbParam.y*rSq);
vec2 tcRed = lensCenter + scale*thetaRed;
float red = texture2D(texture0, tcRed).r;
gl_FragColor = vec4(red, green, blue, 1.0);
}
}
@@ -0,0 +1,53 @@
#version 330
// Input vertex attributes (from vertex shader)
in vec2 fragTexCoord;
in vec4 fragColor;
// Input uniform values
uniform sampler2D texture0;
uniform vec4 colDiffuse;
// Output fragment color
out vec4 finalColor;
// NOTE: Add here your custom variables
uniform vec2 leftLensCenter = vec2(0.288, 0.5);
uniform vec2 rightLensCenter = vec2(0.712, 0.5);
uniform vec2 leftScreenCenter = vec2(0.25, 0.5);
uniform vec2 rightScreenCenter = vec2(0.75, 0.5);
uniform vec2 scale = vec2(0.25, 0.45);
uniform vec2 scaleIn = vec2(4, 2.2222);
uniform vec4 hmdWarpParam = vec4(1, 0.22, 0.24, 0);
uniform vec4 chromaAbParam = vec4(0.996, -0.004, 1.014, 0.0);
void main()
{
// Compute lens distortion
vec2 lensCenter = fragTexCoord.x < 0.5? leftLensCenter : rightLensCenter;
vec2 screenCenter = fragTexCoord.x < 0.5? leftScreenCenter : rightScreenCenter;
vec2 theta = (fragTexCoord - lensCenter)*scaleIn;
float rSq = theta.x*theta.x + theta.y*theta.y;
vec2 theta1 = theta*(hmdWarpParam.x + hmdWarpParam.y*rSq + hmdWarpParam.z*rSq*rSq + hmdWarpParam.w*rSq*rSq*rSq);
vec2 thetaBlue = theta1*(chromaAbParam.z + chromaAbParam.w*rSq);
vec2 tcBlue = lensCenter + scale*thetaBlue;
if (any(bvec2(clamp(tcBlue, screenCenter - vec2(0.25, 0.5), screenCenter + vec2(0.25, 0.5)) - tcBlue)))
{
// Set black fragment for everything outside the lens border
finalColor = vec4(0.0, 0.0, 0.0, 1.0);
}
else
{
// Compute color chroma aberration
float blue = texture(texture0, tcBlue).b;
vec2 tcGreen = lensCenter + scale*theta1;
float green = texture(texture0, tcGreen).g;
vec2 thetaRed = theta1*(chromaAbParam.x + chromaAbParam.y*rSq);
vec2 tcRed = lensCenter + scale*thetaRed;
float red = texture(texture0, tcRed).r;
finalColor = vec4(red, green, blue, 1.0);
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB