Commit 266f3f65 authored by Dario Seyb's avatar Dario Seyb

improved vignette

parent 97259a3e
......@@ -23,6 +23,27 @@ vec3 Uncharted2Tonemap(vec3 x)
return ((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F;
}
//RADIUS of our vignette, where 0.5 results in a circle fitting the screen
const float RADIUS = 0.65;
//softness of our vignette, between 0.0 and 1.0
const float SOFTNESS = 0.35;
vec3 Vignette(vec3 color) {
//determine center position
vec2 position = vTexCoord - vec2(0.5);
//determine the vector length of the center position
float len = length(position);
//use smoothstep to create a smooth vignette
float vignette = smoothstep(RADIUS, RADIUS-SOFTNESS, len);
//apply the vignette with 50% opacity
return mix(color, color * vignette, 0.8);
}
void main()
{
......@@ -36,8 +57,8 @@ void main()
vec3 whiteScale = vec3(1.0f)/Uncharted2Tonemap(vec3(W));
color = curr*whiteScale;
vec2 centerDist = abs(vTexCoord * 2.0 - 1.0);
color *= length(vec2(1.0) - centerDist);
color = Vignette(color);
vec3 retColor = pow(color, vec3(1.0/2.2));
retColor += vec3(rand(gl_FragCoord.xy) * 1.0/255 - 0.5/255);
......
This diff is collapsed.
This diff is collapsed.
All SDK and Integration documentation are now available on-line at the following link:
https://developer.oculus.com/documentation/
\ No newline at end of file
This diff is collapsed.
/********************************************************************************//**
\file OVR_CAPI_Util.h
\brief This header provides LibOVR utility function declarations
\copyright Copyright 2015 Oculus VR, LLC All Rights reserved.
*************************************************************************************/
#ifndef OVR_CAPI_Util_h
#define OVR_CAPI_Util_h
#include "OVR_CAPI.h"
#ifdef __cplusplus
extern "C" {
#endif
/// Enumerates modifications to the projection matrix based on the application's needs.
///
/// \see ovrMatrix4f_Projection
///
typedef enum ovrProjectionModifier_
{
/// Use for generating a default projection matrix that is:
/// * Left-handed.
/// * Near depth values stored in the depth buffer are smaller than far depth values.
/// * Both near and far are explicitly defined.
/// * With a clipping range that is (0 to w).
ovrProjection_None = 0x00,
/// Enable if using right-handed transformations in your application.
ovrProjection_RightHanded = 0x01,
/// After the projection transform is applied, far values stored in the depth buffer will be less than closer depth values.
/// NOTE: Enable only if the application is using a floating-point depth buffer for proper precision.
ovrProjection_FarLessThanNear = 0x02,
/// When this flag is used, the zfar value pushed into ovrMatrix4f_Projection() will be ignored
/// NOTE: Enable only if ovrProjection_FarLessThanNear is also enabled where the far clipping plane will be pushed to infinity.
ovrProjection_FarClipAtInfinity = 0x04,
/// Enable if the application is rendering with OpenGL and expects a projection matrix with a clipping range of (-w to w).
/// Ignore this flag if your application already handles the conversion from D3D range (0 to w) to OpenGL.
ovrProjection_ClipRangeOpenGL = 0x08,
} ovrProjectionModifier;
/// Return values for ovr_Detect.
///
/// \see ovr_Detect
///
typedef struct OVR_ALIGNAS(8) ovrDetectResult_
{
/// Is ovrFalse when the Oculus Service is not running.
/// This means that the Oculus Service is either uninstalled or stopped.
/// IsOculusHMDConnected will be ovrFalse in this case.
/// Is ovrTrue when the Oculus Service is running.
/// This means that the Oculus Service is installed and running.
/// IsOculusHMDConnected will reflect the state of the HMD.
ovrBool IsOculusServiceRunning;
/// Is ovrFalse when an Oculus HMD is not detected.
/// If the Oculus Service is not running, this will be ovrFalse.
/// Is ovrTrue when an Oculus HMD is detected.
/// This implies that the Oculus Service is also installed and running.
ovrBool IsOculusHMDConnected;
OVR_UNUSED_STRUCT_PAD(pad0, 6) ///< \internal struct padding
} ovrDetectResult;
OVR_STATIC_ASSERT(sizeof(ovrDetectResult) == 8, "ovrDetectResult size mismatch");
/// Detects Oculus Runtime and Device Status
///
/// Checks for Oculus Runtime and Oculus HMD device status without loading the LibOVRRT
/// shared library. This may be called before ovr_Initialize() to help decide whether or
/// not to initialize LibOVR.
///
/// \param[in] timeoutMsec Specifies a timeout to wait for HMD to be attached or 0 to poll.
///
/// \return Returns an ovrDetectResult object indicating the result of detection.
///
/// \see ovrDetectResult
///
OVR_PUBLIC_FUNCTION(ovrDetectResult) ovr_Detect(int timeoutMsec);
// On the Windows platform,
#ifdef _WIN32
/// This is the Windows Named Event name that is used to check for HMD connected state.
#define OVR_HMD_CONNECTED_EVENT_NAME L"OculusHMDConnected"
#endif // _WIN32
/// Used to generate projection from ovrEyeDesc::Fov.
///
/// \param[in] fov Specifies the ovrFovPort to use.
/// \param[in] znear Distance to near Z limit.
/// \param[in] zfar Distance to far Z limit.
/// \param[in] projectionModFlags A combination of the ovrProjectionModifier flags.
///
/// \return Returns the calculated projection matrix.
///
/// \see ovrProjectionModifier
///
OVR_PUBLIC_FUNCTION(ovrMatrix4f) ovrMatrix4f_Projection(ovrFovPort fov, float znear, float zfar, unsigned int projectionModFlags);
/// Extracts the required data from the result of ovrMatrix4f_Projection.
///
/// \param[in] projection Specifies the project matrix from which to extract ovrTimewarpProjectionDesc.
/// \param[in] projectionModFlags A combination of the ovrProjectionModifier flags.
/// \return Returns the extracted ovrTimewarpProjectionDesc.
/// \see ovrTimewarpProjectionDesc
///
OVR_PUBLIC_FUNCTION(ovrTimewarpProjectionDesc) ovrTimewarpProjectionDesc_FromProjection(ovrMatrix4f projection, unsigned int projectionModFlags);
/// Generates an orthographic sub-projection.
///
/// Used for 2D rendering, Y is down.
///
/// \param[in] projection The perspective matrix that the orthographic matrix is derived from.
/// \param[in] orthoScale Equal to 1.0f / pixelsPerTanAngleAtCenter.
/// \param[in] orthoDistance Equal to the distance from the camera in meters, such as 0.8m.
/// \param[in] hmdToEyeViewOffsetX Specifies the offset of the eye from the center.
///
/// \return Returns the calculated projection matrix.
///
OVR_PUBLIC_FUNCTION(ovrMatrix4f) ovrMatrix4f_OrthoSubProjection(ovrMatrix4f projection, ovrVector2f orthoScale,
float orthoDistance, float hmdToEyeViewOffsetX);
/// Computes offset eye poses based on headPose returned by ovrTrackingState.
///
/// \param[in] headPose Indicates the HMD position and orientation to use for the calculation.
/// \param[in] hmdToEyeViewOffset Can be ovrEyeRenderDesc.HmdToEyeViewOffset returned from
/// ovr_GetRenderDesc. For monoscopic rendering, use a vector that is the average
/// of the two vectors for both eyes.
/// \param[out] outEyePoses If outEyePoses are used for rendering, they should be passed to
/// ovr_SubmitFrame in ovrLayerEyeFov::RenderPose or ovrLayerEyeFovDepth::RenderPose.
///
OVR_PUBLIC_FUNCTION(void) ovr_CalcEyePoses(ovrPosef headPose,
const ovrVector3f hmdToEyeViewOffset[2],
ovrPosef outEyePoses[2]);
/// Returns the predicted head pose in outHmdTrackingState and offset eye poses in outEyePoses.
///
/// This is a thread-safe function where caller should increment frameIndex with every frame
/// and pass that index where applicable to functions called on the rendering thread.
/// Assuming outEyePoses are used for rendering, it should be passed as a part of ovrLayerEyeFov.
/// The caller does not need to worry about applying HmdToEyeViewOffset to the returned outEyePoses variables.
///
/// \param[in] hmd Specifies an ovrHmd previously returned by ovr_Create.
/// \param[in] frameIndex Specifies the targeted frame index, or 0 to refer to one frame after
/// the last time ovr_SubmitFrame was called.
/// \param[in] hmdToEyeViewOffset Can be ovrEyeRenderDesc.HmdToEyeViewOffset returned from
/// ovr_GetRenderDesc. For monoscopic rendering, use a vector that is the average
/// of the two vectors for both eyes.
/// \param[in] latencyMarker Specifies that this call is the point in time where
/// the "App-to-Mid-Photon" latency timer starts from. If a given ovrLayer
/// provides "SensorSampleTimestamp", that will override the value stored here.
/// \param[out] outEyePoses The predicted eye poses.
/// \param[out] outHmdTrackingState The predicted ovrTrackingState. May be NULL, in which case it is ignored.
///
OVR_PUBLIC_FUNCTION(void) ovr_GetEyePoses(ovrSession session, long long frameIndex, ovrBool latencyMarker,
const ovrVector3f hmdToEyeViewOffset[2],
ovrPosef outEyePoses[2],
ovrTrackingState* outHmdTrackingState);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif // Header include guard
This diff is collapsed.
/************************************************************************************
Filename : OVR_StereoProjection.h
Content : Stereo projection functions
Created : November 30, 2013
Authors : Tom Fosyth
Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved.
Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License");
you may not use the Oculus VR Rift SDK except in compliance with the License,
which is provided at the time of installation or download, or which
otherwise accompanies this software in either electronic or hard copy form.
You may obtain a copy of the License at
http://www.oculusvr.com/licenses/LICENSE-3.2
Unless required by applicable law or agreed to in writing, the Oculus VR SDK
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*************************************************************************************/
#ifndef OVR_StereoProjection_h
#define OVR_StereoProjection_h
#include "Extras/OVR_Math.h"
namespace OVR {
//-----------------------------------------------------------------------------------
// ***** Stereo Enumerations
// StereoEye specifies which eye we are rendering for; it is used to
// retrieve StereoEyeParams.
enum StereoEye
{
StereoEye_Left,
StereoEye_Right,
StereoEye_Center
};
//-----------------------------------------------------------------------------------
// ***** Propjection functions
Matrix4f CreateProjection ( bool rightHanded, bool isOpenGL, FovPort fov, StereoEye eye,
float zNear = 0.01f, float zFar = 10000.0f,
bool flipZ = false, bool farAtInfinity = false);
Matrix4f CreateOrthoSubProjection ( bool rightHanded, StereoEye eyeType,
float tanHalfFovX, float tanHalfFovY,
float unitsX, float unitsY, float distanceFromCamera,
float interpupillaryDistance, Matrix4f const &projection,
float zNear = 0.0f, float zFar = 0.0f,
bool flipZ = false, bool farAtInfinity = false);
ScaleAndOffset2D CreateNDCScaleAndOffsetFromFov ( FovPort fov );
} //namespace OVR
#endif // OVR_StereoProjection_h
/********************************************************************************//**
\file OVR.h
\brief The main public interface to Oculus for C++ Developers.
\copyright Copyright 2015 Oculus VR, LLC All Rights reserved.
*************************************************************************************/
#ifndef OVR_h
#define OVR_h
#include "OVR_Version.h"
#include "OVR_CAPI.h"
/* The following includes are deprecated from this location and will be removed from a future version of this library. */
#include "Kernel/OVR_Types.h"
#include "Kernel/OVR_RefCount.h"
#include "Kernel/OVR_Std.h"
#include "Kernel/OVR_Alg.h"
#include "Extras/OVR_Math.h"
#endif
This diff is collapsed.
/********************************************************************************//**
\file OVR_CAPI_Audio.h
\brief CAPI audio functions.
\copyright Copyright 2015 Oculus VR, LLC. All Rights reserved.
************************************************************************************/
#ifndef OVR_CAPI_Audio_h
#define OVR_CAPI_Audio_h
#include "OVR_CAPI.h"
#include <Windows.h>
#define OVR_AUDIO_MAX_DEVICE_STR_SIZE 128
/// Gets the ID of the preferred VR audio device.
///
/// Multiple calls to ovr_CreateSwapTextureSetD3D11 for the same ovrHmd is supported, but applications
/// cannot rely on switching between ovrSwapTextureSets at runtime without a performance penalty.
///
/// \param[out] deviceOutId The ID of the user's preferred VR audio device to use, which will be valid upon a successful return value, else it will be NULL.
///
/// \return Returns an ovrResult indicating success or failure. In the case of failure, use
/// ovr_GetLastErrorInfo to get more information.
///
OVR_PUBLIC_FUNCTION(ovrResult) ovr_GetAudioDeviceOutWaveId(UINT* deviceOutId);
/// Gets the GUID of the preferred VR audio device as a string.
///
/// \param[out] deviceOutStrBuffer A buffer where the GUID string for the device will copied to.
///
/// \return Returns an ovrResult indicating success or failure. In the case of failure, use
/// ovr_GetLastErrorInfo to get more information.
///
OVR_PUBLIC_FUNCTION(ovrResult) ovr_GetAudioDeviceOutGuidStr(WCHAR deviceOutStrBuffer[OVR_AUDIO_MAX_DEVICE_STR_SIZE]);
/// Gets the GUID of the preferred VR audio device.
///
/// \param[out] deviceOutGuid The GUID of the user's preferred VR audio device to use, which will be valid upon a successful return value, else it will be NULL.
///
/// \return Returns an ovrResult indicating success or failure. In the case of failure, use
/// ovr_GetLastErrorInfo to get more information.
///
OVR_PUBLIC_FUNCTION(ovrResult) ovr_GetAudioDeviceOutGuid(GUID* deviceOutGuid);