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)
|
||||
*
|
||||
* 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)
|
||||
*
|
||||
* Copyright (c) 2017-2021 Ramon Santamaria (@raysan5)
|
||||
@ -40,7 +40,8 @@ int main(void)
|
||||
.interpupillaryDistance = 0.07f, // IPD (distance between pupils) in meters
|
||||
|
||||
// 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[1] = 0.22f, // Lens distortion constant parameter 1
|
||||
.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));
|
||||
|
||||
// Update distortion shader with lens and distortion-scale parameters
|
||||
SetShaderValue(distortion, GetShaderLocation(distortion, "leftLensCenter"), config.leftLensCenter, SHADER_UNIFORM_VEC2);
|
||||
SetShaderValue(distortion, GetShaderLocation(distortion, "rightLensCenter"), 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, "leftLensCenter"),
|
||||
config.leftLensCenter, SHADER_UNIFORM_VEC2);
|
||||
SetShaderValue(distortion, GetShaderLocation(distortion, "rightLensCenter"),
|
||||
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, "scaleIn"), 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);
|
||||
SetShaderValue(distortion, GetShaderLocation(distortion, "scale"),
|
||||
config.scale, SHADER_UNIFORM_VEC2);
|
||||
SetShaderValue(distortion, GetShaderLocation(distortion, "scaleIn"),
|
||||
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
|
||||
// NOTE: Screen size should match HMD aspect ratio
|
||||
@ -108,7 +117,6 @@ int main(void)
|
||||
|
||||
DrawCube(cubePosition, 2.0f, 2.0f, 2.0f, RED);
|
||||
DrawCubeWires(cubePosition, 2.0f, 2.0f, 2.0f, MAROON);
|
||||
|
||||
DrawGrid(40, 1.0f);
|
||||
|
||||
EndMode3D();
|
||||
@ -116,7 +124,8 @@ int main(void)
|
||||
EndTextureMode();
|
||||
|
||||
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();
|
||||
|
||||
DrawFPS(10, 10);
|
||||
|
Loading…
Reference in New Issue
Block a user