aboutsummaryrefslogtreecommitdiff
path: root/include/ansel/Configuration.h
blob: e172e57d6d2061d61ddc67d9d4ead25ed3712d21 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
// This code contains NVIDIA Confidential Information and is disclosed to you
// under a form of NVIDIA software license agreement provided separately to you.
//
// Notice
// NVIDIA Corporation and its licensors retain all intellectual property and
// proprietary rights in and to this software and related documentation and
// any modifications thereto. Any use, reproduction, disclosure, or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA Corporation is strictly prohibited.
//
// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
//
// Information and code furnished is believed to be accurate and reliable.
// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
// information or for any infringement of patents or other rights of third parties that may
// result from its use. No license is granted by implication or otherwise under any patent
// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
// This code supersedes and replaces all information previously supplied.
// NVIDIA Corporation products are not authorized for use as critical
// components in life support devices or systems without express written approval of
// NVIDIA Corporation.
//
// Copyright 2015 NVIDIA Corporation. All rights reserved.

#pragma once
#include <ansel/Defines.h>
#include <ansel/Session.h>
#include <ansel/Version.h>
#include <nv/Vec3.h>
#include <stdint.h>

namespace ansel
{
    enum SetConfigurationStatus
    {
        // successfully initialized the Ansel SDK
        kSetConfigurationSuccess,
        // the version provided in the Configuration structure is not the same as the one stored inside the SDK binary (header/binary mismatch)
        kSetConfigurationIncompatibleVersion,
        // the Configuration structure supplied for the setConfiguration call is not consistent
        kSetConfigurationIncorrectConfiguration,
        // the Ansel SDK is delay loaded and setConfiguration is called before the SDK is actually loaded
        kSetConfigurationSdkNotLoaded
    };

    enum FovType
    {
        kHorizontalFov,
        kVerticalFov
    };

    struct Configuration
    {
        // Basis vectors used by the game. They specify the handedness and orientation of 
        // the game's coordinate system. Think of them as the default orientation of the game
        // camera.
        nv::Vec3 right, up, forward;
        // The speed at which camera moves in the world
        float translationalSpeedInWorldUnitsPerSecond;
        // The speed at which camera rotates 
        float rotationalSpeedInDegreesPerSecond;
        // How many frames it takes for camera update to be reflected in a rendered frame
        uint32_t captureLatency;
        // How many frames we must wait for a new frame to settle - i.e. temporal AA and similar
        // effects to stabilize after the camera has been adjusted
        uint32_t captureSettleLatency;
        // Game scale, the size of a world unit measured in meters
        float metersInWorldUnit;
        // Integration will support Camera::screenOriginXOffset/screenOriginYOffset
        bool isCameraOffcenteredProjectionSupported;
        // Integration will support Camera::position
        bool isCameraTranslationSupported;
        // Integration will support Camera::rotation
        bool isCameraRotationSupported;
        // Integration will support Camera::horizontalFov
        bool isCameraFovSupported;
        // Game name, in utf8 encoding, used to name the resulting image files from capturing. 
        // It is not mandatory to set this field. The name chosen is based on the following 
        // selection order:
        // 1. If GeForce profile exists for the game that name will be used
        // 2. If 'titleNameUtf8' is set that will be used
        // 3. The executable name is used as a last resort
        const char* titleNameUtf8;
        // Camera structure will contain vertical FOV if this is set to kVerticalFov
        // but horizontal FOV if this is set to kHorizontalFov. To simplify integration set
        // this to the same orientation as the game is using.
        FovType fovType;

        // These callbacks will be called on the same thread Present()/glSwapBuffers is called
        // The thread calling to updateCamera() might be a different thread

        // User defined pointer which is then passed to all the callbacks (nullptr by default)
        void* userPointer;

        // The window handle for the game/application where input messages are processed
        void* gameWindowHandle;

        // Called when user activates Ansel. Return false if the game cannot comply with the
        // request. If the function returns true the following must be done:
        // 1. Change the SessionConfigruation settings, but only where you need to (the object
        //    is already populated with default settings).
        // 2. On the next update loop the game will be in an Ansel session. This requires the game
        //    to 
        //    a) stop drawing any UI or HUD related elements
        //    b) pause the simulation (if possible)
        //    c) call ansel::updateCamera and perform associated processing
        // 3. Step 2 is repeated on every iteration of update loop until Session is stopped.
        StartSessionCallback startSessionCallback;

        // Called when Ansel is deactivated. This call will only be made if the previous call
        // to the startSessionCallback returned true.
        // Normally games will use this callback to restore their camera to the settings it had 
        // when the Ansel session was started.
        StopSessionCallback stopSessionCallback;

        // Called when the capture of a multipart shot (highres, 360, etc) has started.
        // Handy to disable those fullscreen effects that aren't uniform (like vignette)
        // This callback is optional (leave nullptr if not needed)
        StartCaptureCallback startCaptureCallback;
        // Called when the capture of a multipart shot (highres, 360, etc) has stopped.
        // Handy to enable those fullscreen effects that were disabled by startCaptureCallback.
        // This callback is optional (leave nullptr if not needed)
        StopCaptureCallback stopCaptureCallback;
        // Integration allows a filter/effect to remain active when the Ansel session is not active
        bool isFilterOutsideSessionAllowed;
        // The 'isExrSupported' setting has been phased out in version 1.1 of the SDK. Use
        // 'isRawAllowed' setting in SessionConfiguration to enable/disable captures into EXR
        // format.
        bool unused1;
        // Holds the sdk version, doesn't require modifications
        uint64_t sdkVersion;

        Configuration()
        {
            right.x = 0.0f;
            right.y = 1.0f;
            right.z = 0.0f;
            up.x = 0.0f;
            up.y = 0.0f;
            up.z = 1.0f;
            forward.x = 1.0f;
            forward.y = 0.0f;
            forward.z = 0.0f;
            translationalSpeedInWorldUnitsPerSecond = 1.0f;
            rotationalSpeedInDegreesPerSecond = 45.0f;
            captureLatency = 1;
            captureSettleLatency = 0;
            metersInWorldUnit = 1.0f;
            isCameraOffcenteredProjectionSupported = true;
            isCameraTranslationSupported = true;
            isCameraRotationSupported = true;
            isCameraFovSupported = true;
            titleNameUtf8 = nullptr;
            fovType = kHorizontalFov;
            userPointer = nullptr;
            gameWindowHandle = 0;
            startSessionCallback = nullptr;
            stopSessionCallback = nullptr;
            startCaptureCallback = nullptr;
            stopCaptureCallback = nullptr;
            isFilterOutsideSessionAllowed = true;
            unused1 = false;
            sdkVersion = ANSEL_SDK_VERSION;
        }
    };

    // Called during startup by the game. See 'Configuration' for further documentation.
    ANSEL_SDK_API SetConfigurationStatus setConfiguration(const Configuration& cfg);

    // Can be called *after* D3D device has been created to see if Ansel is available.
    // If called prior to D3D device creation it will always return false.
    // Can be called *before* calling setConfiguration in which case it'll return true if Ansel is potentially available, otherwise false.
    // If setConfiguration fails for any reason this function will return false (even if Ansel would be available otherwise)
    // until a successfull call to setConfiguration has been made.
    ANSEL_SDK_API bool isAnselAvailable();
}