From ed96bc64412e01392026230d817d6fb316cd4035 Mon Sep 17 00:00:00 2001 From: Ray Date: Wed, 7 Apr 2021 12:24:43 +0200 Subject: [PATCH] Update core_vr_simulator.c --- examples/core/core_vr_simulator.c | 35 +++++++++++++++++++------------ 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/examples/core/core_vr_simulator.c b/examples/core/core_vr_simulator.c index 091b2fc90..2f69f7c15 100644 --- a/examples/core/core_vr_simulator.c +++ b/examples/core/core_vr_simulator.c @@ -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, "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, "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); // 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);