From 4acbb81413d1da763d967697b371d5df72103eae Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Mon, 12 Jun 2017 15:38:49 -0700 Subject: [PATCH 1/7] Checkpoint --- interface/src/SecondaryCamera.cpp | 7 ++++++- libraries/shared/src/RenderArgs.h | 2 +- scripts/system/spectatorCamera.js | 29 +++++++++++++++-------------- 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/interface/src/SecondaryCamera.cpp b/interface/src/SecondaryCamera.cpp index 0af51bb2c4..3f3d02af42 100644 --- a/interface/src/SecondaryCamera.cpp +++ b/interface/src/SecondaryCamera.cpp @@ -62,13 +62,14 @@ public: gpu::FramebufferPointer destFramebuffer; destFramebuffer = textureCache->getSpectatorCameraFramebuffer(); // FIXME: Change the destination based on some unimplemented config var if (destFramebuffer) { - // Caching/restoring the old values doesn't seem to be needed. Is it because we happen to be last in the pipeline (which would be a bug waiting to happen)? _cachedArgsPointer->_blitFramebuffer = args->_blitFramebuffer; _cachedArgsPointer->_viewport = args->_viewport; _cachedArgsPointer->_displayMode = args->_displayMode; + _cachedArgsPointer->_renderMode = args->_renderMode; args->_blitFramebuffer = destFramebuffer; args->_viewport = glm::ivec4(0, 0, destFramebuffer->getWidth(), destFramebuffer->getHeight()); args->_displayMode = RenderArgs::MONO; + args->_renderMode = RenderArgs::SECONDARY_CAMERA_RENDER_MODE; gpu::doInBatch(args->_context, [&](gpu::Batch& batch) { batch.disableContextStereo(); @@ -77,6 +78,9 @@ public: auto srcViewFrustum = args->getViewFrustum(); srcViewFrustum.setPosition(_position); srcViewFrustum.setOrientation(_orientation); + // Without calculating the bound planes, the secondary camera will use the same culling frustum as the main camera, + // which is not what we want here. + srcViewFrustum.calculate(); args->pushViewFrustum(srcViewFrustum); cachedArgs = _cachedArgsPointer; } @@ -97,6 +101,7 @@ public: args->_viewport = cachedArgs->_viewport; args->popViewFrustum(); args->_displayMode = cachedArgs->_displayMode; + args->_renderMode = cachedArgs->_renderMode; gpu::doInBatch(args->_context, [&](gpu::Batch& batch) { batch.restoreContextStereo(); diff --git a/libraries/shared/src/RenderArgs.h b/libraries/shared/src/RenderArgs.h index d4d88c26a8..f869a93e1f 100644 --- a/libraries/shared/src/RenderArgs.h +++ b/libraries/shared/src/RenderArgs.h @@ -75,7 +75,7 @@ public: class RenderArgs { public: - enum RenderMode { DEFAULT_RENDER_MODE, SHADOW_RENDER_MODE, DIFFUSE_RENDER_MODE, NORMAL_RENDER_MODE, MIRROR_RENDER_MODE }; + enum RenderMode { DEFAULT_RENDER_MODE, SHADOW_RENDER_MODE, DIFFUSE_RENDER_MODE, NORMAL_RENDER_MODE, MIRROR_RENDER_MODE, SECONDARY_CAMERA_RENDER_MODE }; enum DisplayMode { MONO, STEREO_MONITOR, STEREO_HMD }; enum DebugFlags { RENDER_DEBUG_NONE = 0, diff --git a/scripts/system/spectatorCamera.js b/scripts/system/spectatorCamera.js index ea934bd83c..9e83be1a0e 100644 --- a/scripts/system/spectatorCamera.js +++ b/scripts/system/spectatorCamera.js @@ -22,7 +22,7 @@ // - // Function Name: inFrontOf(), flip() + // Function Name: inFrontOf() // // Description: // Spectator camera utility functions and variables. @@ -31,8 +31,6 @@ return Vec3.sum(position || MyAvatar.position, Vec3.multiply(distance, Quat.getForward(orientation || MyAvatar.orientation))); } - var aroundY = Quat.fromPitchYawRollDegrees(0, 180, 0); - function flip(rotation) { return Quat.multiply(rotation, aroundY); } // // Function Name: updateRenderFromCamera() @@ -73,10 +71,6 @@ lastCameraPosition = cameraData.position; beginSpectatorFrameRenderConfig.position = Vec3.sum(inFrontOf(0.17, lastCameraPosition, lastCameraRotation), {x: 0, y: 0.02, z: 0}); } - if (cameraIsDynamic) { - // BUG: image3d overlays don't retain their locations properly when parented to a dynamic object - Overlays.editOverlay(viewFinderOverlay, { orientation: flip(cameraData.rotation) }); - } } // @@ -85,6 +79,8 @@ // Relevant Variables: // isUpdateRenderWired: Bool storing whether or not the camera's update // function is wired. + // windowAspectRatio: The ratio of the Interface windows's sizeX/sizeY + // previewAspectRatio: The ratio of the camera preview's sizeX/sizeY // // Arguments: // None @@ -94,10 +90,15 @@ // spawn the camera entity. // var isUpdateRenderWired = false; + var windowAspectRatio; + var previewAspectRatio = 16/9; function spectatorCameraOn() { // Set the special texture size based on the window in which it will eventually be displayed. var size = Controller.getViewportDimensions(); // FIXME: Need a signal to hook into when the dimensions change. - spectatorFrameRenderConfig.resetSizeSpectatorCamera(size.x, size.y); + var sizeX = Window.innerWidth; + var sizeY = Window.innerHeight; + windowAspectRatio = sizeX/sizeY; + spectatorFrameRenderConfig.resetSizeSpectatorCamera(sizeX, sizeY); spectatorFrameRenderConfig.enabled = beginSpectatorFrameRenderConfig.enabled = true; var cameraRotation = MyAvatar.orientation, cameraPosition = inFrontOf(1, Vec3.sum(MyAvatar.position, { x: 0, y: 0.3, z: 0 })); Script.update.connect(updateRenderFromCamera); @@ -132,14 +133,14 @@ parentID: camera, alpha: 1, position: { x: 0.007, y: 0.15, z: -0.005 }, - scale: -0.16, + dimensions: { x: 0.16, y: -0.16 * windowAspectRatio / previewAspectRatio, z: 0 } + // FIXME: This stretches the preview. + // FIXME: We shouldn't need the negative dimension. + // e.g., This isn't necessary using an ordinary .jpg with lettering, above. + // Must be something about the view frustum projection matrix? + // But don't go changing that in (c++ code) without getting all the way to a desktop display! }); Entities.editEntity(camera, { position: cameraPosition, rotation: cameraRotation }); - // FIXME: We shouldn't need the flip and the negative scale. - // e.g., This isn't necessary using an ordinary .jpg with lettering, above. - // Must be something about the view frustum projection matrix? - // But don't go changing that in (c++ code) without getting all the way to a desktop display! - Overlays.editOverlay(viewFinderOverlay, { orientation: flip(cameraRotation) }); setDisplay(monitorShowsCameraView); } From 7b6033f7bc5f141b28cfbce713653cd1f3b3c1df Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Tue, 13 Jun 2017 11:37:27 -0700 Subject: [PATCH 2/7] Getting closer to a solution --- interface/src/SecondaryCamera.cpp | 1 + libraries/render-utils/src/DeferredLightingEffect.cpp | 3 +-- scripts/system/spectatorCamera.js | 6 +----- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/interface/src/SecondaryCamera.cpp b/interface/src/SecondaryCamera.cpp index 3f3d02af42..479c97c7f8 100644 --- a/interface/src/SecondaryCamera.cpp +++ b/interface/src/SecondaryCamera.cpp @@ -78,6 +78,7 @@ public: auto srcViewFrustum = args->getViewFrustum(); srcViewFrustum.setPosition(_position); srcViewFrustum.setOrientation(_orientation); + srcViewFrustum.setProjection(glm::perspective(45.0f, ((float)args->_viewport.z / (float)args->_viewport.w), 0.1f, 100.0f)); // Without calculating the bound planes, the secondary camera will use the same culling frustum as the main camera, // which is not what we want here. srcViewFrustum.calculate(); diff --git a/libraries/render-utils/src/DeferredLightingEffect.cpp b/libraries/render-utils/src/DeferredLightingEffect.cpp index 4b3ee9fec7..2ab13aecd6 100644 --- a/libraries/render-utils/src/DeferredLightingEffect.cpp +++ b/libraries/render-utils/src/DeferredLightingEffect.cpp @@ -420,8 +420,7 @@ model::MeshPointer DeferredLightingEffect::getSpotLightMesh() { void PreparePrimaryFramebuffer::run(const RenderContextPointer& renderContext, gpu::FramebufferPointer& primaryFramebuffer) { auto framebufferCache = DependencyManager::get(); - auto framebufferSize = framebufferCache->getFrameBufferSize(); - glm::uvec2 frameSize(framebufferSize.width(), framebufferSize.height()); + glm::uvec2 frameSize(renderContext->args->_viewport.z, renderContext->args->_viewport.w); // Resizing framebuffers instead of re-building them seems to cause issues with threaded // rendering diff --git a/scripts/system/spectatorCamera.js b/scripts/system/spectatorCamera.js index 9e83be1a0e..88f9e86ae5 100644 --- a/scripts/system/spectatorCamera.js +++ b/scripts/system/spectatorCamera.js @@ -133,12 +133,8 @@ parentID: camera, alpha: 1, position: { x: 0.007, y: 0.15, z: -0.005 }, - dimensions: { x: 0.16, y: -0.16 * windowAspectRatio / previewAspectRatio, z: 0 } + dimensions: { x: 0.16, y: 0.16 * windowAspectRatio / previewAspectRatio, z: 0 } // FIXME: This stretches the preview. - // FIXME: We shouldn't need the negative dimension. - // e.g., This isn't necessary using an ordinary .jpg with lettering, above. - // Must be something about the view frustum projection matrix? - // But don't go changing that in (c++ code) without getting all the way to a desktop display! }); Entities.editEntity(camera, { position: cameraPosition, rotation: cameraRotation }); setDisplay(monitorShowsCameraView); From 8962c7bf6af03a7fe3852f976cc9b3a62c7cd912 Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Tue, 13 Jun 2017 13:06:03 -0700 Subject: [PATCH 3/7] Viewfinder re-flip, add comments regarding why it's necessary --- scripts/system/spectatorCamera.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/scripts/system/spectatorCamera.js b/scripts/system/spectatorCamera.js index 88f9e86ae5..f77eaab3e4 100644 --- a/scripts/system/spectatorCamera.js +++ b/scripts/system/spectatorCamera.js @@ -133,8 +133,15 @@ parentID: camera, alpha: 1, position: { x: 0.007, y: 0.15, z: -0.005 }, - dimensions: { x: 0.16, y: 0.16 * windowAspectRatio / previewAspectRatio, z: 0 } - // FIXME: This stretches the preview. + dimensions: { x: 0.16, y: -0.16 * windowAspectRatio / previewAspectRatio, z: 0 } + // Negative dimension for viewfinder is necessary for now due to the way Image3DOverlay + // draws textures. + // See Image3DOverlay.cpp:91. If you change the two lines there to: + // glm::vec2 topLeft(-x, -y); + // glm::vec2 bottomRight(x, y); + // the viewfinder will appear rightside up without this negative y-dimension. + // However, other Image3DOverlay textures (like the PAUSED one) will appear upside-down. *Why?* + // FIXME: This code will stretch the preview as the window aspect ratio changes. Fix that! }); Entities.editEntity(camera, { position: cameraPosition, rotation: cameraRotation }); setDisplay(monitorShowsCameraView); From 0d86d4f0cb3917acd52a447d0490ad28b4dddf64 Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Tue, 13 Jun 2017 14:30:32 -0700 Subject: [PATCH 4/7] It's working! --- .../gpu-gl/src/gpu/gl/GLBackendTransform.cpp | 4 ++-- .../render-utils/src/AntialiasingEffect.cpp | 16 +++++++--------- libraries/render-utils/src/AntialiasingEffect.h | 2 +- .../render-utils/src/DebugDeferredBuffer.cpp | 2 -- .../render-utils/src/DeferredLightingEffect.cpp | 2 -- 5 files changed, 10 insertions(+), 16 deletions(-) diff --git a/libraries/gpu-gl/src/gpu/gl/GLBackendTransform.cpp b/libraries/gpu-gl/src/gpu/gl/GLBackendTransform.cpp index 974aee2620..01f055e0d9 100644 --- a/libraries/gpu-gl/src/gpu/gl/GLBackendTransform.cpp +++ b/libraries/gpu-gl/src/gpu/gl/GLBackendTransform.cpp @@ -119,7 +119,7 @@ void GLBackend::TransformStageState::preUpdate(size_t commandIndex, const Stereo size_t offset = _cameraUboSize * _cameras.size(); _cameraOffsets.push_back(TransformStageState::Pair(commandIndex, offset)); - if (stereo._enable) { + if (stereo.isStereo()) { #ifdef GPU_STEREO_CAMERA_BUFFER _cameras.push_back(CameraBufferElement(_camera.getEyeCamera(0, stereo, _view), _camera.getEyeCamera(1, stereo, _view))); #else @@ -151,7 +151,7 @@ void GLBackend::TransformStageState::update(size_t commandIndex, const StereoSta #ifdef GPU_STEREO_CAMERA_BUFFER bindCurrentCamera(0); #else - if (!stereo._enable) { + if (!stereo.isStereo()) { bindCurrentCamera(0); } #endif diff --git a/libraries/render-utils/src/AntialiasingEffect.cpp b/libraries/render-utils/src/AntialiasingEffect.cpp index f7881b0333..ce3bf69588 100644 --- a/libraries/render-utils/src/AntialiasingEffect.cpp +++ b/libraries/render-utils/src/AntialiasingEffect.cpp @@ -40,9 +40,9 @@ Antialiasing::~Antialiasing() { } } -const gpu::PipelinePointer& Antialiasing::getAntialiasingPipeline() { - int width = DependencyManager::get()->getFrameBufferSize().width(); - int height = DependencyManager::get()->getFrameBufferSize().height(); +const gpu::PipelinePointer& Antialiasing::getAntialiasingPipeline(RenderArgs* args) { + int width = args->_viewport.z; + int height = args->_viewport.w; if (_antialiasingBuffer && _antialiasingBuffer->getSize() != uvec2(width, height)) { _antialiasingBuffer.reset(); @@ -115,10 +115,8 @@ void Antialiasing::run(const render::RenderContextPointer& renderContext, const batch.setViewportTransform(args->_viewport); // FIXME: NEED to simplify that code to avoid all the GeometryCahce call, this is purely pixel manipulation - auto framebufferCache = DependencyManager::get(); - QSize framebufferSize = framebufferCache->getFrameBufferSize(); - float fbWidth = framebufferSize.width(); - float fbHeight = framebufferSize.height(); + float fbWidth = renderContext->args->_viewport.z; + float fbHeight = renderContext->args->_viewport.w; // float sMin = args->_viewport.x / fbWidth; // float sWidth = args->_viewport.z / fbWidth; // float tMin = args->_viewport.y / fbHeight; @@ -133,10 +131,10 @@ void Antialiasing::run(const render::RenderContextPointer& renderContext, const batch.setModelTransform(Transform()); // FXAA step - getAntialiasingPipeline(); + auto pipeline = getAntialiasingPipeline(renderContext->args); batch.setResourceTexture(0, sourceBuffer->getRenderBuffer(0)); batch.setFramebuffer(_antialiasingBuffer); - batch.setPipeline(getAntialiasingPipeline()); + batch.setPipeline(pipeline); // initialize the view-space unpacking uniforms using frustum data float left, right, bottom, top, nearVal, farVal; diff --git a/libraries/render-utils/src/AntialiasingEffect.h b/libraries/render-utils/src/AntialiasingEffect.h index e403032b4e..cec2554a3b 100644 --- a/libraries/render-utils/src/AntialiasingEffect.h +++ b/libraries/render-utils/src/AntialiasingEffect.h @@ -33,7 +33,7 @@ public: void configure(const Config& config) {} void run(const render::RenderContextPointer& renderContext, const gpu::FramebufferPointer& sourceBuffer); - const gpu::PipelinePointer& getAntialiasingPipeline(); + const gpu::PipelinePointer& getAntialiasingPipeline(RenderArgs* args); const gpu::PipelinePointer& getBlendPipeline(); private: diff --git a/libraries/render-utils/src/DebugDeferredBuffer.cpp b/libraries/render-utils/src/DebugDeferredBuffer.cpp index a67d20c6b0..3359b3a12d 100644 --- a/libraries/render-utils/src/DebugDeferredBuffer.cpp +++ b/libraries/render-utils/src/DebugDeferredBuffer.cpp @@ -19,7 +19,6 @@ #include #include "GeometryCache.h" -#include "FramebufferCache.h" #include "TextureCache.h" #include "DeferredLightingEffect.h" @@ -410,7 +409,6 @@ void DebugDeferredBuffer::run(const RenderContextPointer& renderContext, const I batch.setViewportTransform(args->_viewport); const auto geometryBuffer = DependencyManager::get(); - const auto framebufferCache = DependencyManager::get(); const auto textureCache = DependencyManager::get(); glm::mat4 projMat; diff --git a/libraries/render-utils/src/DeferredLightingEffect.cpp b/libraries/render-utils/src/DeferredLightingEffect.cpp index 2ab13aecd6..0b4eee125b 100644 --- a/libraries/render-utils/src/DeferredLightingEffect.cpp +++ b/libraries/render-utils/src/DeferredLightingEffect.cpp @@ -418,8 +418,6 @@ model::MeshPointer DeferredLightingEffect::getSpotLightMesh() { } void PreparePrimaryFramebuffer::run(const RenderContextPointer& renderContext, gpu::FramebufferPointer& primaryFramebuffer) { - - auto framebufferCache = DependencyManager::get(); glm::uvec2 frameSize(renderContext->args->_viewport.z, renderContext->args->_viewport.w); // Resizing framebuffers instead of re-building them seems to cause issues with threaded From ec3b488897cd25bc3d251ee5038093d18ae1b34e Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Wed, 14 Jun 2017 10:27:08 -0700 Subject: [PATCH 5/7] Remove SECONDARY_CAMERA_RENDER_MODE for now --- interface/src/SecondaryCamera.cpp | 3 --- libraries/shared/src/RenderArgs.h | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/interface/src/SecondaryCamera.cpp b/interface/src/SecondaryCamera.cpp index 479c97c7f8..ae4c67507a 100644 --- a/interface/src/SecondaryCamera.cpp +++ b/interface/src/SecondaryCamera.cpp @@ -65,11 +65,9 @@ public: _cachedArgsPointer->_blitFramebuffer = args->_blitFramebuffer; _cachedArgsPointer->_viewport = args->_viewport; _cachedArgsPointer->_displayMode = args->_displayMode; - _cachedArgsPointer->_renderMode = args->_renderMode; args->_blitFramebuffer = destFramebuffer; args->_viewport = glm::ivec4(0, 0, destFramebuffer->getWidth(), destFramebuffer->getHeight()); args->_displayMode = RenderArgs::MONO; - args->_renderMode = RenderArgs::SECONDARY_CAMERA_RENDER_MODE; gpu::doInBatch(args->_context, [&](gpu::Batch& batch) { batch.disableContextStereo(); @@ -102,7 +100,6 @@ public: args->_viewport = cachedArgs->_viewport; args->popViewFrustum(); args->_displayMode = cachedArgs->_displayMode; - args->_renderMode = cachedArgs->_renderMode; gpu::doInBatch(args->_context, [&](gpu::Batch& batch) { batch.restoreContextStereo(); diff --git a/libraries/shared/src/RenderArgs.h b/libraries/shared/src/RenderArgs.h index f869a93e1f..d4d88c26a8 100644 --- a/libraries/shared/src/RenderArgs.h +++ b/libraries/shared/src/RenderArgs.h @@ -75,7 +75,7 @@ public: class RenderArgs { public: - enum RenderMode { DEFAULT_RENDER_MODE, SHADOW_RENDER_MODE, DIFFUSE_RENDER_MODE, NORMAL_RENDER_MODE, MIRROR_RENDER_MODE, SECONDARY_CAMERA_RENDER_MODE }; + enum RenderMode { DEFAULT_RENDER_MODE, SHADOW_RENDER_MODE, DIFFUSE_RENDER_MODE, NORMAL_RENDER_MODE, MIRROR_RENDER_MODE }; enum DisplayMode { MONO, STEREO_MONITOR, STEREO_HMD }; enum DebugFlags { RENDER_DEBUG_NONE = 0, From 03c61e21914dcd6be8e75a90784a101af022cce7 Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Wed, 14 Jun 2017 11:53:05 -0700 Subject: [PATCH 6/7] vFoV and clipping plane distances now come from config --- interface/src/SecondaryCamera.cpp | 8 +++++++- interface/src/SecondaryCamera.h | 8 +++++++- scripts/system/spectatorCamera.js | 11 ++++++++++- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/interface/src/SecondaryCamera.cpp b/interface/src/SecondaryCamera.cpp index ae4c67507a..257c8454c5 100644 --- a/interface/src/SecondaryCamera.cpp +++ b/interface/src/SecondaryCamera.cpp @@ -42,6 +42,9 @@ void SecondaryCameraRenderTaskConfig::resetSizeSpectatorCamera(int width, int he class BeginSecondaryCameraFrame { // Changes renderContext for our framebuffer and and view. glm::vec3 _position{}; glm::quat _orientation{}; + float _vFoV{}; + float _nearClipPlaneDistance{}; + float _farClipPlaneDistance{}; public: using Config = BeginSecondaryCameraFrameConfig; using JobModel = render::Job::ModelO; @@ -53,6 +56,9 @@ public: if (config.enabled || config.alwaysEnabled) { _position = config.position; _orientation = config.orientation; + _vFoV = config.vFoV; + _nearClipPlaneDistance = config.nearClipPlaneDistance; + _farClipPlaneDistance = config.farClipPlaneDistance; } } @@ -76,7 +82,7 @@ public: auto srcViewFrustum = args->getViewFrustum(); srcViewFrustum.setPosition(_position); srcViewFrustum.setOrientation(_orientation); - srcViewFrustum.setProjection(glm::perspective(45.0f, ((float)args->_viewport.z / (float)args->_viewport.w), 0.1f, 100.0f)); + srcViewFrustum.setProjection(glm::perspective(glm::radians(_vFoV), ((float)args->_viewport.z / (float)args->_viewport.w), _nearClipPlaneDistance, _farClipPlaneDistance)); // Without calculating the bound planes, the secondary camera will use the same culling frustum as the main camera, // which is not what we want here. srcViewFrustum.calculate(); diff --git a/interface/src/SecondaryCamera.h b/interface/src/SecondaryCamera.h index 1abb2952aa..f689c042c0 100644 --- a/interface/src/SecondaryCamera.h +++ b/interface/src/SecondaryCamera.h @@ -29,13 +29,19 @@ public: void build(JobModel& task, const render::Varying& inputs, render::Varying& outputs, render::CullFunctor cullFunctor, bool isDeferred = true); }; -class BeginSecondaryCameraFrameConfig : public render::Task::Config { // Exposes view frustum position/orientation to javascript. +class BeginSecondaryCameraFrameConfig : public render::Task::Config { // Exposes secondary camera parameters to JavaScript. Q_OBJECT Q_PROPERTY(glm::vec3 position MEMBER position NOTIFY dirty) // of viewpoint to render from Q_PROPERTY(glm::quat orientation MEMBER orientation NOTIFY dirty) // of viewpoint to render from + Q_PROPERTY(float vFoV MEMBER vFoV NOTIFY dirty) // Secondary camera's vertical field of view. In degrees. + Q_PROPERTY(float nearClipPlaneDistance MEMBER nearClipPlaneDistance NOTIFY dirty) // Secondary camera's near clip plane distance. In meters. + Q_PROPERTY(float farClipPlaneDistance MEMBER farClipPlaneDistance NOTIFY dirty) // Secondary camera's far clip plane distance. In meters. public: glm::vec3 position{}; glm::quat orientation{}; + float vFoV{}; + float nearClipPlaneDistance{}; + float farClipPlaneDistance{}; BeginSecondaryCameraFrameConfig() : render::Task::Config(false) {} signals: void dirty(); diff --git a/scripts/system/spectatorCamera.js b/scripts/system/spectatorCamera.js index f77eaab3e4..a3cdea7bd5 100644 --- a/scripts/system/spectatorCamera.js +++ b/scripts/system/spectatorCamera.js @@ -81,6 +81,9 @@ // function is wired. // windowAspectRatio: The ratio of the Interface windows's sizeX/sizeY // previewAspectRatio: The ratio of the camera preview's sizeX/sizeY + // vFoV: The vertical field of view of the spectator camera + // nearClipPlaneDistance: The near clip plane distance of the spectator camera + // farClipPlaneDistance: The far clip plane distance of the spectator camera // // Arguments: // None @@ -91,7 +94,10 @@ // var isUpdateRenderWired = false; var windowAspectRatio; - var previewAspectRatio = 16/9; + var previewAspectRatio = 16 / 9; + var vFoV = 45.0; + var nearClipPlaneDistance = 0.1; + var farClipPlaneDistance = 100.0; function spectatorCameraOn() { // Set the special texture size based on the window in which it will eventually be displayed. var size = Controller.getViewportDimensions(); // FIXME: Need a signal to hook into when the dimensions change. @@ -100,6 +106,9 @@ windowAspectRatio = sizeX/sizeY; spectatorFrameRenderConfig.resetSizeSpectatorCamera(sizeX, sizeY); spectatorFrameRenderConfig.enabled = beginSpectatorFrameRenderConfig.enabled = true; + beginSpectatorFrameRenderConfig.vFoV = vFoV; + beginSpectatorFrameRenderConfig.nearClipPlaneDistance = nearClipPlaneDistance; + beginSpectatorFrameRenderConfig.farClipPlaneDistance = farClipPlaneDistance; var cameraRotation = MyAvatar.orientation, cameraPosition = inFrontOf(1, Vec3.sum(MyAvatar.position, { x: 0, y: 0.3, z: 0 })); Script.update.connect(updateRenderFromCamera); isUpdateRenderWired = true; From 8a217acd2bef505696dae04ba2a19076c3a364ee Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Wed, 14 Jun 2017 12:19:38 -0700 Subject: [PATCH 7/7] Defaults for camera projection parameters --- interface/src/SecondaryCamera.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/interface/src/SecondaryCamera.h b/interface/src/SecondaryCamera.h index f689c042c0..0f74ff8be0 100644 --- a/interface/src/SecondaryCamera.h +++ b/interface/src/SecondaryCamera.h @@ -39,9 +39,9 @@ class BeginSecondaryCameraFrameConfig : public render::Task::Config { // Exposes public: glm::vec3 position{}; glm::quat orientation{}; - float vFoV{}; - float nearClipPlaneDistance{}; - float farClipPlaneDistance{}; + float vFoV{ 45.0f }; + float nearClipPlaneDistance{ 0.1f }; + float farClipPlaneDistance{ 100.0f }; BeginSecondaryCameraFrameConfig() : render::Task::Config(false) {} signals: void dirty();