Update core_vr_simulator.c
This commit is contained in:
parent
6719c3a1cd
commit
ed96bc6441
@ -2,7 +2,7 @@
|
|||||||
*
|
*
|
||||||
* raylib [core] example - VR Simulator (Oculus Rift CV1 parameters)
|
* raylib [core] example - VR Simulator (Oculus Rift CV1 parameters)
|
||||||
*
|
*
|
||||||
* This example has been created using raylib 3.6-dev (www.raylib.com)
|
* This example has been created using raylib 3.7 (www.raylib.com)
|
||||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||||
*
|
*
|
||||||
* Copyright (c) 2017-2021 Ramon Santamaria (@raysan5)
|
* Copyright (c) 2017-2021 Ramon Santamaria (@raysan5)
|
||||||
@ -40,7 +40,8 @@ int main(void)
|
|||||||
.interpupillaryDistance = 0.07f, // IPD (distance between pupils) in meters
|
.interpupillaryDistance = 0.07f, // IPD (distance between pupils) in meters
|
||||||
|
|
||||||
// NOTE: CV1 uses a Fresnel-hybrid-asymmetric lenses with specific distortion compute shaders
|
// NOTE: CV1 uses a Fresnel-hybrid-asymmetric lenses with specific distortion compute shaders
|
||||||
// Following parameters are an approximation to distortion stereo rendering but results differ from actual device
|
// Following parameters are an approximation to distortion stereo rendering
|
||||||
|
// but results differ from actual device
|
||||||
.lensDistortionValues[0] = 1.0f, // Lens distortion constant parameter 0
|
.lensDistortionValues[0] = 1.0f, // Lens distortion constant parameter 0
|
||||||
.lensDistortionValues[1] = 0.22f, // Lens distortion constant parameter 1
|
.lensDistortionValues[1] = 0.22f, // Lens distortion constant parameter 1
|
||||||
.lensDistortionValues[2] = 0.24f, // Lens distortion constant parameter 2
|
.lensDistortionValues[2] = 0.24f, // Lens distortion constant parameter 2
|
||||||
@ -58,15 +59,23 @@ int main(void)
|
|||||||
Shader distortion = LoadShader(0, TextFormat("resources/distortion%i.fs", GLSL_VERSION));
|
Shader distortion = LoadShader(0, TextFormat("resources/distortion%i.fs", GLSL_VERSION));
|
||||||
|
|
||||||
// Update distortion shader with lens and distortion-scale parameters
|
// Update distortion shader with lens and distortion-scale parameters
|
||||||
SetShaderValue(distortion, GetShaderLocation(distortion, "leftLensCenter"), config.leftLensCenter, SHADER_UNIFORM_VEC2);
|
SetShaderValue(distortion, GetShaderLocation(distortion, "leftLensCenter"),
|
||||||
SetShaderValue(distortion, GetShaderLocation(distortion, "rightLensCenter"), config.rightLensCenter, SHADER_UNIFORM_VEC2);
|
config.leftLensCenter, SHADER_UNIFORM_VEC2);
|
||||||
SetShaderValue(distortion, GetShaderLocation(distortion, "leftScreenCenter"), config.leftScreenCenter, SHADER_UNIFORM_VEC2);
|
SetShaderValue(distortion, GetShaderLocation(distortion, "rightLensCenter"),
|
||||||
SetShaderValue(distortion, GetShaderLocation(distortion, "rightScreenCenter"), config.rightScreenCenter, SHADER_UNIFORM_VEC2);
|
config.rightLensCenter, SHADER_UNIFORM_VEC2);
|
||||||
|
SetShaderValue(distortion, GetShaderLocation(distortion, "leftScreenCenter"),
|
||||||
|
config.leftScreenCenter, SHADER_UNIFORM_VEC2);
|
||||||
|
SetShaderValue(distortion, GetShaderLocation(distortion, "rightScreenCenter"),
|
||||||
|
config.rightScreenCenter, SHADER_UNIFORM_VEC2);
|
||||||
|
|
||||||
SetShaderValue(distortion, GetShaderLocation(distortion, "scale"), config.scale, SHADER_UNIFORM_VEC2);
|
SetShaderValue(distortion, GetShaderLocation(distortion, "scale"),
|
||||||
SetShaderValue(distortion, GetShaderLocation(distortion, "scaleIn"), config.scaleIn, SHADER_UNIFORM_VEC2);
|
config.scale, SHADER_UNIFORM_VEC2);
|
||||||
SetShaderValue(distortion, GetShaderLocation(distortion, "deviceWarpParam"), device.lensDistortionValues, SHADER_UNIFORM_VEC4);
|
SetShaderValue(distortion, GetShaderLocation(distortion, "scaleIn"),
|
||||||
SetShaderValue(distortion, GetShaderLocation(distortion, "chromaAbParam"), device.chromaAbCorrection, SHADER_UNIFORM_VEC4);
|
config.scaleIn, SHADER_UNIFORM_VEC2);
|
||||||
|
SetShaderValue(distortion, GetShaderLocation(distortion, "deviceWarpParam"),
|
||||||
|
device.lensDistortionValues, SHADER_UNIFORM_VEC4);
|
||||||
|
SetShaderValue(distortion, GetShaderLocation(distortion, "chromaAbParam"),
|
||||||
|
device.chromaAbCorrection, SHADER_UNIFORM_VEC4);
|
||||||
|
|
||||||
// Initialize framebuffer for stereo rendering
|
// Initialize framebuffer for stereo rendering
|
||||||
// NOTE: Screen size should match HMD aspect ratio
|
// NOTE: Screen size should match HMD aspect ratio
|
||||||
@ -108,7 +117,6 @@ int main(void)
|
|||||||
|
|
||||||
DrawCube(cubePosition, 2.0f, 2.0f, 2.0f, RED);
|
DrawCube(cubePosition, 2.0f, 2.0f, 2.0f, RED);
|
||||||
DrawCubeWires(cubePosition, 2.0f, 2.0f, 2.0f, MAROON);
|
DrawCubeWires(cubePosition, 2.0f, 2.0f, 2.0f, MAROON);
|
||||||
|
|
||||||
DrawGrid(40, 1.0f);
|
DrawGrid(40, 1.0f);
|
||||||
|
|
||||||
EndMode3D();
|
EndMode3D();
|
||||||
@ -116,7 +124,8 @@ int main(void)
|
|||||||
EndTextureMode();
|
EndTextureMode();
|
||||||
|
|
||||||
BeginShaderMode(distortion);
|
BeginShaderMode(distortion);
|
||||||
DrawTextureRec(target.texture, (Rectangle){ 0, 0, (float)target.texture.width, (float)-target.texture.height }, (Vector2){ 0.0f, 0.0f }, WHITE);
|
DrawTextureRec(target.texture, (Rectangle){ 0, 0, (float)target.texture.width,
|
||||||
|
(float)-target.texture.height }, (Vector2){ 0.0f, 0.0f }, WHITE);
|
||||||
EndShaderMode();
|
EndShaderMode();
|
||||||
|
|
||||||
DrawFPS(10, 10);
|
DrawFPS(10, 10);
|
||||||
|
Loading…
Reference in New Issue
Block a user