aboutsummaryrefslogtreecommitdiff
path: root/samples
diff options
context:
space:
mode:
authorNathan Hoobler <[email protected]>2016-03-22 11:40:34 -0400
committerNathan Hoobler <[email protected]>2016-03-22 11:40:34 -0400
commitb4ab266c9010aaff5404f6a508a2e592eb367d36 (patch)
tree1e9eefa78e90485397b50ce5e780a1d0cb38b493 /samples
downloadvolumetriclighting-b4ab266c9010aaff5404f6a508a2e592eb367d36.tar.xz
volumetriclighting-b4ab266c9010aaff5404f6a508a2e592eb367d36.zip
initial commit
Diffstat (limited to 'samples')
-rw-r--r--samples/VolumetricLightingTest/common.h264
-rw-r--r--samples/VolumetricLightingTest/d3d11/DeviceManager.cpp609
-rw-r--r--samples/VolumetricLightingTest/d3d11/DeviceManager.h148
-rw-r--r--samples/VolumetricLightingTest/d3d11/compiled_shaders_d3d11.cpp36
-rw-r--r--samples/VolumetricLightingTest/d3d11/compiled_shaders_d3d11.h45
-rw-r--r--samples/VolumetricLightingTest/d3d11/d3d11_main.cpp478
-rw-r--r--samples/VolumetricLightingTest/d3d11/d3d11_util.cpp347
-rw-r--r--samples/VolumetricLightingTest/d3d11/d3d11_util.h234
-rw-r--r--samples/VolumetricLightingTest/main.cpp68
-rw-r--r--samples/VolumetricLightingTest/scene.cpp609
-rw-r--r--samples/VolumetricLightingTest/scene.h150
-rw-r--r--samples/VolumetricLightingTest/shaders/post_PS.hlsl56
-rw-r--r--samples/VolumetricLightingTest/shaders/quad_VS.hlsl47
-rw-r--r--samples/VolumetricLightingTest/shaders/scene_GS.hlsl141
-rw-r--r--samples/VolumetricLightingTest/shaders/scene_PS.hlsl177
-rw-r--r--samples/VolumetricLightingTest/shaders/scene_VS.hlsl117
-rw-r--r--samples/bin/NvVolumetricLighting.win64.dllbin0 -> 2093568 bytes
-rw-r--r--samples/bin/VolumetricLightingTest.win64.exebin0 -> 110592 bytes
-rw-r--r--samples/bin/VolumetricLightingTest_Readme.txt15
-rw-r--r--samples/build/vs2012/VolumetricLightingTest.vcxproj338
-rw-r--r--samples/build/vs2012/VolumetricLightingTest.vcxproj.filters69
-rw-r--r--samples/build/vs2012/VolumetricLighting_Samples.sln30
-rw-r--r--samples/build/vs2013/VolumetricLightingTest.vcxproj338
-rw-r--r--samples/build/vs2013/VolumetricLightingTest.vcxproj.filters69
-rw-r--r--samples/build/vs2013/VolumetricLighting_Samples.sln30
25 files changed, 4415 insertions, 0 deletions
diff --git a/samples/VolumetricLightingTest/common.h b/samples/VolumetricLightingTest/common.h
new file mode 100644
index 0000000..3b214ca
--- /dev/null
+++ b/samples/VolumetricLightingTest/common.h
@@ -0,0 +1,264 @@
+// This code contains NVIDIA Confidential Information and is disclosed
+// under the Mutual Non-Disclosure Agreement.
+//
+// Notice
+// ALL NVIDIA DESIGN SPECIFICATIONS AND CODE ("MATERIALS") ARE PROVIDED "AS IS" NVIDIA MAKES
+// NO REPRESENTATIONS, WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
+//
+// 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. No third party distribution is allowed unless
+// expressly authorized by NVIDIA. 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 (c) 2003 - 2016 NVIDIA Corporation. All rights reserved.
+//
+// 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.
+//
+
+#ifndef COMMON_H
+#define COMMON_H
+////////////////////////////////////////////////////////////////////////////////
+
+#include <NvPreprocessor.h>
+#include <NvAssert.h>
+#include <NvIntrinsics.h>
+#include <NvMath.h>
+#include <NvFoundationMath.h>
+#include <NvCTypes.h>
+
+namespace Nv
+{
+ using namespace nvidia;
+} // namespace Nv
+
+/*==============================================================================
+ GFSDK Conversion stubs
+==============================================================================*/
+
+NV_FORCE_INLINE NvcVec2 NVtoNVC(const Nv::NvVec2 & rhs)
+{
+ return *reinterpret_cast<const NvcVec2 *>(&rhs);
+}
+
+NV_FORCE_INLINE NvcVec3 NVtoNVC(const Nv::NvVec3 & rhs)
+{
+ return *reinterpret_cast<const NvcVec3 *>(&rhs);
+}
+
+NV_FORCE_INLINE NvcVec4 NVtoNVC(const Nv::NvVec4 & rhs)
+{
+ return *reinterpret_cast<const NvcVec4 *>(&rhs);
+}
+
+NV_FORCE_INLINE NvcMat44 NVtoNVC(const Nv::NvMat44 & rhs)
+{
+ return *reinterpret_cast<const NvcMat44 *>(&rhs);
+}
+
+
+NV_FORCE_INLINE Nv::NvMat44 PerspectiveProjLH(float fov, float aspect, float zn, float zf)
+{
+ Nv::NvMat44 p(Nv::NvZero);
+ float cot_fov = Nv::intrinsics::cos(fov) / Nv::intrinsics::sin(fov);
+ p(0, 0) = cot_fov / aspect;
+ p(1, 1) = cot_fov;
+ p(2, 2) = zf / (zf - zn);
+ p(2, 3) = -zn * zf / (zf - zn);
+ p(3, 2) = 1.0;
+ return p;
+}
+
+NV_FORCE_INLINE Nv::NvMat44 OrthographicProjLH(float width, float height, float zn, float zf)
+{
+ Nv::NvMat44 p(Nv::NvZero);
+ p(0, 0) = 2.0f / width;
+ p(1, 1) = 2.0f / height;
+ p(2, 2) = 1 / (zf - zn);
+ p(2, 3) = zn / (zf - zn);
+ p(3, 3) = 1.0f;
+ return p;
+}
+
+NV_FORCE_INLINE Nv::NvMat44 LookAtTransform(const Nv::NvVec3 & eye, const Nv::NvVec3 & at, const Nv::NvVec3 & up)
+{
+ Nv::NvVec3 zaxis = at - eye;
+ zaxis.normalize();
+ Nv::NvVec3 xaxis = up.cross(zaxis);
+ xaxis.normalize();
+ Nv::NvVec3 yaxis = zaxis.cross(xaxis);
+ return Nv::NvMat44(
+ Nv::NvVec4(xaxis.x, yaxis.x, zaxis.x, 0),
+ Nv::NvVec4(xaxis.y, yaxis.y, zaxis.y, 0),
+ Nv::NvVec4(xaxis.z, yaxis.z, zaxis.z, 0),
+ Nv::NvVec4(-xaxis.dot(eye), -yaxis.dot(eye), -zaxis.dot(eye), 1));
+}
+
+NV_FORCE_INLINE Nv::NvMat44 Inverse(const Nv::NvMat44 & in)
+{
+ const float * m = in.front();
+ float inv[16];
+ float det;
+ int i;
+
+ inv[0] = m[5] * m[10] * m[15] -
+ m[5] * m[11] * m[14] -
+ m[9] * m[6] * m[15] +
+ m[9] * m[7] * m[14] +
+ m[13] * m[6] * m[11] -
+ m[13] * m[7] * m[10];
+
+ inv[4] = -m[4] * m[10] * m[15] +
+ m[4] * m[11] * m[14] +
+ m[8] * m[6] * m[15] -
+ m[8] * m[7] * m[14] -
+ m[12] * m[6] * m[11] +
+ m[12] * m[7] * m[10];
+
+ inv[8] = m[4] * m[9] * m[15] -
+ m[4] * m[11] * m[13] -
+ m[8] * m[5] * m[15] +
+ m[8] * m[7] * m[13] +
+ m[12] * m[5] * m[11] -
+ m[12] * m[7] * m[9];
+
+ inv[12] = -m[4] * m[9] * m[14] +
+ m[4] * m[10] * m[13] +
+ m[8] * m[5] * m[14] -
+ m[8] * m[6] * m[13] -
+ m[12] * m[5] * m[10] +
+ m[12] * m[6] * m[9];
+
+ inv[1] = -m[1] * m[10] * m[15] +
+ m[1] * m[11] * m[14] +
+ m[9] * m[2] * m[15] -
+ m[9] * m[3] * m[14] -
+ m[13] * m[2] * m[11] +
+ m[13] * m[3] * m[10];
+
+ inv[5] = m[0] * m[10] * m[15] -
+ m[0] * m[11] * m[14] -
+ m[8] * m[2] * m[15] +
+ m[8] * m[3] * m[14] +
+ m[12] * m[2] * m[11] -
+ m[12] * m[3] * m[10];
+
+ inv[9] = -m[0] * m[9] * m[15] +
+ m[0] * m[11] * m[13] +
+ m[8] * m[1] * m[15] -
+ m[8] * m[3] * m[13] -
+ m[12] * m[1] * m[11] +
+ m[12] * m[3] * m[9];
+
+ inv[13] = m[0] * m[9] * m[14] -
+ m[0] * m[10] * m[13] -
+ m[8] * m[1] * m[14] +
+ m[8] * m[2] * m[13] +
+ m[12] * m[1] * m[10] -
+ m[12] * m[2] * m[9];
+
+ inv[2] = m[1] * m[6] * m[15] -
+ m[1] * m[7] * m[14] -
+ m[5] * m[2] * m[15] +
+ m[5] * m[3] * m[14] +
+ m[13] * m[2] * m[7] -
+ m[13] * m[3] * m[6];
+
+ inv[6] = -m[0] * m[6] * m[15] +
+ m[0] * m[7] * m[14] +
+ m[4] * m[2] * m[15] -
+ m[4] * m[3] * m[14] -
+ m[12] * m[2] * m[7] +
+ m[12] * m[3] * m[6];
+
+ inv[10] = m[0] * m[5] * m[15] -
+ m[0] * m[7] * m[13] -
+ m[4] * m[1] * m[15] +
+ m[4] * m[3] * m[13] +
+ m[12] * m[1] * m[7] -
+ m[12] * m[3] * m[5];
+
+ inv[14] = -m[0] * m[5] * m[14] +
+ m[0] * m[6] * m[13] +
+ m[4] * m[1] * m[14] -
+ m[4] * m[2] * m[13] -
+ m[12] * m[1] * m[6] +
+ m[12] * m[2] * m[5];
+
+ inv[3] = -m[1] * m[6] * m[11] +
+ m[1] * m[7] * m[10] +
+ m[5] * m[2] * m[11] -
+ m[5] * m[3] * m[10] -
+ m[9] * m[2] * m[7] +
+ m[9] * m[3] * m[6];
+
+ inv[7] = m[0] * m[6] * m[11] -
+ m[0] * m[7] * m[10] -
+ m[4] * m[2] * m[11] +
+ m[4] * m[3] * m[10] +
+ m[8] * m[2] * m[7] -
+ m[8] * m[3] * m[6];
+
+ inv[11] = -m[0] * m[5] * m[11] +
+ m[0] * m[7] * m[9] +
+ m[4] * m[1] * m[11] -
+ m[4] * m[3] * m[9] -
+ m[8] * m[1] * m[7] +
+ m[8] * m[3] * m[5];
+
+ inv[15] = m[0] * m[5] * m[10] -
+ m[0] * m[6] * m[9] -
+ m[4] * m[1] * m[10] +
+ m[4] * m[2] * m[9] +
+ m[8] * m[1] * m[6] -
+ m[8] * m[2] * m[5];
+
+ det = m[0] * inv[0] + m[1] * inv[4] + m[2] * inv[8] + m[3] * inv[12];
+
+ if (det == 0)
+ return Nv::NvMat44(Nv::NvZero);
+
+ det = 1.0f / det;
+
+ for (i = 0; i < 16; i++)
+ inv[i] = inv[i] * det;
+
+ return Nv::NvMat44(inv);
+}
+/*==============================================================================
+ Helper Macros
+==============================================================================*/
+
+#ifdef _DEBUG
+# include <stdio.h>
+# include <assert.h>
+# if defined(WIN31) || defined(WIN63)
+# define LOG(fmt, ...) { char debug_string[1024]; _snprintf_c(debug_string, 1024, fmt, ##__VA_ARGS__); OutputDebugStringA(debug_string); }
+# define ASSERT_LOG(test, msg, ...) if (!(test)) { LOG(msg "\n", ##__VA_ARGS__); DebugBreak(); }
+# else
+# define LOG(fmt, ...) printf(fmt, ##__VA_ARGS__)
+# define ASSERT_LOG(test, msg, ...) if (!(test)) { LOG(msg, ##__VA_ARGS__); abort(); }
+# endif
+#else
+# define LOG(fmt, ...)
+# define ASSERT_LOG(test, msg, ...)
+#endif
+
+#define VALIDATE(r, e) if (FAILED(r)) { LOG("Call Failure: %u\n", r); return e; };
+#define SIZE_OF_ARRAY(a) (sizeof(a)/sizeof(a[0]))
+#define SAFE_DELETE(x) if((x) != nullptr) {delete (x); (x)=nullptr;}
+#define SAFE_RELEASE(x) if((x) != nullptr) {(x)->Release(); (x)=nullptr;}
+#define SAFE_RELEASE_ARRAY(x) for (unsigned _sr_count=0; _sr_count<SIZE_OF_ARRAY(x); ++_sr_count) {if((x)[_sr_count] != nullptr) {((IUnknown *)(x)[_sr_count])->Release(); (x)[_sr_count]=nullptr;}}
+#define SAFE_DELETE_ARRAY(x) if (x != nullptr) {SAFE_RELEASE_ARRAY(x); delete[] x; x=nullptr;}
+
+#endif // COMMON_H
diff --git a/samples/VolumetricLightingTest/d3d11/DeviceManager.cpp b/samples/VolumetricLightingTest/d3d11/DeviceManager.cpp
new file mode 100644
index 0000000..122da86
--- /dev/null
+++ b/samples/VolumetricLightingTest/d3d11/DeviceManager.cpp
@@ -0,0 +1,609 @@
+// TAGRELEASE: PUBLIC
+#include "common.h"
+
+#include "DeviceManager.h"
+#include <WinUser.h>
+#include <Windows.h>
+
+#ifndef SAFE_RELEASE
+#define SAFE_RELEASE(p) { if (p) { (p)->Release(); (p)=NULL; } }
+#endif
+
+#define WINDOW_CLASS_NAME L"NvDX11"
+
+#define WINDOW_STYLE_NORMAL (WS_OVERLAPPEDWINDOW | WS_VISIBLE)
+#define WINDOW_STYLE_FULLSCREEN (WS_POPUP | WS_SYSMENU | WS_VISIBLE)
+
+// A singleton, sort of... To pass the events from WindowProc to the object.
+DeviceManager* g_DeviceManagerInstance = NULL;
+
+LRESULT CALLBACK WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+ if(g_DeviceManagerInstance)
+ return g_DeviceManagerInstance->MsgProc(hWnd, uMsg, wParam, lParam);
+ else
+ return DefWindowProc(hWnd, uMsg, wParam, lParam);
+}
+
+
+HRESULT
+DeviceManager::CreateWindowDeviceAndSwapChain(const DeviceCreationParameters& params, LPWSTR title)
+{
+ g_DeviceManagerInstance = this;
+ m_WindowTitle = title;
+
+ HINSTANCE hInstance = GetModuleHandle(NULL);
+ WNDCLASSEX windowClass = { sizeof(WNDCLASSEX), CS_HREDRAW | CS_VREDRAW, WindowProc,
+ 0L, 0L, hInstance, NULL, NULL, NULL, NULL, WINDOW_CLASS_NAME, NULL };
+
+ RegisterClassEx(&windowClass);
+
+ UINT windowStyle = params.startFullscreen
+ ? WINDOW_STYLE_FULLSCREEN
+ : params.startMaximized
+ ? (WINDOW_STYLE_NORMAL | WS_MAXIMIZE)
+ : WINDOW_STYLE_NORMAL;
+
+ RECT rect = { 0, 0, params.backBufferWidth, params.backBufferHeight };
+ AdjustWindowRect(&rect, windowStyle, FALSE);
+
+ m_hWnd = CreateWindowEx(
+ 0,
+ WINDOW_CLASS_NAME,
+ title,
+ windowStyle,
+ CW_USEDEFAULT,
+ CW_USEDEFAULT,
+ rect.right - rect.left,
+ rect.bottom - rect.top,
+ GetDesktopWindow(),
+ NULL,
+ hInstance,
+ NULL
+ );
+
+ if(!m_hWnd)
+ {
+#ifdef DEBUG
+ DWORD errorCode = GetLastError();
+ printf("CreateWindowEx error code = 0x%x\n", errorCode);
+#endif
+
+ MessageBox(NULL, L"Cannot create window", m_WindowTitle.c_str(), MB_OK | MB_ICONERROR);
+ return E_FAIL;
+ }
+
+ UpdateWindow(m_hWnd);
+
+ HRESULT hr = E_FAIL;
+
+ RECT clientRect;
+ GetClientRect(m_hWnd, &clientRect);
+ UINT width = clientRect.right - clientRect.left;
+ UINT height = clientRect.bottom - clientRect.top;
+
+ ZeroMemory(&m_SwapChainDesc, sizeof(m_SwapChainDesc));
+ m_SwapChainDesc.BufferCount = params.swapChainBufferCount;
+ m_SwapChainDesc.BufferDesc.Width = width;
+ m_SwapChainDesc.BufferDesc.Height = height;
+ m_SwapChainDesc.BufferDesc.Format = params.swapChainFormat;
+ m_SwapChainDesc.BufferDesc.RefreshRate.Numerator = params.refreshRate;
+ m_SwapChainDesc.BufferDesc.RefreshRate.Denominator = 0;
+ m_SwapChainDesc.BufferUsage = params.swapChainUsage;
+ m_SwapChainDesc.OutputWindow = m_hWnd;
+ m_SwapChainDesc.SampleDesc.Count = params.swapChainSampleCount;
+ m_SwapChainDesc.SampleDesc.Quality = 0;
+ m_SwapChainDesc.Windowed = !params.startFullscreen;
+ m_SwapChainDesc.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH;
+
+ hr = D3D11CreateDeviceAndSwapChain(
+ NULL, // pAdapter
+ params.driverType, // DriverType
+ NULL, // Software
+ params.createDeviceFlags, // Flags
+ &params.featureLevel, // pFeatureLevels
+ 1, // FeatureLevels
+ D3D11_SDK_VERSION, // SDKVersion
+ &m_SwapChainDesc, // pSwapChainDesc
+ &m_SwapChain, // ppSwapChain
+ &m_Device, // ppDevice
+ NULL, // pFeatureLevel
+ &m_ImmediateContext // ppImmediateContext
+ );
+
+ if(FAILED(hr))
+ return hr;
+
+ m_DepthStencilDesc.ArraySize = 1;
+ m_DepthStencilDesc.BindFlags = D3D11_BIND_DEPTH_STENCIL;
+ m_DepthStencilDesc.CPUAccessFlags = 0;
+ m_DepthStencilDesc.Format = params.depthStencilFormat;
+ m_DepthStencilDesc.Width = width;
+ m_DepthStencilDesc.Height = height;
+ m_DepthStencilDesc.MipLevels = 1;
+ m_DepthStencilDesc.MiscFlags = 0;
+ m_DepthStencilDesc.SampleDesc.Count = params.swapChainSampleCount;
+ m_DepthStencilDesc.SampleDesc.Quality = 0;
+ m_DepthStencilDesc.Usage = D3D11_USAGE_DEFAULT;
+
+ hr = CreateRenderTargetAndDepthStencil();
+
+ if(FAILED(hr))
+ return hr;
+
+ DeviceCreated();
+ BackBufferResized();
+
+ return S_OK;
+}
+
+void
+DeviceManager::Shutdown()
+{
+ if(m_SwapChain && GetWindowState() == kWindowFullscreen)
+ m_SwapChain->SetFullscreenState(false, NULL);
+
+ DeviceDestroyed();
+
+ SAFE_RELEASE(m_BackBufferRTV);
+ SAFE_RELEASE(m_DepthStencilDSV);
+ SAFE_RELEASE(m_DepthStencilBuffer);
+
+ g_DeviceManagerInstance = NULL;
+ SAFE_RELEASE(m_SwapChain);
+ SAFE_RELEASE(m_Device);
+
+ if(m_hWnd)
+ {
+ DestroyWindow(m_hWnd);
+ m_hWnd = NULL;
+ }
+}
+
+HRESULT
+DeviceManager::CreateRenderTargetAndDepthStencil()
+{
+ HRESULT hr;
+
+ ID3D11Texture2D *backBuffer = NULL;
+ hr = m_SwapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), (LPVOID*)&backBuffer);
+ if (FAILED(hr))
+ return hr;
+
+ hr = m_Device->CreateRenderTargetView(backBuffer, NULL, &m_BackBufferRTV);
+ backBuffer->Release();
+ if (FAILED(hr))
+ return hr;
+
+ if(m_DepthStencilDesc.Format != DXGI_FORMAT_UNKNOWN)
+ {
+ hr = m_Device->CreateTexture2D(&m_DepthStencilDesc, NULL, &m_DepthStencilBuffer);
+ if (FAILED(hr))
+ return hr;
+
+ hr = m_Device->CreateDepthStencilView(m_DepthStencilBuffer, NULL, &m_DepthStencilDSV);
+ if (FAILED(hr))
+ return hr;
+ }
+
+ return S_OK;
+}
+
+void
+DeviceManager::MessageLoop()
+{
+ MSG msg = {0};
+
+ LARGE_INTEGER perfFreq, previousTime;
+ QueryPerformanceFrequency(&perfFreq);
+ QueryPerformanceCounter(&previousTime);
+
+ while (WM_QUIT != msg.message)
+ {
+ if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
+ {
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
+ else
+ {
+ LARGE_INTEGER newTime;
+ QueryPerformanceCounter(&newTime);
+
+ double elapsedSeconds = (m_FixedFrameInterval >= 0)
+ ? m_FixedFrameInterval
+ : (double)(newTime.QuadPart - previousTime.QuadPart) / (double)perfFreq.QuadPart;
+
+ if(m_SwapChain && GetWindowState() != kWindowMinimized)
+ {
+ Animate(elapsedSeconds);
+ Render();
+ m_SwapChain->Present(m_SyncInterval, 0);
+ Sleep(0);
+ }
+ else
+ {
+ // Release CPU resources when idle
+ Sleep(1);
+ }
+
+ {
+ m_vFrameTimes.push_back(elapsedSeconds);
+ double timeSum = 0;
+ for(auto it = m_vFrameTimes.begin(); it != m_vFrameTimes.end(); it++)
+ timeSum += *it;
+
+ if(timeSum > m_AverageTimeUpdateInterval)
+ {
+ m_AverageFrameTime = timeSum / (double)m_vFrameTimes.size();
+ m_vFrameTimes.clear();
+ }
+ }
+
+ previousTime = newTime;
+ }
+ }
+}
+
+LRESULT
+DeviceManager::MsgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+ switch(uMsg)
+ {
+ case WM_DESTROY:
+ case WM_CLOSE:
+ PostQuitMessage(0);
+ return 0;
+
+ case WM_SYSKEYDOWN:
+ if(wParam == VK_F4)
+ {
+ PostQuitMessage(0);
+ return 0;
+ }
+ break;
+
+ case WM_SIZE:
+ // Ignore the WM_SIZE event if there is no device,
+ // or if the window has been minimized (size == 0),
+ // or if it has been restored to the previous size
+ if (m_Device
+ && (lParam != 0)
+ && (LOWORD(lParam) != m_SwapChainDesc.BufferDesc.Width || HIWORD(lParam) != m_SwapChainDesc.BufferDesc.Height))
+ {
+ ID3D11RenderTargetView *nullRTV = NULL;
+ m_ImmediateContext->OMSetRenderTargets(1, &nullRTV, NULL);
+ SAFE_RELEASE(m_BackBufferRTV);
+ SAFE_RELEASE(m_DepthStencilDSV);
+ SAFE_RELEASE(m_DepthStencilBuffer);
+
+ if (m_SwapChain)
+ {
+ // Resize the swap chain
+ m_SwapChainDesc.BufferDesc.Width = LOWORD(lParam);
+ m_SwapChainDesc.BufferDesc.Height = HIWORD(lParam);
+ m_SwapChain->ResizeBuffers(m_SwapChainDesc.BufferCount, m_SwapChainDesc.BufferDesc.Width,
+ m_SwapChainDesc.BufferDesc.Height, m_SwapChainDesc.BufferDesc.Format,
+ m_SwapChainDesc.Flags);
+
+ m_DepthStencilDesc.Width = LOWORD(lParam);
+ m_DepthStencilDesc.Height = HIWORD(lParam);
+
+ CreateRenderTargetAndDepthStencil();
+
+ BackBufferResized();
+ }
+ }
+ }
+
+ if( uMsg >= WM_MOUSEFIRST && uMsg <= WM_MOUSELAST ||
+ uMsg >= WM_KEYFIRST && uMsg <= WM_KEYLAST )
+ {
+ // processing messages front-to-back
+ for(auto it = m_vControllers.begin(); it != m_vControllers.end(); it++)
+ {
+ if((*it)->IsEnabled())
+ {
+ // for kb/mouse messages, 0 means the message has been handled
+ if(0 == (*it)->MsgProc(hWnd, uMsg, wParam, lParam))
+ return 0;
+ }
+ }
+ }
+
+ return DefWindowProc(hWnd, uMsg, wParam, lParam);
+}
+
+void
+DeviceManager::Render()
+{
+ D3D11_VIEWPORT viewport = { 0.0f, 0.0f, (float)m_SwapChainDesc.BufferDesc.Width, (float)m_SwapChainDesc.BufferDesc.Height, 0.0f, 1.0f };
+
+ // rendering back-to-front
+ for(auto it = m_vControllers.rbegin(); it != m_vControllers.rend(); it++)
+ {
+ if((*it)->IsEnabled())
+ {
+ m_ImmediateContext->OMSetRenderTargets(1, &m_BackBufferRTV, m_DepthStencilDSV);
+ m_ImmediateContext->RSSetViewports(1, &viewport);
+
+ (*it)->Render(m_Device, m_ImmediateContext, m_BackBufferRTV, m_DepthStencilDSV);
+ }
+ }
+
+ m_ImmediateContext->OMSetRenderTargets(0, NULL, NULL);
+}
+
+void
+DeviceManager::Animate(double fElapsedTimeSeconds)
+{
+ for(auto it = m_vControllers.begin(); it != m_vControllers.end(); it++)
+ {
+ if((*it)->IsEnabled())
+ {
+ (*it)->Animate(fElapsedTimeSeconds);
+ }
+ }
+}
+
+void
+DeviceManager::DeviceCreated()
+{
+ for(auto it = m_vControllers.begin(); it != m_vControllers.end(); it++)
+ {
+ (*it)->DeviceCreated(m_Device);
+ }
+}
+
+void
+DeviceManager::DeviceDestroyed()
+{
+ for(auto it = m_vControllers.begin(); it != m_vControllers.end(); it++)
+ {
+ (*it)->DeviceDestroyed();
+ }
+}
+
+void
+DeviceManager::BackBufferResized()
+{
+ if(m_SwapChain == NULL)
+ return;
+
+ DXGI_SURFACE_DESC backSD;
+ backSD.Format = m_SwapChainDesc.BufferDesc.Format;
+ backSD.Width = m_SwapChainDesc.BufferDesc.Width;
+ backSD.Height = m_SwapChainDesc.BufferDesc.Height;
+ backSD.SampleDesc = m_SwapChainDesc.SampleDesc;
+
+ for(auto it = m_vControllers.begin(); it != m_vControllers.end(); it++)
+ {
+ (*it)->BackBufferResized(m_Device, &backSD);
+ }
+}
+
+HRESULT
+DeviceManager::ChangeBackBufferFormat(DXGI_FORMAT format, UINT sampleCount)
+{
+ HRESULT hr = E_FAIL;
+
+ if((format == DXGI_FORMAT_UNKNOWN || format == m_SwapChainDesc.BufferDesc.Format) &&
+ (sampleCount == 0 || sampleCount == m_SwapChainDesc.SampleDesc.Count))
+ return S_FALSE;
+
+ if(m_Device)
+ {
+ bool fullscreen = (GetWindowState() == kWindowFullscreen);
+ if(fullscreen)
+ m_SwapChain->SetFullscreenState(false, NULL);
+
+ IDXGISwapChain* newSwapChain = NULL;
+ DXGI_SWAP_CHAIN_DESC newSwapChainDesc = m_SwapChainDesc;
+
+ if(format != DXGI_FORMAT_UNKNOWN)
+ newSwapChainDesc.BufferDesc.Format = format;
+ if(sampleCount != 0)
+ newSwapChainDesc.SampleDesc.Count = sampleCount;
+
+ IDXGIAdapter* pDXGIAdapter = GetDXGIAdapter();
+
+ IDXGIFactory* pDXGIFactory = NULL;
+ pDXGIAdapter->GetParent(__uuidof(IDXGIFactory), reinterpret_cast<void**>(&pDXGIFactory));
+
+ hr = pDXGIFactory->CreateSwapChain(m_Device, &newSwapChainDesc, &newSwapChain);
+
+ pDXGIFactory->Release();
+ pDXGIAdapter->Release();
+
+ if (FAILED(hr))
+ {
+ if(fullscreen)
+ m_SwapChain->SetFullscreenState(true, NULL);
+
+ return hr;
+ }
+
+ SAFE_RELEASE(m_BackBufferRTV);
+ SAFE_RELEASE(m_SwapChain);
+ SAFE_RELEASE(m_DepthStencilBuffer);
+ SAFE_RELEASE(m_DepthStencilDSV);
+
+ m_SwapChain = newSwapChain;
+ m_SwapChainDesc = newSwapChainDesc;
+
+ m_DepthStencilDesc.SampleDesc.Count = sampleCount;
+
+ if(fullscreen)
+ m_SwapChain->SetFullscreenState(true, NULL);
+
+ CreateRenderTargetAndDepthStencil();
+ BackBufferResized();
+ }
+
+ return S_OK;
+}
+
+void
+DeviceManager::AddControllerToFront(IVisualController* pController)
+{
+ m_vControllers.remove(pController);
+ m_vControllers.push_front(pController);
+}
+
+void
+DeviceManager::AddControllerToBack(IVisualController* pController)
+{
+ m_vControllers.remove(pController);
+ m_vControllers.push_back(pController);
+}
+
+void
+DeviceManager::RemoveController(IVisualController* pController)
+{
+ m_vControllers.remove(pController);
+}
+
+HRESULT
+DeviceManager::ResizeWindow(int width, int height)
+{
+ if(m_SwapChain == NULL)
+ return E_FAIL;
+
+ RECT rect;
+ GetWindowRect(m_hWnd, &rect);
+
+ ShowWindow(m_hWnd, SW_RESTORE);
+
+ if(!MoveWindow(m_hWnd, rect.left, rect.top, width, height, true))
+ return E_FAIL;
+
+ // No need to call m_SwapChain->ResizeBackBuffer because MoveWindow will send WM_SIZE, which calls that function.
+
+ return S_OK;
+}
+
+HRESULT
+DeviceManager::EnterFullscreenMode(int width, int height)
+{
+ if(m_SwapChain == NULL)
+ return E_FAIL;
+
+ if(GetWindowState() == kWindowFullscreen)
+ return S_FALSE;
+
+ if(width <= 0 || height <= 0)
+ {
+ width = m_SwapChainDesc.BufferDesc.Width;
+ height = m_SwapChainDesc.BufferDesc.Height;
+ }
+
+ SetWindowLong(m_hWnd, GWL_STYLE, WINDOW_STYLE_FULLSCREEN);
+ MoveWindow(m_hWnd, 0, 0, width, height, true);
+
+ HRESULT hr = m_SwapChain->SetFullscreenState(true, NULL);
+
+ if(FAILED(hr))
+ {
+ SetWindowLong(m_hWnd, GWL_STYLE, WINDOW_STYLE_NORMAL);
+ return hr;
+ }
+
+ UpdateWindow(m_hWnd);
+ m_SwapChain->GetDesc(&m_SwapChainDesc);
+
+ return S_OK;
+}
+
+HRESULT
+DeviceManager::LeaveFullscreenMode(int windowWidth, int windowHeight)
+{
+ if(m_SwapChain == NULL)
+ return E_FAIL;
+
+ if(GetWindowState() != kWindowFullscreen)
+ return S_FALSE;
+
+ HRESULT hr = m_SwapChain->SetFullscreenState(false, NULL);
+ if(FAILED(hr)) return hr;
+
+ SetWindowLong(m_hWnd, GWL_STYLE, WINDOW_STYLE_NORMAL);
+
+ if(windowWidth <= 0 || windowHeight <= 0)
+ {
+ windowWidth = m_SwapChainDesc.BufferDesc.Width;
+ windowHeight = m_SwapChainDesc.BufferDesc.Height;
+ }
+
+ RECT rect = { 0, 0, windowWidth, windowHeight };
+ AdjustWindowRect(&rect, WINDOW_STYLE_NORMAL, FALSE);
+ MoveWindow(m_hWnd, 0, 0, rect.right - rect.left, rect.bottom - rect.top, true);
+ UpdateWindow(m_hWnd);
+
+ m_SwapChain->GetDesc(&m_SwapChainDesc);
+
+ return S_OK;
+}
+
+HRESULT
+DeviceManager::ToggleFullscreen()
+{
+ if(GetWindowState() == kWindowFullscreen)
+ return LeaveFullscreenMode();
+ else
+ return EnterFullscreenMode();
+}
+
+DeviceManager::WindowState
+DeviceManager::GetWindowState()
+{
+ if(m_SwapChain && !m_SwapChainDesc.Windowed)
+ return kWindowFullscreen;
+
+ if(m_hWnd == INVALID_HANDLE_VALUE)
+ return kWindowNone;
+
+ if(IsZoomed(m_hWnd))
+ return kWindowMaximized;
+
+ if(IsIconic(m_hWnd))
+ return kWindowMinimized;
+
+ return kWindowNormal;
+}
+
+HRESULT
+DeviceManager::GetDisplayResolution(int& width, int& height)
+{
+ if(m_hWnd != INVALID_HANDLE_VALUE)
+ {
+ HMONITOR monitor = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTOPRIMARY);
+ MONITORINFO info;
+ info.cbSize = sizeof(MONITORINFO);
+
+ if(GetMonitorInfo(monitor, &info))
+ {
+ width = info.rcMonitor.right - info.rcMonitor.left;
+ height = info.rcMonitor.bottom - info.rcMonitor.top;
+ return S_OK;
+ }
+ }
+
+ return E_FAIL;
+}
+
+IDXGIAdapter*
+DeviceManager::GetDXGIAdapter()
+{
+ if(!m_Device)
+ return NULL;
+
+ IDXGIDevice* pDXGIDevice = NULL;
+ m_Device->QueryInterface(__uuidof(IDXGIDevice), reinterpret_cast<void**>(&pDXGIDevice));
+
+ IDXGIAdapter* pDXGIAdapter = NULL;
+ pDXGIDevice->GetParent(__uuidof(IDXGIAdapter), reinterpret_cast<void**>(&pDXGIAdapter));
+
+ pDXGIDevice->Release();
+
+ return pDXGIAdapter;
+}
diff --git a/samples/VolumetricLightingTest/d3d11/DeviceManager.h b/samples/VolumetricLightingTest/d3d11/DeviceManager.h
new file mode 100644
index 0000000..4bd164a
--- /dev/null
+++ b/samples/VolumetricLightingTest/d3d11/DeviceManager.h
@@ -0,0 +1,148 @@
+// TAGRELEASE: PUBLIC
+
+#pragma once
+#include <Windows.h>
+#include <DXGI.h>
+#include <D3D11.h>
+#include <list>
+
+
+struct DeviceCreationParameters
+{
+ bool startMaximized;
+ bool startFullscreen;
+ int backBufferWidth;
+ int backBufferHeight;
+ int refreshRate;
+ int swapChainBufferCount;
+ DXGI_FORMAT swapChainFormat;
+ DXGI_FORMAT depthStencilFormat;
+ DXGI_USAGE swapChainUsage;
+ int swapChainSampleCount;
+ UINT createDeviceFlags;
+ D3D_DRIVER_TYPE driverType;
+ D3D_FEATURE_LEVEL featureLevel;
+
+ DeviceCreationParameters()
+ : startMaximized(false)
+ , startFullscreen(false)
+ , backBufferWidth(1280)
+ , backBufferHeight(720)
+ , refreshRate(0)
+ , swapChainBufferCount(1)
+ , swapChainFormat(DXGI_FORMAT_R8G8B8A8_UNORM)
+ , depthStencilFormat(DXGI_FORMAT_D24_UNORM_S8_UINT)
+ , swapChainUsage(DXGI_USAGE_SHADER_INPUT | DXGI_USAGE_RENDER_TARGET_OUTPUT)
+ , swapChainSampleCount(1)
+ , createDeviceFlags(0)
+ , driverType(D3D_DRIVER_TYPE_HARDWARE)
+ , featureLevel(D3D_FEATURE_LEVEL_11_0)
+ { }
+};
+
+#pragma warning(push)
+#pragma warning(disable: 4100) // unreferenced formal parameter
+class IVisualController
+{
+private:
+ bool m_Enabled;
+public:
+ IVisualController() : m_Enabled(true) { }
+
+ virtual LRESULT MsgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { return 1; }
+ virtual void Render(ID3D11Device* pDevice, ID3D11DeviceContext* pDeviceContext, ID3D11RenderTargetView* pRTV, ID3D11DepthStencilView* pDSV) { }
+ virtual void Animate(double fElapsedTimeSeconds) { }
+ virtual HRESULT DeviceCreated(ID3D11Device* pDevice) { return S_OK; }
+ virtual void DeviceDestroyed() { }
+ virtual void BackBufferResized(ID3D11Device* pDevice, const DXGI_SURFACE_DESC* pBackBufferSurfaceDesc) { }
+
+ virtual void EnableController() { m_Enabled = true; }
+ virtual void DisableController() { m_Enabled = false; }
+ virtual bool IsEnabled() { return m_Enabled; }
+};
+#pragma warning(pop)
+
+class DeviceManager
+{
+public:
+ enum WindowState
+ {
+ kWindowNone,
+ kWindowNormal,
+ kWindowMinimized,
+ kWindowMaximized,
+ kWindowFullscreen
+ };
+
+protected:
+ ID3D11Device* m_Device;
+ ID3D11DeviceContext* m_ImmediateContext;
+ IDXGISwapChain* m_SwapChain;
+ ID3D11RenderTargetView* m_BackBufferRTV;
+ ID3D11Texture2D* m_DepthStencilBuffer;
+ ID3D11DepthStencilView* m_DepthStencilDSV;
+ DXGI_SWAP_CHAIN_DESC m_SwapChainDesc;
+ D3D11_TEXTURE2D_DESC m_DepthStencilDesc;
+ HWND m_hWnd;
+ std::list<IVisualController*> m_vControllers;
+ std::wstring m_WindowTitle;
+ double m_FixedFrameInterval;
+ UINT m_SyncInterval;
+ std::list<double> m_vFrameTimes;
+ double m_AverageFrameTime;
+ double m_AverageTimeUpdateInterval;
+private:
+ HRESULT CreateRenderTargetAndDepthStencil();
+public:
+
+ DeviceManager()
+ : m_Device(NULL)
+ , m_ImmediateContext(NULL)
+ , m_SwapChain(NULL)
+ , m_BackBufferRTV(NULL)
+ , m_DepthStencilBuffer(NULL)
+ , m_DepthStencilDSV(NULL)
+ , m_hWnd(NULL)
+ , m_WindowTitle(L"")
+ , m_FixedFrameInterval(-1)
+ , m_SyncInterval(0)
+ , m_AverageFrameTime(0)
+ , m_AverageTimeUpdateInterval(0.5)
+ { }
+
+ virtual ~DeviceManager()
+ { Shutdown(); }
+
+ virtual HRESULT CreateWindowDeviceAndSwapChain(const DeviceCreationParameters& params, LPWSTR windowTitle);
+ virtual HRESULT ChangeBackBufferFormat(DXGI_FORMAT format, UINT sampleCount);
+ virtual HRESULT ResizeWindow(int width, int height);
+ virtual HRESULT EnterFullscreenMode(int width = 0, int height = 0);
+ virtual HRESULT LeaveFullscreenMode(int windowWidth = 0, int windowHeight = 0);
+ virtual HRESULT ToggleFullscreen();
+
+ virtual void Shutdown();
+ virtual void MessageLoop();
+ virtual LRESULT MsgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
+ virtual void Render();
+ virtual void Animate(double fElapsedTimeSeconds);
+ virtual void DeviceCreated();
+ virtual void DeviceDestroyed();
+ virtual void BackBufferResized();
+
+ void AddControllerToFront(IVisualController* pController);
+ void AddControllerToBack(IVisualController* pController);
+ void RemoveController(IVisualController* pController);
+
+ void SetFixedFrameInterval(double seconds) { m_FixedFrameInterval = seconds; }
+ void DisableFixedFrameInterval() { m_FixedFrameInterval = -1; }
+
+ HWND GetHWND() { return m_hWnd; }
+ ID3D11Device* GetDevice() { return m_Device; }
+ WindowState GetWindowState();
+ bool GetVsyncEnabled() { return m_SyncInterval > 0; }
+ void SetVsyncEnabled(bool enabled) { m_SyncInterval = enabled ? 1 : 0; }
+ HRESULT GetDisplayResolution(int& width, int& height);
+ IDXGIAdapter* GetDXGIAdapter();
+ double GetAverageFrameTime() { return m_AverageFrameTime; }
+ void SetAverageTimeUpdateInterval(double value) { m_AverageTimeUpdateInterval = value; }
+};
diff --git a/samples/VolumetricLightingTest/d3d11/compiled_shaders_d3d11.cpp b/samples/VolumetricLightingTest/d3d11/compiled_shaders_d3d11.cpp
new file mode 100644
index 0000000..43f2e5d
--- /dev/null
+++ b/samples/VolumetricLightingTest/d3d11/compiled_shaders_d3d11.cpp
@@ -0,0 +1,36 @@
+// This code contains NVIDIA Confidential Information and is disclosed
+// under the Mutual Non-Disclosure Agreement.
+//
+// Notice
+// ALL NVIDIA DESIGN SPECIFICATIONS AND CODE ("MATERIALS") ARE PROVIDED "AS IS" NVIDIA MAKES
+// NO REPRESENTATIONS, WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
+//
+// 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. No third party distribution is allowed unless
+// expressly authorized by NVIDIA. 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 (c) 2003 - 2016 NVIDIA Corporation. All rights reserved.
+//
+// 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.
+//
+
+#include <stdint.h>
+namespace d3d11 { namespace shaders {
+ #include <shaders/post_PS.mux.bytecode>
+ #include <shaders/quad_VS.mux.bytecode>
+ #include <shaders/scene_VS.mux.bytecode>
+ #include <shaders/scene_GS.mux.bytecode>
+ #include <shaders/scene_PS.mux.bytecode>
+}; /* namespace shaders */ }; /* namespace d3d11 */
diff --git a/samples/VolumetricLightingTest/d3d11/compiled_shaders_d3d11.h b/samples/VolumetricLightingTest/d3d11/compiled_shaders_d3d11.h
new file mode 100644
index 0000000..2488d61
--- /dev/null
+++ b/samples/VolumetricLightingTest/d3d11/compiled_shaders_d3d11.h
@@ -0,0 +1,45 @@
+// This code contains NVIDIA Confidential Information and is disclosed
+// under the Mutual Non-Disclosure Agreement.
+//
+// Notice
+// ALL NVIDIA DESIGN SPECIFICATIONS AND CODE ("MATERIALS") ARE PROVIDED "AS IS" NVIDIA MAKES
+// NO REPRESENTATIONS, WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
+//
+// 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. No third party distribution is allowed unless
+// expressly authorized by NVIDIA. 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 (c) 2003 - 2016 NVIDIA Corporation. All rights reserved.
+//
+// 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.
+//
+
+#ifndef COMPILED_SHADERS_D3D11_H
+#define COMPILED_SHADERS_D3D11_H
+////////////////////////////////////////////////////////////////////////////////
+#include <stdint.h>
+namespace d3d11 { namespace shaders {
+ #include <shaders/post_PS.mux.h>
+ #include <shaders/quad_VS.mux.h>
+ #include <shaders/scene_VS.mux.h>
+ #include <shaders/scene_GS.mux.h>
+ #include <shaders/scene_PS.mux.h>
+}; /* namespace shaders */ }; /* namespace d3d11 */
+// We use the namespaces to avoid conflicts if supporting multiple APIs
+// but they aren't needed wherever these would be included.
+using namespace d3d11;
+using namespace shaders;
+////////////////////////////////////////////////////////////////////////////////
+#endif // COMPILED_SHADERS_D3D11_H
diff --git a/samples/VolumetricLightingTest/d3d11/d3d11_main.cpp b/samples/VolumetricLightingTest/d3d11/d3d11_main.cpp
new file mode 100644
index 0000000..308d025
--- /dev/null
+++ b/samples/VolumetricLightingTest/d3d11/d3d11_main.cpp
@@ -0,0 +1,478 @@
+// This code contains NVIDIA Confidential Information and is disclosed
+// under the Mutual Non-Disclosure Agreement.
+//
+// Notice
+// ALL NVIDIA DESIGN SPECIFICATIONS AND CODE ("MATERIALS") ARE PROVIDED "AS IS" NVIDIA MAKES
+// NO REPRESENTATIONS, WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
+//
+// 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. No third party distribution is allowed unless
+// expressly authorized by NVIDIA. 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 (c) 2003 - 2016 NVIDIA Corporation. All rights reserved.
+//
+// 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.
+//
+#include "common.h"
+
+#include "compiled_shaders_d3d11.h"
+#include "DeviceManager.h"
+#include "d3d11_util.h"
+#include "scene.h"
+
+#include <Nv/VolumetricLighting/NvVolumetricLighting.h>
+#include <d3d11.h>
+
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// Control rendering of the scene
+#define LOAD_SHADERS(x) LoadShaders(device, ##x##::permutation_code, ##x##::permutation_length, shaders::##x##::PERMUTATION_ENTRY_COUNT, shaders.##x)
+
+class SceneController : public IVisualController
+{
+private:
+ Scene * pScene_;
+ DeviceManager * pManager_;
+
+ uint32_t framebufferWidth_;
+ uint32_t framebufferHeight_;
+
+ // Resources used by the scene
+
+ ConstantBuffer <Scene::ViewCB> * pViewCB_;
+ ConstantBuffer <Scene::ObjectCB> * pObjectCB_;
+ ConstantBuffer <Scene::LightCB> * pLightCB_;
+
+ RenderTarget * pSceneRT_;
+ DepthTarget * pSceneDepth_;
+ DepthTarget * pShadowMap_;
+ DepthTarget * pParaboloidShadowMap_;
+
+ ID3D11SamplerState * ss_shadowmap_;
+ ID3D11RasterizerState * rs_render_;
+ ID3D11BlendState * bs_no_color_;
+ ID3D11DepthStencilState * ds_shadowmap_;
+
+ struct
+ {
+ ID3D11PixelShader ** post_PS;
+ ID3D11VertexShader ** quad_VS;
+ ID3D11VertexShader ** scene_VS;
+ ID3D11GeometryShader ** scene_GS;
+ ID3D11PixelShader ** scene_PS;
+ } shaders;
+
+ // GWVL Platform-specific info
+ Nv::Vl::PlatformDesc platformDesc_;
+
+public:
+
+ SceneController(Scene * pScene, DeviceManager * pManager)
+ {
+ pScene_ = pScene;
+ pManager_ = pManager;
+ }
+
+ virtual HRESULT DeviceCreated(ID3D11Device* device)
+ {
+ Nv::Vl::OpenLibrary();
+
+ // Shaders
+ LOAD_SHADERS(post_PS);
+ LOAD_SHADERS(quad_VS);
+ LOAD_SHADERS(scene_VS);
+ LOAD_SHADERS(scene_GS);
+ LOAD_SHADERS(scene_PS);
+
+ // Constant Buffers
+ pViewCB_ = ConstantBuffer<Scene::ViewCB>::Create(device);
+ pObjectCB_ = ConstantBuffer<Scene::ObjectCB>::Create(device);
+ pLightCB_ = ConstantBuffer<Scene::LightCB>::Create(device);
+
+ // Textures
+ pSceneRT_ = nullptr;
+ pSceneDepth_ = nullptr;
+ pShadowMap_ = DepthTarget::Create(device, Scene::SHADOWMAP_RESOLUTION, Scene::SHADOWMAP_RESOLUTION, 1, DXGI_FORMAT_D16_UNORM, 1, "Simple Shadow Map");
+ pParaboloidShadowMap_ = DepthTarget::Create(device, Scene::SHADOWMAP_RESOLUTION, Scene::SHADOWMAP_RESOLUTION, 1, DXGI_FORMAT_D16_UNORM, 2, "Dual-Paraboloid Shadow Map");
+
+ // Shadowmap Sampler
+ {
+ CD3D11_SAMPLER_DESC desc((CD3D11_DEFAULT()));
+ desc.Filter = D3D11_FILTER_COMPARISON_MIN_MAG_LINEAR_MIP_POINT;
+ desc.ComparisonFunc = D3D11_COMPARISON_LESS;
+ device->CreateSamplerState(&desc, &ss_shadowmap_);
+ }
+ // No color output blend-state
+ {
+ CD3D11_BLEND_DESC desc((CD3D11_DEFAULT()));
+ desc.RenderTarget[0].RenderTargetWriteMask = 0x00000000;
+ device->CreateBlendState(&desc, &bs_no_color_);
+ }
+ {
+ CD3D11_RASTERIZER_DESC rsDesc((CD3D11_DEFAULT()));
+ rsDesc.CullMode = D3D11_CULL_NONE;
+ device->CreateRasterizerState(&rsDesc, &rs_render_);
+ }
+ {
+ CD3D11_DEPTH_STENCIL_DESC dsDesc((CD3D11_DEFAULT()));
+ device->CreateDepthStencilState(&dsDesc, &ds_shadowmap_);
+ }
+ // Initialize GWVL settings info
+ {
+ platformDesc_.platform = Nv::Vl::PlatformName::D3D11;
+ platformDesc_.d3d11.pDevice = device;
+ }
+
+ return S_OK;
+ }
+
+ virtual void DeviceDestroyed()
+ {
+ // Release resources
+ SAFE_RELEASE(ss_shadowmap_);
+ SAFE_RELEASE(bs_no_color_);
+ SAFE_RELEASE(rs_render_);
+ SAFE_RELEASE(ds_shadowmap_);
+ SAFE_DELETE(pViewCB_);
+ SAFE_DELETE(pObjectCB_);
+ SAFE_DELETE(pLightCB_);
+ SAFE_DELETE(pSceneRT_);
+ SAFE_DELETE(pSceneDepth_);
+ SAFE_DELETE(pShadowMap_);
+ SAFE_DELETE(pParaboloidShadowMap_);
+ SAFE_DELETE_ARRAY(shaders.post_PS);
+ SAFE_DELETE_ARRAY(shaders.quad_VS);
+ SAFE_DELETE_ARRAY(shaders.scene_VS);
+ SAFE_DELETE_ARRAY(shaders.scene_GS);
+ SAFE_DELETE_ARRAY(shaders.scene_PS);
+
+ pScene_->Release();
+ Nv::Vl::CloseLibrary();
+ }
+
+ virtual void BackBufferResized(ID3D11Device* device, const DXGI_SURFACE_DESC* surface_desc)
+ {
+ framebufferWidth_ = surface_desc->Width;
+ framebufferHeight_ = surface_desc->Height;
+
+ // Create back-buffer sized resources
+ SAFE_DELETE(pSceneRT_);
+ SAFE_DELETE(pSceneDepth_);
+ pSceneRT_ = RenderTarget::Create(device, framebufferWidth_, framebufferHeight_, surface_desc->SampleDesc.Count, DXGI_FORMAT_R16G16B16A16_FLOAT, "Scene Render Target");
+ pSceneDepth_ = DepthTarget::Create(device, framebufferWidth_, framebufferHeight_, surface_desc->SampleDesc.Count, DXGI_FORMAT_D24_UNORM_S8_UINT, 1, "Scene Depth");
+
+ // Update the context desc and (re-)create the context
+ pScene_->updateFramebuffer(framebufferWidth_, framebufferHeight_, surface_desc->SampleDesc.Count);
+ }
+
+ virtual void Render(ID3D11Device*, ID3D11DeviceContext* ctx, ID3D11RenderTargetView* pFramebuffer_RTV, ID3D11DepthStencilView*)
+ {
+ NV_PERFEVENT(ctx, "Render Frame");
+ if (!pScene_->isCtxValid())
+ {
+ pScene_->createCtx(&platformDesc_);
+ }
+
+ float clear_color[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
+ ctx->ClearRenderTargetView( pSceneRT_->getRTV(), clear_color);
+ ctx->ClearDepthStencilView(pSceneDepth_->getDSV(), D3D11_CLEAR_DEPTH, 1.0, 0);
+
+ ID3D11Buffer * CBs[] = {
+ pViewCB_->getCB(),
+ pObjectCB_->getCB(),
+ pLightCB_->getCB()
+ };
+
+ auto RenderScene = [=]()
+ {
+ NV_PERFEVENT(ctx, "Draw Scene Geometry");
+ const float scene_range[] = { -6, -3, 3, 6 };
+ for (auto x : scene_range)
+ {
+ for (auto y : scene_range)
+ {
+ for (auto z : scene_range)
+ {
+ Scene::ObjectCB * pObject = this->pObjectCB_->Map(ctx);
+ pScene_->setupObjectCB(pObject, Nv::NvVec3(x, y, z));
+ this->pObjectCB_->Unmap(ctx);
+
+ ctx->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
+ ctx->IASetVertexBuffers(0,0,nullptr, nullptr,nullptr);
+ ctx->IASetInputLayout(nullptr);
+ ctx->IASetIndexBuffer(nullptr, DXGI_FORMAT_R16_UINT, 0);
+ ctx->Draw(36, 0);
+ }
+ }
+ }
+ };
+
+ //----------------------------------------------------------------------
+ // Render the light's shadow map
+ {
+ NV_PERFEVENT(ctx, "Render Shadow Map");
+ {
+ Scene::ViewCB * pView = pViewCB_->Map(ctx);
+ pScene_->setupLightViewCB(pView);
+ pViewCB_->Unmap(ctx);
+ }
+
+ ctx->ClearState();
+ CD3D11_VIEWPORT shadowmap_viewport;
+ shadowmap_viewport.TopLeftX = 0;
+ shadowmap_viewport.TopLeftY = 0;
+ shadowmap_viewport.Width = static_cast<float>(Scene::SHADOWMAP_RESOLUTION);
+ shadowmap_viewport.Height = static_cast<float>(Scene::SHADOWMAP_RESOLUTION);
+ shadowmap_viewport.MinDepth = 0.0f;
+ shadowmap_viewport.MaxDepth = 1.0f;
+ ctx->RSSetState(rs_render_);
+ ctx->VSSetShader(shaders.scene_VS[scene_VS::SINGLE], nullptr, 0);
+ ctx->VSSetConstantBuffers(0, 3, CBs);
+ if (pScene_->getLightMode() == Scene::eLightMode::OMNI)
+ {
+ ctx->ClearDepthStencilView(pParaboloidShadowMap_->getDSV(), D3D11_CLEAR_DEPTH, 1.0, 0);
+ ctx->OMSetRenderTargets(0, nullptr, pParaboloidShadowMap_->getDSV());
+ CD3D11_VIEWPORT dual_viewports[] = { shadowmap_viewport, shadowmap_viewport };
+ ctx->RSSetViewports(2, dual_viewports);
+ ctx->GSSetShader(shaders.scene_GS[scene_GS::SINGLE], nullptr, 0);
+ ctx->GSSetConstantBuffers(0, 3, CBs);
+ }
+ else
+ {
+ ctx->ClearDepthStencilView(pShadowMap_->getDSV(), D3D11_CLEAR_DEPTH, 1.0, 0);
+ ctx->OMSetRenderTargets(0, nullptr, pShadowMap_->getDSV());
+ ctx->RSSetViewports(1, &shadowmap_viewport);
+ }
+ ctx->PSSetShader(nullptr, nullptr, 0);
+ ctx->OMSetBlendState(bs_no_color_, nullptr, 0xFFFFFFFF);
+ ctx->OMSetDepthStencilState(ds_shadowmap_, 0xFF);
+ RenderScene();
+ }
+ ID3D11ShaderResourceView * shadowmap_srv = (pScene_->getLightMode() == Scene::eLightMode::OMNI) ? pParaboloidShadowMap_->getSRV() : pShadowMap_->getSRV();
+
+ //----------------------------------------------------------------------
+ // Render the scene
+ {
+ NV_PERFEVENT(ctx, "Render Main Scene");
+ {
+ Scene::ViewCB * pView = pViewCB_->Map(ctx);
+ Scene::LightCB * pLight = pLightCB_->Map(ctx);
+ pScene_->setupSceneCBs(pView, pLight);
+ pViewCB_->Unmap(ctx);
+ pLightCB_->Unmap(ctx);
+ }
+
+ ctx->ClearState();
+ CD3D11_VIEWPORT scene_viewport;
+ scene_viewport.TopLeftX = 0.0f;
+ scene_viewport.TopLeftY = 0.f;
+ scene_viewport.Width = static_cast<float>(framebufferWidth_);
+ scene_viewport.Height = static_cast<float>(framebufferHeight_);
+ scene_viewport.MinDepth = 0.0f;
+ scene_viewport.MaxDepth = 1.0f;
+ ctx->RSSetViewports(1, &scene_viewport);
+ ctx->RSSetState(rs_render_);
+ ctx->VSSetShader(shaders.scene_VS[scene_VS::SINGLE], nullptr, 0);
+ ctx->VSSetConstantBuffers(0, 3, CBs);
+ ctx->GSSetShader(nullptr, nullptr, 0);
+ scene_PS::Desc ps_desc;
+ switch (pScene_->getLightMode())
+ {
+ default:
+ case Scene::eLightMode::DIRECTIONAL:
+ ps_desc.flags.LIGHTMODE = scene_PS::LIGHTMODE_DIRECTIONAL;
+ break;
+
+ case Scene::eLightMode::SPOTLIGHT:
+ ps_desc.flags.LIGHTMODE = scene_PS::LIGHTMODE_SPOTLIGHT;
+ break;
+
+ case Scene::eLightMode::OMNI:
+ ps_desc.flags.LIGHTMODE = scene_PS::LIGHTMODE_OMNI;
+ break;
+ }
+ ctx->PSSetShader(shaders.scene_PS[ps_desc], nullptr, 0);
+ ctx->PSSetConstantBuffers(0, 3, CBs);
+ ID3D11ShaderResourceView * SRVs[] = { shadowmap_srv };
+ ctx->PSSetShaderResources(0, 1, SRVs);
+ ctx->PSSetSamplers(0, 1, &ss_shadowmap_);
+ ID3D11RenderTargetView * RTVs[] = { pSceneRT_->getRTV() };
+ ctx->OMSetRenderTargets(1, RTVs, pSceneDepth_->getDSV());
+ RenderScene();
+ }
+
+ //----------------------------------------------------------------------
+ // Render the volumetric lighting
+ {
+ NV_PERFEVENT(ctx, "Volumetric Lighting");
+ ctx->ClearState();
+ pScene_->beginAccumulation(ctx, pSceneDepth_->getSRV());
+ pScene_->renderVolume(ctx, shadowmap_srv);
+ pScene_->endAccumulation(ctx);
+ pScene_->applyLighting(ctx, pSceneRT_->getRTV(), pSceneDepth_->getSRV());
+ }
+
+ //----------------------------------------------------------------------
+ // Tonemap to output
+ {
+ NV_PERFEVENT(ctx, "Postprocess");
+ ctx->ClearState();
+ CD3D11_VIEWPORT scene_viewport;
+ scene_viewport.TopLeftX = 0.0f;
+ scene_viewport.TopLeftY = 0.f;
+ scene_viewport.Width = static_cast<float>(framebufferWidth_);
+ scene_viewport.Height = static_cast<float>(framebufferHeight_);
+ scene_viewport.MinDepth = 0.0f;
+ scene_viewport.MaxDepth = 1.0f;
+ ctx->RSSetViewports(1, &scene_viewport);
+ ctx->RSSetState(rs_render_);
+ ID3D11RenderTargetView * RTVs[] = { pFramebuffer_RTV };
+ ctx->OMSetRenderTargets(1, RTVs, nullptr);
+ ctx->VSSetShader(shaders.quad_VS[quad_VS::SINGLE], nullptr, 0);
+ ctx->PSSetShader(shaders.post_PS[post_PS::SINGLE], nullptr, 0);
+ ID3D11ShaderResourceView * SRVs[] = { pSceneRT_->getSRV() };
+ ctx->PSSetShaderResources(0, 1, SRVs);
+ ctx->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
+ ctx->IASetVertexBuffers(0, 0, nullptr, nullptr, nullptr);
+ ctx->IASetInputLayout(nullptr);
+ ctx->IASetIndexBuffer(nullptr, DXGI_FORMAT_R16_UINT, 0);
+ ctx->Draw(3, 0);
+ }
+ }
+
+ virtual void Animate(double fElapsedTimeSeconds)
+ {
+ pScene_->animate((float)fElapsedTimeSeconds);
+ }
+
+ virtual LRESULT MsgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
+ {
+ hWnd; uMsg; wParam; lParam;
+ switch (uMsg)
+ {
+ case WM_KEYDOWN:
+ switch (wParam)
+ {
+ case VK_ESCAPE:
+ PostQuitMessage(0);
+ break;
+
+ case VK_F1:
+ pScene_->setDebugMode(Nv::Vl::DebugFlags::NONE);
+ break;
+
+ case VK_F2:
+ pScene_->setDebugMode(Nv::Vl::DebugFlags::NO_BLENDING);
+ break;
+
+ case VK_F3:
+ pScene_->setDebugMode(Nv::Vl::DebugFlags::WIREFRAME);
+ break;
+
+ case VK_F4:
+ pManager_->ToggleFullscreen();
+ break;
+
+ case VK_SPACE:
+ pScene_->togglePause();
+ break;
+
+ case 0x44: // D key - toggle downsample mode
+ pScene_->toggleDownsampleMode();
+ break;
+
+ case 0x46: // F key - toggle fog
+ pScene_->toggleFog();
+ break;
+
+ case 0x4C: // L key - toggle light type
+ pScene_->toggleLightMode();
+ break;
+
+ case 0x4D: // M key - toggle MSAA mode
+ pScene_->toggleMsaaMode();
+ break;
+
+ case 0x4F: // O key - toggle light intensity
+ pScene_->toggleMediumType();
+ break;
+
+ case 0x50: // P key - toggle light intensity
+ pScene_->toggleIntensity();
+ break;
+
+ case 0x54: // T key - toggle temporal filtering
+ pScene_->toggleFiltering();
+ break;
+
+ case 0x55: // U key - toggle upsample mode
+ pScene_->toggleUpsampleMode();
+ break;
+
+ case 0x56: // V key - toggle view mode
+ pScene_->toggleViewpoint();
+ break;
+ }
+ return 0;
+ }
+ return 1;
+ }
+};
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// Entry point to the program. Initializes everything and goes into a message processing
+// loop. Idle time is used to render the scene.
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+int main_D3D11(Scene * pScene)
+{
+ // Enable run-time memory check for debug builds.
+#if (NV_CHECKED)
+ _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
+
+ AllocConsole();
+ freopen("CONIN$", "r",stdin);
+ freopen("CONOUT$", "w",stdout);
+ freopen("CONOUT$", "w",stderr);
+#endif
+
+ DeviceManager * device_manager = new DeviceManager();
+
+ auto scene_controller = SceneController(pScene, device_manager);
+ device_manager->AddControllerToFront(&scene_controller);
+
+ DeviceCreationParameters deviceParams;
+ deviceParams.swapChainFormat = DXGI_FORMAT_R8G8B8A8_UNORM;
+ deviceParams.swapChainSampleCount = 4;
+ deviceParams.startFullscreen = false;
+ deviceParams.backBufferWidth = 1920;
+ deviceParams.backBufferHeight = 1080;
+#if (NV_CHECKED)
+ deviceParams.createDeviceFlags |= D3D11_CREATE_DEVICE_DEBUG;
+#endif
+
+ if(FAILED(device_manager->CreateWindowDeviceAndSwapChain(deviceParams, L"Gameworks Volumetric Lighting Unit Test")))
+ {
+ MessageBox(nullptr, L"Cannot initialize the D3D11 device with the requested parameters", L"Error", MB_OK | MB_ICONERROR);
+ return 1;
+ }
+ // Loop
+ device_manager->MessageLoop();
+ // Shutdown and exit
+ device_manager->Shutdown();
+ delete device_manager;
+
+ return 0;
+}
diff --git a/samples/VolumetricLightingTest/d3d11/d3d11_util.cpp b/samples/VolumetricLightingTest/d3d11/d3d11_util.cpp
new file mode 100644
index 0000000..4226fdb
--- /dev/null
+++ b/samples/VolumetricLightingTest/d3d11/d3d11_util.cpp
@@ -0,0 +1,347 @@
+// This code contains NVIDIA Confidential Information and is disclosed
+// under the Mutual Non-Disclosure Agreement.
+//
+// Notice
+// ALL NVIDIA DESIGN SPECIFICATIONS AND CODE ("MATERIALS") ARE PROVIDED "AS IS" NVIDIA MAKES
+// NO REPRESENTATIONS, WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
+//
+// 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. No third party distribution is allowed unless
+// expressly authorized by NVIDIA. 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 (c) 2003 - 2016 NVIDIA Corporation. All rights reserved.
+//
+// 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.
+//
+
+#include "common.h"
+#include "d3d11_util.h"
+#include <d3d11.h>
+
+/*==============================================================================
+ Overloaded functions to make shader compilation simpler
+==============================================================================*/
+HRESULT CompileShader(ID3D11Device * device, const void * data, UINT length, ID3D11VertexShader ** out_shader)
+ { return device->CreateVertexShader(data, length, nullptr, out_shader); }
+HRESULT CompileShader(ID3D11Device * device, const void * data, UINT length, ID3D11HullShader ** out_shader)
+ { return device->CreateHullShader(data, length, nullptr, out_shader); }
+HRESULT CompileShader(ID3D11Device * device, const void * data, UINT length, ID3D11DomainShader ** out_shader)
+ { return device->CreateDomainShader(data, length, nullptr, out_shader); }
+HRESULT CompileShader(ID3D11Device * device, const void * data, UINT length, ID3D11GeometryShader ** out_shader)
+ { return device->CreateGeometryShader(data, length, nullptr, out_shader); }
+HRESULT CompileShader(ID3D11Device * device, const void * data, UINT length, ID3D11PixelShader ** out_shader)
+ { return device->CreatePixelShader(data, length, nullptr, out_shader); }
+HRESULT CompileShader(ID3D11Device * device, const void * data, UINT length, ID3D11ComputeShader ** out_shader)
+ { return device->CreateComputeShader(data, length, nullptr, out_shader); }
+/*==============================================================================
+ Texture resource management helpers
+==============================================================================*/
+
+//------------------------------------------------------------------------------
+ShaderResource::ShaderResource(ID3D11Resource * resource, ID3D11ShaderResourceView * srv, ID3D11UnorderedAccessView * uav)
+{
+ resource_ = resource;
+ srv_ = srv;
+ uav_ = uav;
+}
+
+ShaderResource::~ShaderResource()
+{
+ SAFE_RELEASE(resource_);
+ SAFE_RELEASE(srv_);
+ SAFE_RELEASE(uav_);
+}
+
+//------------------------------------------------------------------------------
+RenderTarget * RenderTarget::Create(ID3D11Device * device, UINT width, UINT height, UINT samples, DXGI_FORMAT format, const char * debug_name)
+{
+ ID3D11Texture2D * tex = nullptr;
+ ID3D11ShaderResourceView * srv = nullptr;
+ ID3D11RenderTargetView * rtv = nullptr;
+ ID3D11UnorderedAccessView * uav = nullptr;
+
+ CD3D11_TEXTURE2D_DESC texDesc;
+ texDesc.ArraySize = 1;
+ texDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET;
+ if (samples == 1)
+ texDesc.BindFlags |= D3D11_BIND_UNORDERED_ACCESS;
+ texDesc.CPUAccessFlags = 0;
+ texDesc.Format = format;
+ texDesc.Width = width;
+ texDesc.Height = height;
+ texDesc.MipLevels = 1;
+ texDesc.MiscFlags = 0;
+ if (samples > 1)
+ {
+ texDesc.SampleDesc.Count = samples;
+ texDesc.SampleDesc.Quality = 0;//static_cast<UINT>(D3D11_STANDARD_MULTISAMPLE_PATTERN);
+ }
+ else
+ {
+ texDesc.SampleDesc.Count = 1;
+ texDesc.SampleDesc.Quality = 0;
+ }
+ texDesc.Usage = D3D11_USAGE_DEFAULT;
+ device->CreateTexture2D(&texDesc, nullptr, &tex);
+ if (tex == nullptr)
+ {
+ return nullptr;
+ }
+
+ CD3D11_SHADER_RESOURCE_VIEW_DESC srvDesc;
+ srvDesc.Format = texDesc.Format;
+ if (samples > 1)
+ {
+ srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2DMS;
+ }
+ else
+ {
+ srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
+ srvDesc.Texture2D.MostDetailedMip = 0;
+ srvDesc.Texture2D.MipLevels = 1;
+ }
+ device->CreateShaderResourceView(tex, &srvDesc, &srv);
+ if (srv == nullptr)
+ {
+ tex->Release();
+ return nullptr;
+ }
+
+ CD3D11_RENDER_TARGET_VIEW_DESC rtvDesc;
+ rtvDesc.Format = texDesc.Format;
+ if (samples > 1)
+ {
+ rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2DMS;
+ }
+ else
+ {
+ rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D;
+ rtvDesc.Texture2D.MipSlice = 0;
+ }
+ device->CreateRenderTargetView(tex, &rtvDesc, &rtv);
+ if (rtv == nullptr)
+ {
+ tex->Release();
+ srv->Release();
+ return nullptr;
+ }
+
+ if (samples == 1)
+ {
+ CD3D11_UNORDERED_ACCESS_VIEW_DESC uavDesc;
+ uavDesc.Format = texDesc.Format;
+ uavDesc.ViewDimension = D3D11_UAV_DIMENSION_TEXTURE2D;
+ uavDesc.Texture2D.MipSlice = 0;
+ device->CreateUnorderedAccessView(tex, &uavDesc, &uav);
+ if (uav == nullptr)
+ {
+ tex->Release();
+ srv->Release();
+ rtv->Release();
+ return nullptr;
+ }
+ }
+#if (NV_DEBUG || NV_PROFILE)
+ if (debug_name)
+ {
+ tex->SetPrivateData(WKPDID_D3DDebugObjectName, (UINT)strlen(debug_name), debug_name);
+ }
+#else
+ debug_name;
+#endif
+ return new RenderTarget(tex, srv, rtv, uav);
+}
+
+RenderTarget::RenderTarget(ID3D11Resource * resource, ID3D11ShaderResourceView * srv, ID3D11RenderTargetView * rtv, ID3D11UnorderedAccessView * uav)
+ : ShaderResource(resource, srv, uav)
+{
+ rtv_ = rtv;
+}
+
+RenderTarget::~RenderTarget()
+{
+ SAFE_RELEASE(rtv_);
+}
+
+//------------------------------------------------------------------------------
+DepthTarget * DepthTarget::Create(ID3D11Device * device, UINT width, UINT height, UINT samples, DXGI_FORMAT format, uint32_t slices, char * debug_name)
+{
+ ID3D11Texture2D * tex = nullptr;
+ ID3D11ShaderResourceView * srv = nullptr;
+ ID3D11DepthStencilView * dsv = nullptr;
+ ID3D11DepthStencilView * dsv_ro = nullptr;
+
+ DXGI_FORMAT tex_format;
+ DXGI_FORMAT srv_format;
+ DXGI_FORMAT dsv_format;
+ switch (format)
+ {
+ case DXGI_FORMAT_D32_FLOAT:
+ tex_format = DXGI_FORMAT_R32_TYPELESS;
+ srv_format = DXGI_FORMAT_R32_FLOAT;
+ dsv_format = DXGI_FORMAT_D32_FLOAT;
+ break;
+
+ case DXGI_FORMAT_D24_UNORM_S8_UINT:
+ tex_format = DXGI_FORMAT_R24G8_TYPELESS;
+ srv_format = DXGI_FORMAT_R24_UNORM_X8_TYPELESS;
+ dsv_format = DXGI_FORMAT_D24_UNORM_S8_UINT;
+ break;
+
+ case DXGI_FORMAT_D16_UNORM:
+ tex_format = DXGI_FORMAT_R16_TYPELESS;
+ srv_format = DXGI_FORMAT_R16_UNORM;
+ dsv_format = DXGI_FORMAT_D16_UNORM;
+ break;
+
+ default:
+ return nullptr;
+ }
+
+ CD3D11_TEXTURE2D_DESC texDesc;
+ texDesc.ArraySize = slices;
+ texDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_DEPTH_STENCIL;
+ texDesc.CPUAccessFlags = 0;
+ texDesc.Format = tex_format;
+ texDesc.Width = width;
+ texDesc.Height = height;
+ texDesc.MipLevels = 1;
+ texDesc.MiscFlags = 0;
+ if (samples > 1)
+ {
+ texDesc.SampleDesc.Count = samples;
+ texDesc.SampleDesc.Quality = 0;//static_cast<UINT>(D3D11_STANDARD_MULTISAMPLE_PATTERN);
+ }
+ else
+ {
+ texDesc.SampleDesc.Count = 1;
+ texDesc.SampleDesc.Quality = 0;
+ }
+ texDesc.Usage = D3D11_USAGE_DEFAULT;
+ device->CreateTexture2D(&texDesc, nullptr, &tex);
+ if (tex == nullptr)
+ {
+ return nullptr;
+ }
+
+ CD3D11_SHADER_RESOURCE_VIEW_DESC srvDesc;
+ srvDesc.Format = srv_format;
+ if (slices == 1)
+ {
+ if (samples > 1)
+ {
+ srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2DMS;
+ }
+ else
+ {
+ srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
+ srvDesc.Texture2D.MostDetailedMip = 0;
+ srvDesc.Texture2D.MipLevels = 1;
+ }
+ }
+ else
+ {
+ if (samples > 1)
+ {
+ srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2DMSARRAY;
+ srvDesc.Texture2DMSArray.FirstArraySlice = 0;
+ srvDesc.Texture2DMSArray.ArraySize = slices;
+ }
+ else
+ {
+ srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2DARRAY;
+ srvDesc.Texture2DArray.MostDetailedMip = 0;
+ srvDesc.Texture2DArray.MipLevels = 1;
+ srvDesc.Texture2DArray.FirstArraySlice = 0;
+ srvDesc.Texture2DArray.ArraySize = slices;
+ }
+ }
+ device->CreateShaderResourceView(tex, &srvDesc, &srv);
+
+ if (srv == nullptr)
+ {
+ tex->Release();
+ return nullptr;
+ }
+
+ CD3D11_DEPTH_STENCIL_VIEW_DESC dsvDesc;
+ dsvDesc.Flags = 0;
+ dsvDesc.Format = dsv_format;
+ if (slices == 1)
+ {
+ if (samples > 1)
+ {
+ dsvDesc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2DMS;
+ }
+ else
+ {
+ dsvDesc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2D;
+ dsvDesc.Texture2D.MipSlice = 0;
+ }
+ }
+ else
+ {
+ if (samples > 1)
+ {
+ dsvDesc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2DMSARRAY;
+ dsvDesc.Texture2DMSArray.FirstArraySlice = 0;
+ dsvDesc.Texture2DMSArray.ArraySize = slices;
+ }
+ else
+ {
+ dsvDesc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2DARRAY;
+ dsvDesc.Texture2DArray.MipSlice = 0;
+ dsvDesc.Texture2DArray.FirstArraySlice = 0;
+ dsvDesc.Texture2DArray.ArraySize = slices;
+ }
+ }
+
+ device->CreateDepthStencilView(tex, &dsvDesc, &dsv);
+ dsvDesc.Flags |= D3D11_DSV_READ_ONLY_DEPTH;
+ if (dsv_format == DXGI_FORMAT_D24_UNORM_S8_UINT)
+ dsvDesc.Flags |= D3D11_DSV_READ_ONLY_STENCIL;
+ device->CreateDepthStencilView(tex, &dsvDesc, &dsv_ro);
+ if (dsv == nullptr || dsv_ro == nullptr)
+ {
+ tex->Release();
+ srv->Release();
+ return nullptr;
+ }
+
+#if (NV_DEBUG || NV_PROFILE)
+ if (debug_name)
+ {
+ tex->SetPrivateData(WKPDID_D3DDebugObjectName, (UINT)strlen(debug_name), debug_name);
+ }
+#else
+ debug_name;
+#endif
+
+ return new DepthTarget(tex, srv, dsv, dsv_ro, nullptr);
+}
+
+DepthTarget::DepthTarget(ID3D11Resource * resource, ID3D11ShaderResourceView * srv, ID3D11DepthStencilView * dsv, ID3D11DepthStencilView * readonly_dsv, ID3D11UnorderedAccessView * uav)
+ : ShaderResource(resource, srv, uav)
+{
+ dsv_ = dsv;
+ readonly_dsv_ = readonly_dsv;
+}
+
+DepthTarget::~DepthTarget()
+{
+ SAFE_RELEASE(dsv_);
+ SAFE_RELEASE(readonly_dsv_);
+}
+
diff --git a/samples/VolumetricLightingTest/d3d11/d3d11_util.h b/samples/VolumetricLightingTest/d3d11/d3d11_util.h
new file mode 100644
index 0000000..e9322cf
--- /dev/null
+++ b/samples/VolumetricLightingTest/d3d11/d3d11_util.h
@@ -0,0 +1,234 @@
+// This code contains NVIDIA Confidential Information and is disclosed
+// under the Mutual Non-Disclosure Agreement.
+//
+// Notice
+// ALL NVIDIA DESIGN SPECIFICATIONS AND CODE ("MATERIALS") ARE PROVIDED "AS IS" NVIDIA MAKES
+// NO REPRESENTATIONS, WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
+//
+// 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. No third party distribution is allowed unless
+// expressly authorized by NVIDIA. 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 (c) 2003 - 2016 NVIDIA Corporation. All rights reserved.
+//
+// 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.
+//
+
+#ifndef D3D11_UTIL_H
+#define D3D11_UTIL_H
+////////////////////////////////////////////////////////////////////////////////
+#include "common.h"
+
+#include <d3d11.h>
+#include <d3d11_1.h>
+
+#pragma warning( disable: 4127 )
+
+////////////////////////////////////////////////////////////////////////////////
+/*==============================================================================
+ Overloaded functions to make shader compilation simpler
+==============================================================================*/
+HRESULT CompileShader(ID3D11Device * device, const void * data, UINT length, ID3D11VertexShader ** out_shader);
+HRESULT CompileShader(ID3D11Device * device, const void * data, UINT length, ID3D11HullShader ** out_shader);
+HRESULT CompileShader(ID3D11Device * device, const void * data, UINT length, ID3D11DomainShader ** out_shader);
+HRESULT CompileShader(ID3D11Device * device, const void * data, UINT length, ID3D11GeometryShader ** out_shader);
+HRESULT CompileShader(ID3D11Device * device, const void * data, UINT length, ID3D11PixelShader ** out_shader);
+HRESULT CompileShader(ID3D11Device * device, const void * data, UINT length, ID3D11ComputeShader ** out_shader);
+
+
+template <class T>
+NV_FORCE_INLINE HRESULT LoadShaders(ID3D11Device * device, const void ** shader_codes, const uint32_t * shader_lengths, UINT count, T ** &out_shaders)
+{
+ HRESULT hr = S_OK;
+ out_shaders = new T*[count];
+ for (UINT i = 0; i < count; ++i)
+ {
+ const void * code = shader_codes[i];
+ uint32_t length = shader_lengths[i];
+ if (code == nullptr)
+ {
+ out_shaders[i] = nullptr;
+ continue;
+ }
+ hr = CompileShader(device, code, length, &out_shaders[i]);
+ ASSERT_LOG(hr == S_OK, "Failure loading shader");
+ if (FAILED(hr))
+ break;
+ }
+ return hr;
+}
+
+/*==============================================================================
+ Perf Events
+==============================================================================*/
+
+class ScopedPerfEvent
+{
+public:
+ ScopedPerfEvent(ID3D11DeviceContext * ctx, const wchar_t * msg)
+ {
+ ctx->QueryInterface(IID_ID3DUserDefinedAnnotation, reinterpret_cast<void **>(&pPerf));
+ if (pPerf)
+ {
+ pPerf->BeginEvent(msg);
+ }
+ }
+
+ ~ScopedPerfEvent()
+ {
+ if (pPerf)
+ {
+ pPerf->EndEvent();
+ SAFE_RELEASE(pPerf);
+ }
+ };
+
+private:
+ ScopedPerfEvent() : pPerf(nullptr) {};
+ ID3DUserDefinedAnnotation * pPerf;
+};
+
+#if (NV_PROFILE)
+# define NV_PERFEVENT(c, t) ScopedPerfEvent perfevent_##__COUNTER__##(c, L##t)
+# define NV_PERFEVENT_BEGIN(c, t) { \
+ ID3DUserDefinedAnnotation * pPerf_##__COUNTER__ ; \
+ c->QueryInterface(IID_ID3DUserDefinedAnnotation, reinterpret_cast<void **>(&pPerf_##__COUNTER__##)); \
+ if (pPerf_##__COUNTER__##) { pPerf_##__COUNTER__##->BeginEvent(L##t); pPerf_##__COUNTER__##->Release(); } }
+# define NV_PERFEVENT_END(c) { \
+ ID3DUserDefinedAnnotation * pPerf_##__COUNTER__ ; \
+ c->QueryInterface(IID_ID3DUserDefinedAnnotation, reinterpret_cast<void **>(&pPerf_##__COUNTER__##)); \
+ if (pPerf_##__COUNTER__##) { pPerf_##__COUNTER__##->EndEvent(); pPerf_##__COUNTER__##->Release(); } }
+#else
+# define NV_PERFEVENT(c, t)
+# define NV_PERFEVENT_BEGIN(c, t)
+# define NV_PERFEVENT_END(c)
+#endif
+
+/*==============================================================================
+ Constant buffer management
+==============================================================================*/
+
+template <class T>
+class ConstantBuffer
+{
+public:
+ static ConstantBuffer<T> * Create(ID3D11Device * device)
+ {
+ HRESULT hr;
+ ID3D11Buffer * cb = nullptr;
+
+ static_assert((sizeof(T) % 16) == 0, "Constant buffer size must be 16-byte aligned");
+
+ CD3D11_BUFFER_DESC cbDesc;
+ cbDesc.ByteWidth = sizeof(T);
+ cbDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
+ cbDesc.Usage = D3D11_USAGE_DYNAMIC;
+ cbDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
+ cbDesc.MiscFlags = 0;
+ cbDesc.StructureByteStride = 1;
+ hr = device->CreateBuffer(&cbDesc, nullptr, &cb);
+ if (cb == nullptr)
+ return nullptr;
+ return new ConstantBuffer<T>(cb);
+ }
+
+ ConstantBuffer(ID3D11Buffer * b)
+ {
+ buffer_ = b;
+ }
+
+ ~ConstantBuffer()
+ {
+ SAFE_RELEASE(buffer_);
+ }
+
+ T * Map(ID3D11DeviceContext * ctx)
+ {
+ HRESULT hr;
+ D3D11_MAPPED_SUBRESOURCE data;
+ hr = ctx->Map(buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &data);
+ return static_cast<T*>(data.pData);
+ }
+
+ void Unmap(ID3D11DeviceContext * ctx)
+ {
+ ctx->Unmap(buffer_, 0);
+ }
+
+ ID3D11Buffer * getCB() { return buffer_; }
+
+private:
+ ConstantBuffer() {};
+
+ ID3D11Buffer *buffer_;
+};
+
+/*==============================================================================
+ Texture resource management helpers
+==============================================================================*/
+
+//------------------------------------------------------------------------------
+class ShaderResource
+{
+public:
+ ShaderResource(ID3D11Resource * resource, ID3D11ShaderResourceView * srv, ID3D11UnorderedAccessView * uav);
+ ~ShaderResource();
+
+ ID3D11Resource * getResource() { return resource_; }
+ ID3D11ShaderResourceView * getSRV() { return srv_; }
+ ID3D11UnorderedAccessView * getUAV() { return uav_; }
+
+protected:
+ ShaderResource() {};
+
+ ID3D11Resource * resource_;
+ ID3D11ShaderResourceView * srv_;
+ ID3D11UnorderedAccessView * uav_;
+};
+
+//------------------------------------------------------------------------------
+class RenderTarget : public ShaderResource
+{
+public:
+ static RenderTarget * Create(ID3D11Device * device, UINT width, UINT height, UINT samples, DXGI_FORMAT format, const char * debug_name=nullptr);
+ RenderTarget(ID3D11Resource * resource, ID3D11ShaderResourceView * srv, ID3D11RenderTargetView * rtv, ID3D11UnorderedAccessView * uav);
+ ~RenderTarget();
+
+ ID3D11RenderTargetView * getRTV() { return rtv_; }
+
+protected:
+ RenderTarget() {};
+ ID3D11RenderTargetView * rtv_;
+};
+
+//------------------------------------------------------------------------------
+class DepthTarget : public ShaderResource
+{
+public:
+ static DepthTarget * Create(ID3D11Device * device, UINT width, UINT height, UINT samples, DXGI_FORMAT format, uint32_t slices=1, char * debug_name=nullptr);
+ DepthTarget(ID3D11Resource * resource, ID3D11ShaderResourceView * srv, ID3D11DepthStencilView * dsv, ID3D11DepthStencilView * readonly_dsv, ID3D11UnorderedAccessView * uav);
+ ~DepthTarget();
+
+ ID3D11DepthStencilView * getDSV() { return dsv_; }
+ ID3D11DepthStencilView * getReadOnlyDSV() { return readonly_dsv_; }
+
+protected:
+ DepthTarget() {};
+ ID3D11DepthStencilView * dsv_;
+ ID3D11DepthStencilView * readonly_dsv_;
+};
+
+////////////////////////////////////////////////////////////////////////////////
+#endif // D3D11_UTIL_H \ No newline at end of file
diff --git a/samples/VolumetricLightingTest/main.cpp b/samples/VolumetricLightingTest/main.cpp
new file mode 100644
index 0000000..94d299f
--- /dev/null
+++ b/samples/VolumetricLightingTest/main.cpp
@@ -0,0 +1,68 @@
+// This code contains NVIDIA Confidential Information and is disclosed
+// under the Mutual Non-Disclosure Agreement.
+//
+// Notice
+// ALL NVIDIA DESIGN SPECIFICATIONS AND CODE ("MATERIALS") ARE PROVIDED "AS IS" NVIDIA MAKES
+// NO REPRESENTATIONS, WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
+//
+// 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. No third party distribution is allowed unless
+// expressly authorized by NVIDIA. 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 (c) 2003 - 2016 NVIDIA Corporation. All rights reserved.
+//
+// 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.
+//
+
+#include "common.h"
+#include "scene.h"
+
+#include <Nv/VolumetricLighting/NvVolumetricLighting.h>
+
+#if (NV_WIN32 || NV_WIN64)
+#include <windows.h>
+
+int main_D3D11(Scene * pScene);
+#endif
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// Common entrypoint
+
+#if (NV_WIN32 || NV_WIN64)
+int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow)
+{
+ (void)hInstance;
+ (void)hPrevInstance;
+ (void)lpCmdLine;
+ (void)nCmdShow;
+
+ SetProcessDPIAware();
+#else
+int main(int argc, char ** argv)
+{
+ (void)argc;
+ (void)argv;
+#endif
+
+ // Common setup
+ Scene scene;
+
+ // Call into platform-specific implementation
+#if (NV_WIN32 || NV_WIN64)
+ return main_D3D11(&scene);
+#else
+ return -1;
+#endif
+};
diff --git a/samples/VolumetricLightingTest/scene.cpp b/samples/VolumetricLightingTest/scene.cpp
new file mode 100644
index 0000000..574baa2
--- /dev/null
+++ b/samples/VolumetricLightingTest/scene.cpp
@@ -0,0 +1,609 @@
+// This code contains NVIDIA Confidential Information and is disclosed
+// under the Mutual Non-Disclosure Agreement.
+//
+// Notice
+// ALL NVIDIA DESIGN SPECIFICATIONS AND CODE ("MATERIALS") ARE PROVIDED "AS IS" NVIDIA MAKES
+// NO REPRESENTATIONS, WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
+//
+// 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. No third party distribution is allowed unless
+// expressly authorized by NVIDIA. 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 (c) 2003 - 2016 NVIDIA Corporation. All rights reserved.
+//
+// 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.
+//
+
+#include "common.h"
+#include "scene.h"
+
+#include <Nv/VolumetricLighting/NvVolumetricLighting.h>
+
+////////////////////////////////////////////////////////////////////////////////
+const uint32_t Scene::SHADOWMAP_RESOLUTION = 1024;
+const float Scene::LIGHT_RANGE = 50.0f;
+const float Scene::SPOTLIGHT_FALLOFF_ANGLE = Nv::NvPi / 4.0f;
+const float Scene::SPOTLIGHT_FALLOFF_POWER = 1.0f;
+
+Scene::Scene()
+{
+ gwvlctx_ = nullptr;
+
+ isCtxValid_ = false;
+ debugMode_ = Nv::Vl::DebugFlags::NONE;
+ isPaused_ = false;
+
+ viewpoint_ = 0;
+ lightPower_ = 0;
+ mediumType_ = 0;
+ lightMode_ = eLightMode::SPOTLIGHT;
+
+ sceneTransform_ = Nv::NvMat44(Nv::NvIdentity);
+ lightTransform_ = Nv::NvMat44(Nv::NvIdentity);
+
+ //--------------------------------------------------------------------------
+ // Default context settings
+ contextDesc_.framebuffer.uWidth = 0;
+ contextDesc_.framebuffer.uHeight = 0;
+ contextDesc_.framebuffer.uSamples = 0;
+ contextDesc_.eDownsampleMode = Nv::Vl::DownsampleMode::FULL;
+ contextDesc_.eInternalSampleMode = Nv::Vl::MultisampleMode::SINGLE;
+ contextDesc_.eFilterMode = Nv::Vl::FilterMode::NONE;
+
+ //--------------------------------------------------------------------------
+ // Default post-process settings
+ postprocessDesc_.bDoFog = true;
+ postprocessDesc_.bIgnoreSkyFog = false;
+ postprocessDesc_.eUpsampleQuality = Nv::Vl::UpsampleQuality::BILINEAR;
+ postprocessDesc_.fBlendfactor = 1.0f;
+ postprocessDesc_.fTemporalFactor = 0.95f;
+ postprocessDesc_.fFilterThreshold = 0.20f;
+}
+
+void Scene::Release()
+{
+ if (gwvlctx_) Nv::Vl::ReleaseContext(gwvlctx_);
+ isCtxValid_ = false;
+}
+
+bool Scene::isCtxValid()
+{
+ return isCtxValid_;
+}
+
+void Scene::invalidateCtx()
+{
+ isCtxValid_ = false;
+}
+
+void Scene::createCtx(const Nv::Vl::PlatformDesc * platform)
+{
+ // Assumes platformDesc and contextDesc have been updated
+ if (gwvlctx_) Nv::Vl::ReleaseContext(gwvlctx_);
+ Nv::Vl::Status gwvl_status = Nv::Vl::CreateContext(gwvlctx_, platform, &contextDesc_);
+ ASSERT_LOG(gwvl_status == Nv::Vl::Status::OK, "GWVL Error: %d", gwvl_status);
+ gwvl_status;
+ isCtxValid_ = true;
+}
+
+void Scene::updateFramebuffer(uint32_t w, uint32_t h, uint32_t s)
+{
+ contextDesc_.framebuffer.uWidth = w;
+ contextDesc_.framebuffer.uHeight = h;
+ contextDesc_.framebuffer.uSamples = s;
+ invalidateCtx();
+}
+
+void Scene::setDebugMode(Nv::Vl::DebugFlags d)
+{
+ debugMode_ = d;
+}
+
+void Scene::togglePause()
+{
+ isPaused_ = !isPaused_;
+}
+
+void Scene::toggleDownsampleMode()
+{
+ switch (contextDesc_.eDownsampleMode)
+ {
+ case Nv::Vl::DownsampleMode::FULL:
+ contextDesc_.eDownsampleMode = Nv::Vl::DownsampleMode::HALF;
+ break;
+
+ case Nv::Vl::DownsampleMode::HALF:
+ contextDesc_.eDownsampleMode = Nv::Vl::DownsampleMode::QUARTER;
+ break;
+
+ case Nv::Vl::DownsampleMode::QUARTER:
+ contextDesc_.eDownsampleMode = Nv::Vl::DownsampleMode::FULL;
+ break;
+ }
+ invalidateCtx();
+}
+
+void Scene::toggleMsaaMode()
+{
+ if (contextDesc_.eDownsampleMode == Nv::Vl::DownsampleMode::FULL)
+ return;
+
+ switch (contextDesc_.eInternalSampleMode)
+ {
+ case Nv::Vl::MultisampleMode::SINGLE:
+ contextDesc_.eInternalSampleMode = Nv::Vl::MultisampleMode::MSAA2;
+ break;
+
+ case Nv::Vl::MultisampleMode::MSAA2:
+ contextDesc_.eInternalSampleMode = Nv::Vl::MultisampleMode::MSAA4;
+ break;
+
+ case Nv::Vl::MultisampleMode::MSAA4:
+ contextDesc_.eInternalSampleMode = Nv::Vl::MultisampleMode::SINGLE;
+ break;
+ }
+ invalidateCtx();
+}
+
+void Scene::toggleFiltering()
+{
+ if (contextDesc_.eDownsampleMode == Nv::Vl::DownsampleMode::FULL)
+ return;
+
+ contextDesc_.eFilterMode = (contextDesc_.eFilterMode == Nv::Vl::FilterMode::TEMPORAL) ? Nv::Vl::FilterMode::NONE : Nv::Vl::FilterMode::TEMPORAL;
+ invalidateCtx();
+}
+
+void Scene::toggleUpsampleMode()
+{
+ if (contextDesc_.eDownsampleMode == Nv::Vl::DownsampleMode::FULL)
+ return;
+
+ switch (postprocessDesc_.eUpsampleQuality)
+ {
+ case Nv::Vl::UpsampleQuality::POINT:
+ postprocessDesc_.eUpsampleQuality = Nv::Vl::UpsampleQuality::BILINEAR;
+ break;
+
+ case Nv::Vl::UpsampleQuality::BILINEAR:
+ if (contextDesc_.eFilterMode == Nv::Vl::FilterMode::TEMPORAL)
+ postprocessDesc_.eUpsampleQuality = Nv::Vl::UpsampleQuality::BILATERAL;
+ else
+ postprocessDesc_.eUpsampleQuality = Nv::Vl::UpsampleQuality::POINT;
+ break;
+
+ case Nv::Vl::UpsampleQuality::BILATERAL:
+ postprocessDesc_.eUpsampleQuality = Nv::Vl::UpsampleQuality::POINT;
+ break;
+ }
+}
+
+void Scene::toggleFog()
+{
+ postprocessDesc_.bDoFog = !postprocessDesc_.bDoFog;
+}
+
+void Scene::toggleViewpoint()
+{
+ viewpoint_ = (viewpoint_+1)%4;
+}
+
+void Scene::toggleIntensity()
+{
+ lightPower_ = (lightPower_+1)%6;
+}
+
+void Scene::toggleMediumType()
+{
+ mediumType_ = (mediumType_+1)%4;
+}
+
+
+void Scene::toggleLightMode()
+{
+ switch (lightMode_)
+ {
+ default:
+ case Scene::eLightMode::DIRECTIONAL:
+ lightMode_ = Scene::eLightMode::SPOTLIGHT;
+ break;
+
+ case Scene::eLightMode::SPOTLIGHT:
+ lightMode_ = Scene::eLightMode::OMNI;
+ break;
+
+ case Scene::eLightMode::OMNI:
+ lightMode_ = Scene::eLightMode::DIRECTIONAL;
+ break;
+ }
+}
+
+Scene::eLightMode Scene::getLightMode()
+{
+ return lightMode_;
+}
+
+void Scene::getLightViewpoint(Nv::NvVec3 & vPos, Nv::NvMat44 & mViewProj)
+{
+ Nv::NvVec3 vOrigin = Nv::NvVec3(0, 0, 0);
+ Nv::NvVec3 vUp = Nv::NvVec3(0, 1, 0);
+ switch (getLightMode())
+ {
+ case Scene::eLightMode::OMNI:
+ {
+ vPos = lightTransform_.transform(Nv::NvVec3(15, 10, 0));
+ Nv::NvMat44 mLightView = Nv::NvMat44(Nv::NvVec3(1,0,0), Nv::NvVec3(0,1,0), Nv::NvVec3(0,0,1), -vPos);
+ Nv::NvMat44 mLightProj = Nv::NvMat44(Nv::NvIdentity);
+ mViewProj = mLightProj*mLightView;
+ }
+ break;
+
+ case Scene::eLightMode::SPOTLIGHT:
+ {
+ vPos = Nv::NvVec3(10, 15, 5);
+ Nv::NvMat44 mLightView = LookAtTransform(vPos, vOrigin, vUp);
+ Nv::NvMat44 mLightProj = PerspectiveProjLH(
+ SPOTLIGHT_FALLOFF_ANGLE,
+ 1.0f,
+ 0.50f, LIGHT_RANGE);
+ mViewProj = mLightProj*mLightView;
+ }
+ break;
+
+ default:
+ case eLightMode::DIRECTIONAL:
+ {
+ vPos = Nv::NvVec3(10, 15, 5);
+ Nv::NvMat44 mLightView = LookAtTransform(vPos, vOrigin, vUp);
+ Nv::NvMat44 mLightProj = OrthographicProjLH(25.0f, 25.0f, 0.50f, LIGHT_RANGE);
+
+ mViewProj = mLightProj*mLightView;
+ }
+ break;
+ }
+}
+
+Nv::NvVec3 Scene::getLightIntensity()
+{
+ const Nv::NvVec3 LIGHT_POWER[] = {
+ 1.00f*Nv::NvVec3(1.00f, 0.95f, 0.90f),
+ 0.50f*Nv::NvVec3(1.00f, 0.95f, 0.90f),
+ 1.50f*Nv::NvVec3(1.00f, 0.95f, 0.90f),
+ 1.00f*Nv::NvVec3(1.00f, 0.75f, 0.50f),
+ 1.00f*Nv::NvVec3(0.75f, 1.00f, 0.75f),
+ 1.00f*Nv::NvVec3(0.50f, 0.75f, 1.00f)
+ };
+
+ switch (getLightMode())
+ {
+ case Scene::eLightMode::OMNI:
+ return 25000.0f*LIGHT_POWER[lightPower_];
+
+ case Scene::eLightMode::SPOTLIGHT:
+ return 50000.0f*LIGHT_POWER[lightPower_];
+
+ default:
+ case eLightMode::DIRECTIONAL:
+ return 250.0f*LIGHT_POWER[lightPower_];
+ }
+}
+
+const Nv::Vl::ViewerDesc * Scene::getViewerDesc()
+{
+ static Nv::Vl::ViewerDesc viewerDesc;
+ Nv::NvVec3 vOrigin = Nv::NvVec3(0, 0, 0);
+ Nv::NvVec3 vUp = Nv::NvVec3(0, 1, 0);
+ Nv::NvVec3 VIEWPOINTS[] = {
+ Nv::NvVec3(0, 0, -17.5f),
+ Nv::NvVec3(0, 17.5f, 0),
+ Nv::NvVec3(0, -17.5f, 0),
+ Nv::NvVec3(17.5f, 0, 0),
+ };
+ Nv::NvVec3 VIEWPOINT_UP[] = {
+ Nv::NvVec3(0, 1, 0),
+ Nv::NvVec3(0, 0, -1),
+ Nv::NvVec3(0, 0, -1),
+ Nv::NvVec3(0, 1, 0),
+ };
+ Nv::NvVec3 vEyePos = VIEWPOINTS[viewpoint_];
+ Nv::NvMat44 mEyeView = LookAtTransform(vEyePos, vOrigin, VIEWPOINT_UP[viewpoint_]);
+ Nv::NvMat44 mEyeProj = PerspectiveProjLH(
+ Nv::NvPiDivFour,
+ static_cast<float>(contextDesc_.framebuffer.uWidth)/static_cast<float>(contextDesc_.framebuffer.uHeight),
+ 0.50f, 50.0f );
+ Nv::NvMat44 mEyeViewProj = mEyeProj*mEyeView;
+
+ viewerDesc.mProj = NVtoNVC(mEyeProj);
+ viewerDesc.mViewProj = NVtoNVC(mEyeViewProj);
+ viewerDesc.vEyePosition = NVtoNVC(vEyePos);
+ viewerDesc.uViewportWidth = contextDesc_.framebuffer.uWidth;
+ viewerDesc.uViewportHeight = contextDesc_.framebuffer.uHeight;
+
+ return &viewerDesc;
+}
+
+const Nv::Vl::LightDesc * Scene::getLightDesc()
+{
+ static Nv::Vl::LightDesc lightDesc;
+ const float LIGHT_RANGE = 50.0f;
+
+ Nv::NvVec3 vLightPos;
+ Nv::NvMat44 mLightViewProj;
+ getLightViewpoint(vLightPos, mLightViewProj);
+ Nv::NvMat44 mLightViewProj_Inv = Inverse(mLightViewProj);
+
+ lightDesc.vIntensity = NVtoNVC(getLightIntensity());
+ lightDesc.mLightToWorld = NVtoNVC(mLightViewProj_Inv);
+
+ switch (getLightMode())
+ {
+ case Scene::eLightMode::OMNI:
+ {
+ lightDesc.eType = Nv::Vl::LightType::OMNI;
+ lightDesc.Omni.fZNear = 0.5f;
+ lightDesc.Omni.fZFar = LIGHT_RANGE;
+ lightDesc.Omni.vPosition = NVtoNVC(vLightPos);
+ lightDesc.Omni.eAttenuationMode = Nv::Vl::AttenuationMode::INV_POLYNOMIAL;
+ const float LIGHT_SOURCE_RADIUS = 0.5f; // virtual radius of a spheroid light source
+ lightDesc.Omni.fAttenuationFactors[0] = 1.0f;
+ lightDesc.Omni.fAttenuationFactors[1] = 2.0f / LIGHT_SOURCE_RADIUS;
+ lightDesc.Omni.fAttenuationFactors[2] = 1.0f / (LIGHT_SOURCE_RADIUS*LIGHT_SOURCE_RADIUS);
+ lightDesc.Omni.fAttenuationFactors[3] = 0.0f;
+ }
+ break;
+
+ case Scene::eLightMode::SPOTLIGHT:
+ {
+ Nv::NvVec3 vLightDirection = -vLightPos;
+ vLightDirection.normalize();
+ lightDesc.eType = Nv::Vl::LightType::SPOTLIGHT;
+ lightDesc.Spotlight.fZNear = 0.5f;
+ lightDesc.Spotlight.fZFar = LIGHT_RANGE;
+ lightDesc.Spotlight.eFalloffMode = Nv::Vl::SpotlightFalloffMode::FIXED;
+ lightDesc.Spotlight.fFalloff_Power = SPOTLIGHT_FALLOFF_POWER;
+ lightDesc.Spotlight.fFalloff_CosTheta = Nv::intrinsics::cos(SPOTLIGHT_FALLOFF_ANGLE);
+ lightDesc.Spotlight.vDirection = NVtoNVC(vLightDirection);
+ lightDesc.Spotlight.vPosition = NVtoNVC(vLightPos);
+ lightDesc.Spotlight.eAttenuationMode = Nv::Vl::AttenuationMode::INV_POLYNOMIAL;
+ const float LIGHT_SOURCE_RADIUS = 1.0f; // virtual radius of a spheroid light source
+ lightDesc.Spotlight.fAttenuationFactors[0] = 1.0f;
+ lightDesc.Spotlight.fAttenuationFactors[1] = 2.0f / LIGHT_SOURCE_RADIUS;
+ lightDesc.Spotlight.fAttenuationFactors[2] = 1.0f / (LIGHT_SOURCE_RADIUS*LIGHT_SOURCE_RADIUS);
+ lightDesc.Spotlight.fAttenuationFactors[3] = 0.0f;
+ }
+ break;
+
+ default:
+ case eLightMode::DIRECTIONAL:
+ {
+ Nv::NvVec3 vLightDirection = -vLightPos;
+ vLightDirection.normalize();
+ lightDesc.eType = Nv::Vl::LightType::DIRECTIONAL;
+ lightDesc.Directional.vDirection = NVtoNVC(vLightDirection);
+ }
+ }
+ return &lightDesc;
+}
+
+const Nv::Vl::MediumDesc * Scene::getMediumDesc()
+{
+ static Nv::Vl::MediumDesc mediumDesc;
+
+ const float SCATTER_PARAM_SCALE = 0.0001f;
+ mediumDesc.uNumPhaseTerms = 0;
+
+ uint32_t t = 0;
+
+ mediumDesc.PhaseTerms[t].ePhaseFunc = Nv::Vl::PhaseFunctionType::RAYLEIGH;
+ mediumDesc.PhaseTerms[t].vDensity = NVtoNVC(10.00f * SCATTER_PARAM_SCALE * Nv::NvVec3(0.596f, 1.324f, 3.310f));
+ t++;
+
+ switch (mediumType_)
+ {
+ default:
+ case 0:
+ mediumDesc.PhaseTerms[t].ePhaseFunc = Nv::Vl::PhaseFunctionType::HENYEYGREENSTEIN;
+ mediumDesc.PhaseTerms[t].vDensity = NVtoNVC(10.00f * SCATTER_PARAM_SCALE * Nv::NvVec3(1.00f, 1.00f, 1.00f));
+ mediumDesc.PhaseTerms[t].fEccentricity = 0.85f;
+ t++;
+ mediumDesc.vAbsorption = NVtoNVC(5.0f * SCATTER_PARAM_SCALE * Nv::NvVec3(1, 1, 1));
+ break;
+
+ case 1:
+ mediumDesc.PhaseTerms[t].ePhaseFunc = Nv::Vl::PhaseFunctionType::HENYEYGREENSTEIN;
+ mediumDesc.PhaseTerms[t].vDensity = NVtoNVC(15.00f * SCATTER_PARAM_SCALE * Nv::NvVec3(1.00f, 1.00f, 1.00f));
+ mediumDesc.PhaseTerms[t].fEccentricity = 0.60f;
+ t++;
+ mediumDesc.vAbsorption = NVtoNVC(25.0f * SCATTER_PARAM_SCALE * Nv::NvVec3(1, 1, 1));
+ break;
+
+ case 2:
+ mediumDesc.PhaseTerms[t].ePhaseFunc = Nv::Vl::PhaseFunctionType::MIE_HAZY;
+ mediumDesc.PhaseTerms[t].vDensity = NVtoNVC(20.00f * SCATTER_PARAM_SCALE * Nv::NvVec3(1.00f, 1.00f, 1.00f));
+ t++;
+ mediumDesc.vAbsorption = NVtoNVC(25.0f * SCATTER_PARAM_SCALE * Nv::NvVec3(1, 1, 1));
+ break;
+
+ case 3:
+ mediumDesc.PhaseTerms[t].ePhaseFunc = Nv::Vl::PhaseFunctionType::MIE_MURKY;
+ mediumDesc.PhaseTerms[t].vDensity = NVtoNVC(30.00f * SCATTER_PARAM_SCALE * Nv::NvVec3(1.00f, 1.00f, 1.00f));
+ t++;
+ mediumDesc.vAbsorption = NVtoNVC(50.0f * SCATTER_PARAM_SCALE * Nv::NvVec3(1, 1, 1));
+ break;
+ }
+
+ mediumDesc.uNumPhaseTerms = t;
+
+ return &mediumDesc;
+}
+
+const Nv::Vl::PostprocessDesc * Scene::getPostprocessDesc()
+{
+ postprocessDesc_.vFogLight = NVtoNVC(getLightIntensity());
+ postprocessDesc_.fMultiscatter = 0.000002f;
+ return &postprocessDesc_;
+}
+
+void Scene::beginAccumulation(Nv::Vl::PlatformRenderCtx ctx, Nv::Vl::PlatformShaderResource sceneDepth)
+{
+ Nv::Vl::Status gwvl_status;
+ gwvl_status = Nv::Vl::BeginAccumulation(gwvlctx_, ctx, sceneDepth, getViewerDesc(), getMediumDesc(), debugMode_);
+ ASSERT_LOG(gwvl_status == Nv::Vl::Status::OK, "GWVL Error: %d", gwvl_status);
+}
+
+void Scene::renderVolume(Nv::Vl::PlatformRenderCtx ctx, Nv::Vl::PlatformShaderResource shadowmap)
+{
+ Nv::NvVec3 vLightPos;
+ Nv::NvMat44 mLightViewProj;
+ getLightViewpoint(vLightPos, mLightViewProj);
+
+ Nv::Vl::ShadowMapDesc shadowmapDesc;
+ {
+ shadowmapDesc.eType = (getLightMode() == Scene::eLightMode::OMNI) ? Nv::Vl::ShadowMapLayout::PARABOLOID : Nv::Vl::ShadowMapLayout::SIMPLE;
+ shadowmapDesc.uWidth = SHADOWMAP_RESOLUTION;
+ shadowmapDesc.uHeight = SHADOWMAP_RESOLUTION;
+ shadowmapDesc.uElementCount = 1;
+ shadowmapDesc.Elements[0].uOffsetX = 0;
+ shadowmapDesc.Elements[0].uOffsetY = 0;
+ shadowmapDesc.Elements[0].uWidth = shadowmapDesc.uWidth;
+ shadowmapDesc.Elements[0].uHeight = shadowmapDesc.uHeight;
+ shadowmapDesc.Elements[0].mViewProj = NVtoNVC(mLightViewProj);
+ shadowmapDesc.Elements[0].mArrayIndex = 0;
+ if (getLightMode() == Scene::eLightMode::OMNI)
+ {
+ shadowmapDesc.uElementCount = 2;
+ shadowmapDesc.Elements[1].uOffsetX = 0;
+ shadowmapDesc.Elements[1].uOffsetY = 0;
+ shadowmapDesc.Elements[1].uWidth = shadowmapDesc.uWidth;
+ shadowmapDesc.Elements[1].uHeight = shadowmapDesc.uHeight;
+ shadowmapDesc.Elements[1].mViewProj = NVtoNVC(mLightViewProj);
+ shadowmapDesc.Elements[1].mArrayIndex = 1;
+ }
+ }
+
+ Nv::Vl::VolumeDesc volumeDesc;
+ {
+ volumeDesc.fTargetRayResolution = 12.0f;
+ volumeDesc.uMaxMeshResolution = SHADOWMAP_RESOLUTION;
+ volumeDesc.fDepthBias = 0.0f;
+ volumeDesc.eTessQuality = Nv::Vl::TessellationQuality::HIGH;
+ }
+
+ Nv::Vl::Status gwvl_status;
+ gwvl_status = Nv::Vl::RenderVolume(gwvlctx_, ctx, shadowmap, &shadowmapDesc, getLightDesc(), &volumeDesc);
+ ASSERT_LOG(gwvl_status == Nv::Vl::Status::OK, "GWVL Error: %d", gwvl_status);
+}
+
+void Scene::endAccumulation(Nv::Vl::PlatformRenderCtx ctx)
+{
+ Nv::Vl::Status gwvl_status;
+ gwvl_status = Nv::Vl::EndAccumulation(gwvlctx_, ctx);
+ ASSERT_LOG(gwvl_status == Nv::Vl::Status::OK, "GWVL Error: %d", gwvl_status);
+}
+
+void Scene::applyLighting(Nv::Vl::PlatformRenderCtx ctx, Nv::Vl::PlatformRenderTarget sceneRT, Nv::Vl::PlatformShaderResource sceneDepth)
+{
+ Nv::Vl::Status gwvl_status;
+ gwvl_status = Nv::Vl::ApplyLighting(gwvlctx_, ctx, sceneRT, sceneDepth, getPostprocessDesc());
+ ASSERT_LOG(gwvl_status == Nv::Vl::Status::OK, "GWVL Error: %d", gwvl_status);
+}
+
+void Scene::animate(float dt)
+{
+ static uint64_t time_elapsed_us = 0;
+
+ // Update the scene
+ if (!isPaused_)
+ {
+ time_elapsed_us += static_cast<uint64_t>(dt * 1000000.0);
+ if (lightMode_ != eLightMode::OMNI)
+ {
+ float angle = float(dt) * Nv::NvPiDivFour;
+ sceneTransform_ = sceneTransform_ * Nv::NvMat44(
+ Nv::NvVec4(Nv::intrinsics::cos(angle), 0, -Nv::intrinsics::sin(angle), 0),
+ Nv::NvVec4(0, 1, 0, 0),
+ Nv::NvVec4(Nv::intrinsics::sin(angle), 0, Nv::intrinsics::cos(angle), 0),
+ Nv::NvVec4(0, 0, 0, 1)
+ );
+ }
+ else
+ {
+ sceneTransform_ = Nv::NvMat44(Nv::NvIdentity);
+ }
+
+ if (lightMode_ == eLightMode::OMNI)
+ {
+ const uint64_t CYCLE_LENGTH = 60000000;
+ float cyclePhase = static_cast<float>(time_elapsed_us % CYCLE_LENGTH) / static_cast<float>(CYCLE_LENGTH);
+ lightTransform_ = Nv::NvMat44(
+ Nv::NvVec4(Nv::intrinsics::cos(Nv::NvTwoPi*7.0f*cyclePhase), 0, 0, 0),
+ Nv::NvVec4(0, Nv::intrinsics::cos(Nv::NvTwoPi*3.0f*cyclePhase), 0, 0),
+ Nv::NvVec4(0, 0, 1, 0),
+ Nv::NvVec4(0, 0, 0, 1)
+ );
+ }
+ }
+}
+
+void Scene::setupObjectCB(ObjectCB * pObject, const Nv::NvVec3 & offset)
+{
+ pObject->mTransform = sceneTransform_*Nv::NvTransform(offset);
+ pObject->vColor[0] = 1.0f;
+ pObject->vColor[1] = 1.0f;
+ pObject->vColor[2] = 1.0f;
+}
+
+void Scene::setupLightViewCB(ViewCB * pView)
+{
+ getLightViewpoint(pView->vEyePos, pView->mProj);
+ pView->zNear = 0.50f;
+ pView->zFar = LIGHT_RANGE;
+}
+
+void Scene::setupSceneCBs(ViewCB * pView, LightCB * pLight)
+{
+ const Nv::Vl::ViewerDesc * viewerDesc = getViewerDesc();
+ pView->mProj = *reinterpret_cast<const Nv::NvMat44 *>(&viewerDesc->mViewProj);
+ pView->vEyePos = *reinterpret_cast<const Nv::NvVec3 *>(&viewerDesc->vEyePosition);
+ pView->zNear = 0.50f;
+ pView->zFar = 50.0f;
+
+ const Nv::Vl::LightDesc * lightDesc = getLightDesc();
+ getLightViewpoint(pLight->vLightPos, pLight->mLightViewProj);
+ pLight->vLightDirection = (-pLight->vLightPos);
+ pLight->vLightDirection.normalize();
+ pLight->fLightFalloffCosTheta = Nv::intrinsics::cos(SPOTLIGHT_FALLOFF_ANGLE);
+ pLight->fLightFalloffPower = SPOTLIGHT_FALLOFF_POWER;
+ pLight->vLightColor = getLightIntensity();
+ if (lightMode_ == eLightMode::SPOTLIGHT)
+ {
+ pLight->vLightAttenuationFactors = Nv::NvVec4(lightDesc->Spotlight.fAttenuationFactors);
+ }
+ else if (lightMode_ == eLightMode::OMNI)
+ {
+ pLight->vLightAttenuationFactors = Nv::NvVec4(lightDesc->Omni.fAttenuationFactors);
+ }
+ pLight->zNear = 0.50f;
+ pLight->zFar = LIGHT_RANGE;
+
+ const Nv::Vl::MediumDesc * mediumDesc = getMediumDesc();
+ pLight->vSigmaExtinction = *reinterpret_cast<const Nv::NvVec3 *>(&mediumDesc->vAbsorption);
+ for (uint32_t t = 0; t < mediumDesc->uNumPhaseTerms; ++t)
+ {
+ pLight->vSigmaExtinction = pLight->vSigmaExtinction + *reinterpret_cast<const Nv::NvVec3 *>(&mediumDesc->PhaseTerms[t].vDensity);
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////
diff --git a/samples/VolumetricLightingTest/scene.h b/samples/VolumetricLightingTest/scene.h
new file mode 100644
index 0000000..efed5af
--- /dev/null
+++ b/samples/VolumetricLightingTest/scene.h
@@ -0,0 +1,150 @@
+// This code contains NVIDIA Confidential Information and is disclosed
+// under the Mutual Non-Disclosure Agreement.
+//
+// Notice
+// ALL NVIDIA DESIGN SPECIFICATIONS AND CODE ("MATERIALS") ARE PROVIDED "AS IS" NVIDIA MAKES
+// NO REPRESENTATIONS, WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
+//
+// 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. No third party distribution is allowed unless
+// expressly authorized by NVIDIA. 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 (c) 2003 - 2016 NVIDIA Corporation. All rights reserved.
+//
+// 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.
+//
+
+#ifndef SCENE_H
+#define SCENE_H
+////////////////////////////////////////////////////////////////////////////////
+#include "common.h"
+#include <Nv/VolumetricLighting/NvVolumetricLighting.h>
+////////////////////////////////////////////////////////////////////////////////
+class Scene
+{
+public:
+ static const uint32_t SHADOWMAP_RESOLUTION;
+ static const float LIGHT_RANGE;
+ static const float SPOTLIGHT_FALLOFF_ANGLE;
+ static const float SPOTLIGHT_FALLOFF_POWER;
+
+ enum class eLightMode
+ {
+ UNKNOWN = -1,
+ DIRECTIONAL,
+ SPOTLIGHT,
+ OMNI,
+ COUNT
+ };
+
+ struct ViewCB
+ {
+ Nv::NvMat44 mProj;
+ Nv::NvVec3 vEyePos;
+ float pad1[1];
+ float zNear;
+ float zFar;
+ float pad2[2];
+ };
+
+ struct ObjectCB
+ {
+ Nv::NvMat44 mTransform;
+ float vColor[3];
+ float pad[1];
+ };
+
+ struct LightCB
+ {
+ Nv::NvMat44 mLightViewProj;
+ Nv::NvVec3 vLightDirection;
+ float fLightFalloffCosTheta;
+ Nv::NvVec3 vLightPos;
+ float fLightFalloffPower;
+ Nv::NvVec3 vLightColor;
+ float pad1[1];
+ Nv::NvVec4 vLightAttenuationFactors;
+ float zNear;
+ float zFar;
+ float pad2[2];
+ Nv::NvVec3 vSigmaExtinction;
+ float pad3[1];
+ };
+
+ Scene();
+ void Release();
+
+ bool isCtxValid();
+ void invalidateCtx();
+ void createCtx(const Nv::Vl::PlatformDesc * platform);
+
+ void updateFramebuffer(uint32_t w, uint32_t h, uint32_t s);
+
+ void setDebugMode(Nv::Vl::DebugFlags d);
+ void togglePause();
+ void toggleDownsampleMode();
+ void toggleMsaaMode();
+ void toggleFiltering();
+ void toggleUpsampleMode();
+ void toggleFog();
+ void toggleViewpoint();
+ void toggleIntensity();
+ void toggleMediumType();
+ void toggleLightMode();
+
+ eLightMode getLightMode();
+ void getLightViewpoint(Nv::NvVec3 & vPos, Nv::NvMat44 & mViewProj);
+ Nv::NvVec3 getLightIntensity();
+
+ const Nv::Vl::ViewerDesc * getViewerDesc();
+ const Nv::Vl::LightDesc * getLightDesc();
+ const Nv::Vl::MediumDesc * getMediumDesc();
+ const Nv::Vl::PostprocessDesc * getPostprocessDesc();
+
+ void beginAccumulation(Nv::Vl::PlatformRenderCtx ctx, Nv::Vl::PlatformShaderResource sceneDepth);
+ void renderVolume(Nv::Vl::PlatformRenderCtx ctx, Nv::Vl::PlatformShaderResource shadowmap);
+ void endAccumulation(Nv::Vl::PlatformRenderCtx ctx);
+ void applyLighting(Nv::Vl::PlatformRenderCtx ctx, Nv::Vl::PlatformRenderTarget sceneRT, Nv::Vl::PlatformShaderResource sceneDepth);
+
+ void setupObjectCB(ObjectCB * pObject, const Nv::NvVec3 & offset);
+ void setupLightViewCB(ViewCB * cb);
+ void setupSceneCBs(ViewCB * view_cb, LightCB * light_cb);
+ void animate(float dt);
+
+private:
+ Scene(const Scene & rhs) {rhs;};
+
+ Nv::Vl::Context gwvlctx_;
+ uint32_t shadowmapRes_;
+
+ bool isCtxValid_;
+ bool isPaused_;
+
+ eLightMode lightMode_;
+
+ Nv::Vl::DebugFlags debugMode_;
+ uint32_t viewpoint_;
+ uint32_t lightPower_;
+ uint32_t mediumType_;
+
+ Nv::NvMat44 sceneTransform_;
+ Nv::NvMat44 lightTransform_;
+
+ Nv::Vl::ContextDesc contextDesc_;
+ Nv::Vl::PostprocessDesc postprocessDesc_;
+};
+
+////////////////////////////////////////////////////////////////////////////////
+#endif // SCENE_H
diff --git a/samples/VolumetricLightingTest/shaders/post_PS.hlsl b/samples/VolumetricLightingTest/shaders/post_PS.hlsl
new file mode 100644
index 0000000..d0e5a4c
--- /dev/null
+++ b/samples/VolumetricLightingTest/shaders/post_PS.hlsl
@@ -0,0 +1,56 @@
+// This code contains NVIDIA Confidential Information and is disclosed
+// under the Mutual Non-Disclosure Agreement.
+//
+// Notice
+// ALL NVIDIA DESIGN SPECIFICATIONS AND CODE ("MATERIALS") ARE PROVIDED "AS IS" NVIDIA MAKES
+// NO REPRESENTATIONS, WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
+//
+// 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. No third party distribution is allowed unless
+// expressly authorized by NVIDIA. 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 (c) 2003 - 2016 NVIDIA Corporation. All rights reserved.
+//
+// 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.
+//
+
+/*
+Define the shader permutations for code generation
+%% MUX_BEGIN %%
+%% MUX_END %%
+*/
+
+struct VS_QUAD_OUTPUT
+{
+ float4 vPos : SV_POSITION;
+ sample float2 vTex : TEXCOORD0;
+};
+
+float3 tonemap(float3 C)
+{
+ // Filmic -- model film properties
+ C = max(0, C - 0.004);
+ return (C*(6.2*C+0.5))/(C*(6.2*C+1.7)+0.06);
+}
+
+Texture2DMS<float4> tScene : register(t0);
+
+float4 main(VS_QUAD_OUTPUT input, uint sampleID : SV_SAMPLEINDEX) : SV_Target0
+{
+ float3 output = float3(0, 0, 0);
+ float3 s_hdr = tScene.Load(int2(input.vPos.xy), sampleID).rgb;
+ output = tonemap(s_hdr);
+ return float4(output, 1);
+}
diff --git a/samples/VolumetricLightingTest/shaders/quad_VS.hlsl b/samples/VolumetricLightingTest/shaders/quad_VS.hlsl
new file mode 100644
index 0000000..b8f666a
--- /dev/null
+++ b/samples/VolumetricLightingTest/shaders/quad_VS.hlsl
@@ -0,0 +1,47 @@
+// This code contains NVIDIA Confidential Information and is disclosed
+// under the Mutual Non-Disclosure Agreement.
+//
+// Notice
+// ALL NVIDIA DESIGN SPECIFICATIONS AND CODE ("MATERIALS") ARE PROVIDED "AS IS" NVIDIA MAKES
+// NO REPRESENTATIONS, WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
+//
+// 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. No third party distribution is allowed unless
+// expressly authorized by NVIDIA. 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 (c) 2003 - 2016 NVIDIA Corporation. All rights reserved.
+//
+// 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.
+//
+
+/*
+Define the shader permutations for code generation
+%% MUX_BEGIN %%
+%% MUX_END %%
+*/
+
+struct VS_QUAD_OUTPUT
+{
+ float4 vPos : SV_POSITION;
+ sample float2 vTex : TEXCOORD0;
+};
+
+VS_QUAD_OUTPUT main(uint id : SV_VERTEXID)
+{
+ VS_QUAD_OUTPUT output;
+ output.vTex = float2((id << 1) & 2, id & 2);
+ output.vPos = float4(output.vTex * float2(2,-2) + float2(-1,1), 1, 1);
+ return output;
+}
diff --git a/samples/VolumetricLightingTest/shaders/scene_GS.hlsl b/samples/VolumetricLightingTest/shaders/scene_GS.hlsl
new file mode 100644
index 0000000..3315a79
--- /dev/null
+++ b/samples/VolumetricLightingTest/shaders/scene_GS.hlsl
@@ -0,0 +1,141 @@
+// This code contains NVIDIA Confidential Information and is disclosed
+// under the Mutual Non-Disclosure Agreement.
+//
+// Notice
+// ALL NVIDIA DESIGN SPECIFICATIONS AND CODE ("MATERIALS") ARE PROVIDED "AS IS" NVIDIA MAKES
+// NO REPRESENTATIONS, WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
+//
+// 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. No third party distribution is allowed unless
+// expressly authorized by NVIDIA. 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 (c) 2003 - 2016 NVIDIA Corporation. All rights reserved.
+//
+// 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.
+//
+
+/*
+Define the shader permutations for code generation
+%% MUX_BEGIN %%
+
+%% MUX_END %%
+
+*/
+
+////////////////////////////////////////////////////////////////////////////////
+// Constant Buffers
+
+cbuffer CameraCB : register( b0 )
+{
+ column_major float4x4 c_mViewProj : packoffset(c0);
+ float3 c_vEyePos : packoffset(c4);
+ float c_fZNear : packoffset(c5);
+ float c_fZFar : packoffset(c5.y);
+};
+
+cbuffer ObjectCB : register( b1 )
+{
+ column_major float4x4 c_mObject : packoffset(c0);
+ float3 c_vObjectColor : packoffset(c4);
+};
+
+cbuffer LightCB : register( b2 )
+{
+ column_major float4x4 c_mLightViewProj : packoffset(c0);
+ float3 c_vLightDirection : packoffset(c4);
+ float c_fLightFalloffCosTheta : packoffset(c4.w);
+ float3 c_vLightPos : packoffset(c5);
+ float c_fLightFalloffPower : packoffset(c5.w);
+ float3 c_vLightColor : packoffset(c6);
+ float4 c_vLightAttenuationFactors : packoffset(c7);
+ float c_fLightZNear : packoffset(c8);
+ float c_fLightZNFar : packoffset(c8.y);
+ float3 c_vSigmaExtinction : packoffset(c9);
+};
+
+////////////////////////////////////////////////////////////////////////////////
+// IO Structures
+
+struct VS_OUTPUT
+{
+ float4 ScreenP : SV_POSITION;
+ float4 P : TEXCOORD0;
+ float3 N : NORMAL0;
+};
+
+struct GS_OUTPUT
+{
+ float4 ScreenP : SV_POSITION;
+ float4 P : TEXCOORD0;
+ float3 N : NORMAL;
+ uint Target : SV_RenderTargetArrayIndex;
+ float Wz : SV_ClipDistance0;
+};
+
+////////////////////////////////////////////////////////////////////////////////
+// Geometry Shader
+
+float3 ParaboloidProject(float3 P, float zNear, float zFar)
+{
+ float3 outP;
+ float lenP = length(P.xyz);
+ outP.xyz = P.xyz/lenP;
+ outP.x = outP.x / (outP.z + 1);
+ outP.y = outP.y / (outP.z + 1);
+ outP.z = (lenP - zNear) / (zFar - zNear);
+ return outP;
+}
+
+void GenerateOmniTriangle(uint target, VS_OUTPUT vA, VS_OUTPUT vB, VS_OUTPUT vC, inout TriangleStream<GS_OUTPUT> output)
+{
+ GS_OUTPUT outValue;
+ outValue.Target = target;
+ outValue.ScreenP = float4(ParaboloidProject(vA.ScreenP.xyz, c_fZNear, c_fZFar), 1);
+ outValue.P = vA.P;
+ outValue.N = vA.N;
+ outValue.Wz = vA.ScreenP.z;
+ output.Append(outValue);
+ outValue.ScreenP = float4(ParaboloidProject(vB.ScreenP.xyz, c_fZNear, c_fZFar), 1);
+ outValue.P = vB.P;
+ outValue.N = vB.N;
+ outValue.Wz = vB.ScreenP.z;
+ output.Append(outValue);
+ outValue.ScreenP = float4(ParaboloidProject(vC.ScreenP.xyz, c_fZNear, c_fZFar), 1);
+ outValue.P = vC.P;
+ outValue.N = vC.N;
+ outValue.Wz = vC.ScreenP.z;
+ output.Append(outValue);
+ output.RestartStrip();
+}
+
+[maxvertexcount(6)]
+void main(triangle VS_OUTPUT input[3], inout TriangleStream<GS_OUTPUT> output)
+{
+ float minZ = min(input[0].ScreenP.z, min(input[1].ScreenP.z, input[2].ScreenP.z));
+ float maxZ = max(input[0].ScreenP.z, max(input[1].ScreenP.z, input[2].ScreenP.z));
+
+ if (maxZ >= 0)
+ {
+ GenerateOmniTriangle(0, input[0], input[1], input[2], output);
+ }
+
+ if (minZ <= 0)
+ {
+ input[0].ScreenP.z *= -1;
+ input[1].ScreenP.z *= -1;
+ input[2].ScreenP.z *= -1;
+ GenerateOmniTriangle(1, input[2], input[1], input[0], output);
+ }
+}
diff --git a/samples/VolumetricLightingTest/shaders/scene_PS.hlsl b/samples/VolumetricLightingTest/shaders/scene_PS.hlsl
new file mode 100644
index 0000000..66b7e9d
--- /dev/null
+++ b/samples/VolumetricLightingTest/shaders/scene_PS.hlsl
@@ -0,0 +1,177 @@
+// This code contains NVIDIA Confidential Information and is disclosed
+// under the Mutual Non-Disclosure Agreement.
+//
+// Notice
+// ALL NVIDIA DESIGN SPECIFICATIONS AND CODE ("MATERIALS") ARE PROVIDED "AS IS" NVIDIA MAKES
+// NO REPRESENTATIONS, WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
+//
+// 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. No third party distribution is allowed unless
+// expressly authorized by NVIDIA. 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 (c) 2003 - 2016 NVIDIA Corporation. All rights reserved.
+//
+// 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.
+//
+
+/*
+Define the shader permutations for code generation
+%% MUX_BEGIN %%
+- LIGHTMODE:
+ - LIGHTMODE_DIRECTIONAL
+ - LIGHTMODE_SPOTLIGHT
+ - LIGHTMODE_OMNI
+%% MUX_END %%
+*/
+
+////////////////////////////////////////////////////////////////////////////////
+// Resources
+
+SamplerComparisonState sampShadowmap : register(s0);
+
+#if (LIGHTMODE == LIGHTMODE_DIRECTIONAL || LIGHTMODE == LIGHTMODE_SPOTLIGHT)
+ Texture2D<float> tShadowmap : register(t0);
+#elif (LIGHTMODE == LIGHTMODE_OMNI)
+ Texture2DArray <float1> tShadowmapArray : register(t0);
+#endif
+////////////////////////////////////////////////////////////////////////////////
+// Constant Buffers
+
+cbuffer CameraCB : register( b0 )
+{
+ column_major float4x4 c_mViewProj : packoffset(c0);
+ float3 c_vEyePos : packoffset(c4);
+ float c_fZNear : packoffset(c5);
+ float c_fZFar : packoffset(c5.y);
+};
+
+cbuffer ObjectCB : register( b1 )
+{
+ column_major float4x4 c_mObject : packoffset(c0);
+ float3 c_vObjectColor : packoffset(c4);
+};
+
+cbuffer LightCB : register( b2 )
+{
+ column_major float4x4 c_mLightViewProj : packoffset(c0);
+ float3 c_vLightDirection : packoffset(c4);
+ float c_fLightFalloffCosTheta : packoffset(c4.w);
+ float3 c_vLightPos : packoffset(c5);
+ float c_fLightFalloffPower : packoffset(c5.w);
+ float3 c_vLightColor : packoffset(c6);
+ float4 c_vLightAttenuationFactors : packoffset(c7);
+ float c_fLightZNear : packoffset(c8);
+ float c_fLightZFar : packoffset(c8.y);
+ float3 c_vSigmaExtinction : packoffset(c9);
+};
+
+////////////////////////////////////////////////////////////////////////////////
+// IO Structures
+
+struct VS_OUTPUT
+{
+ float4 ScreenP : SV_POSITION;
+ float4 P : TEXCOORD0;
+ float3 N : NORMAL0;
+};
+
+////////////////////////////////////////////////////////////////////////////////
+// Pixel Shader
+
+float3 ParaboloidProject(float3 P, float zNear, float zFar)
+{
+ float3 outP;
+ float lenP = length(P.xyz);
+ outP.xyz = P.xyz/lenP;
+ outP.x = outP.x / (outP.z + 1);
+ outP.y = outP.y / (outP.z + 1);
+ outP.z = (lenP - zNear) / (zFar - zNear);
+ return outP;
+}
+
+float4 main(VS_OUTPUT input) : SV_Target0
+{
+ float3 P = input.P.xyz / input.P.w;
+ float3 N = normalize(input.N);
+ float3 Kd = c_vObjectColor;
+
+ //return float4(0.5*(N+1), 1);
+
+ const float SHADOW_BIAS = -0.001f;
+ float4 shadow_clip = mul(c_mLightViewProj, float4(P,1));
+ shadow_clip = shadow_clip / shadow_clip.w;
+ uint hemisphereID = (shadow_clip.z > 0) ? 0 : 1;
+ if (LIGHTMODE == LIGHTMODE_OMNI)
+ {
+ shadow_clip.z = abs(shadow_clip.z);
+ shadow_clip.xyz = ParaboloidProject(shadow_clip.xyz, c_fLightZNear, c_fLightZFar);
+ }
+ float2 shadow_tc = float2(0.5f, -0.5f)*shadow_clip.xy + 0.5f;
+ float receiver_depth = shadow_clip.z+SHADOW_BIAS;
+
+ float total_light = 0;
+ const int SHADOW_KERNEL = 2;
+ [unroll]
+ for (int ox=-SHADOW_KERNEL; ox<=SHADOW_KERNEL; ++ox)
+ {
+ [unroll]
+ for (int oy=-SHADOW_KERNEL; oy<=SHADOW_KERNEL; ++oy)
+ {
+#if (LIGHTMODE == LIGHTMODE_OMNI)
+ total_light += tShadowmapArray.SampleCmpLevelZero(sampShadowmap, float3(shadow_tc, hemisphereID), receiver_depth, int2(ox, oy)).x;
+#else
+ total_light += tShadowmap.SampleCmpLevelZero(sampShadowmap, shadow_tc, receiver_depth, int2(ox, oy)).x;
+#endif
+ }
+ }
+ float shadow_term = total_light / ((2*SHADOW_KERNEL+1) * (2*SHADOW_KERNEL+1));
+
+ float3 output = float3(0,0,0);
+ float3 L = -c_vLightDirection;
+ if (LIGHTMODE == LIGHTMODE_DIRECTIONAL)
+ {
+ float3 attenuation = shadow_term*dot(N, L);
+ float3 ambient = 0.001f*saturate(0.5f*(dot(N, L)+1.0f));
+ output += c_vLightColor*max(attenuation, ambient);
+
+ }
+ else if (LIGHTMODE == LIGHTMODE_SPOTLIGHT)
+ {
+ float light_to_world = length(P - c_vLightPos);
+ float3 W = (c_vLightPos - P)/light_to_world;
+
+ float distance_attenuation = 1.0f/(c_vLightAttenuationFactors.x + c_vLightAttenuationFactors.y*light_to_world + c_vLightAttenuationFactors.z*light_to_world*light_to_world) + c_vLightAttenuationFactors.w;
+
+ const float ANGLE_EPSILON = 0.00001f;
+ float angle_factor = saturate((dot(N, L)-c_fLightFalloffCosTheta)/(1-c_fLightFalloffCosTheta));
+ float spot_attenuation = (angle_factor > ANGLE_EPSILON) ? pow(angle_factor, c_fLightFalloffPower) : 0.0f;
+
+ float3 attenuation = distance_attenuation*spot_attenuation*shadow_term*dot(N, W);
+ float3 ambient = 0.00001f*saturate(0.5f*(dot(N, L)+1.0f));
+ output += c_vLightColor*max(attenuation, ambient)*exp(-c_vSigmaExtinction*light_to_world);
+ }
+ else if (LIGHTMODE == LIGHTMODE_OMNI)
+ {
+ float light_to_world = length(P - c_vLightPos);
+ float3 W = (c_vLightPos - P)/light_to_world;
+ float distance_attenuation = 1.0f/(c_vLightAttenuationFactors.x + c_vLightAttenuationFactors.y*light_to_world + c_vLightAttenuationFactors.z*light_to_world*light_to_world) + c_vLightAttenuationFactors.w;
+
+ float3 attenuation = distance_attenuation*shadow_term*dot(N, W);
+ float3 ambient = 0.00001f*saturate(0.5f*(dot(N, L)+1.0f));
+ output += c_vLightColor*max(attenuation, ambient)*exp(-c_vSigmaExtinction*light_to_world);
+ }
+
+ return float4(output, 1);
+}
diff --git a/samples/VolumetricLightingTest/shaders/scene_VS.hlsl b/samples/VolumetricLightingTest/shaders/scene_VS.hlsl
new file mode 100644
index 0000000..630b87c
--- /dev/null
+++ b/samples/VolumetricLightingTest/shaders/scene_VS.hlsl
@@ -0,0 +1,117 @@
+// This code contains NVIDIA Confidential Information and is disclosed
+// under the Mutual Non-Disclosure Agreement.
+//
+// Notice
+// ALL NVIDIA DESIGN SPECIFICATIONS AND CODE ("MATERIALS") ARE PROVIDED "AS IS" NVIDIA MAKES
+// NO REPRESENTATIONS, WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
+//
+// 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. No third party distribution is allowed unless
+// expressly authorized by NVIDIA. 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 (c) 2003 - 2016 NVIDIA Corporation. All rights reserved.
+//
+// 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.
+//
+
+/*
+Define the shader permutations for code generation
+%% MUX_BEGIN %%
+%% MUX_END %%
+*/
+
+////////////////////////////////////////////////////////////////////////////////
+// Constant Buffers
+
+cbuffer CameraCB : register( b0 )
+{
+ column_major float4x4 c_mViewProj : packoffset(c0);
+ float3 c_vEyePos : packoffset(c4);
+ float c_fZNear : packoffset(c5);
+ float c_fZFar : packoffset(c5.y);
+};
+
+cbuffer ObjectCB : register( b1 )
+{
+ column_major float4x4 c_mObject : packoffset(c0);
+ float3 c_vObjectColor : packoffset(c4);
+};
+
+cbuffer LightCB : register( b2 )
+{
+ column_major float4x4 c_mLightViewProj : packoffset(c0);
+ float3 c_vLightDirection : packoffset(c4);
+ float c_fLightFalloffCosTheta : packoffset(c4.w);
+ float3 c_vLightPos : packoffset(c5);
+ float c_fLightFalloffPower : packoffset(c5.w);
+ float3 c_vLightColor : packoffset(c6);
+ float4 c_vLightAttenuationFactors : packoffset(c7);
+ float c_fLightZNear : packoffset(c8);
+ float c_fLightZNFar : packoffset(c8.y);
+ float3 c_vSigmaExtinction : packoffset(c9);
+};
+
+////////////////////////////////////////////////////////////////////////////////
+// IO Structures
+
+struct VS_OUTPUT
+{
+ float4 ScreenP : SV_POSITION;
+ float4 P : TEXCOORD0;
+ float3 N : NORMAL0;
+};
+
+////////////////////////////////////////////////////////////////////////////////
+// Vertex Shader
+
+VS_OUTPUT main( uint id : SV_VERTEXID )
+{
+ VS_OUTPUT output;
+
+ // Faces
+ // +X, +Y, +Z, -X, -Y, -Z
+ // Vertices
+ // 0 ---15
+ // | / |
+ // | / |
+ // | / |
+ // 24--- 3
+
+ uint face_idx = id / 6;
+ uint vtx_idx = id % 6;
+ float3 P;
+ P.x = ((vtx_idx % 3) == 2) ? -1 : 1;
+ P.y = ((vtx_idx % 3) == 1) ? -1 : 1;
+ P.z = 0;
+ if ((face_idx % 3) == 0)
+ P.yzx = P.xyz;
+ else if ((face_idx % 3) == 1)
+ P.xzy = P.xyz;
+ // else if ((face_idx % 3) == 2)
+ // P.xyz = P.xyz;
+ P *= ((vtx_idx / 3) == 0) ? 1 : -1;
+
+ float3 N;
+ N.x = ((face_idx % 3) == 0) ? 1 : 0;
+ N.y = ((face_idx % 3) == 1) ? 1 : 0;
+ N.z = ((face_idx % 3) == 2) ? 1 : 0;
+ N *= ((face_idx / 3) == 0) ? 1 : -1;
+ P += N;
+
+ output.P = mul(c_mObject, float4(P, 1));
+ output.ScreenP = mul(c_mViewProj, output.P);
+ output.N = mul(c_mObject, float4(N, 0)).xyz;
+ return output;
+}
diff --git a/samples/bin/NvVolumetricLighting.win64.dll b/samples/bin/NvVolumetricLighting.win64.dll
new file mode 100644
index 0000000..0f3aff4
--- /dev/null
+++ b/samples/bin/NvVolumetricLighting.win64.dll
Binary files differ
diff --git a/samples/bin/VolumetricLightingTest.win64.exe b/samples/bin/VolumetricLightingTest.win64.exe
new file mode 100644
index 0000000..3096459
--- /dev/null
+++ b/samples/bin/VolumetricLightingTest.win64.exe
Binary files differ
diff --git a/samples/bin/VolumetricLightingTest_Readme.txt b/samples/bin/VolumetricLightingTest_Readme.txt
new file mode 100644
index 0000000..be5079a
--- /dev/null
+++ b/samples/bin/VolumetricLightingTest_Readme.txt
@@ -0,0 +1,15 @@
+F1 - Default View
+F2 - Scattering-only View
+F3 - Wireframe View
+
+F4 - Toggle Fullscreen
+
+Space - Pause animation
+
+V - Toggle Viewer Position
+L - Toggle Light Type (Spot, Point, Directional)
+O - Toggle Medium Type (Very Clear, Humid, Hazy, Murky)
+P - Toggle Light Power (Medium, Low, High, Red, Green, Blue)
+D - Toggle Downsample Mode (Full-Res, Half-Res, Quarter-Res)
+M - Toggle MSAA Mode (1x, 2x, 4x)
+U - Toggle Upsampling Mode (Point, Bilinear, Bilateral) \ No newline at end of file
diff --git a/samples/build/vs2012/VolumetricLightingTest.vcxproj b/samples/build/vs2012/VolumetricLightingTest.vcxproj
new file mode 100644
index 0000000..5f1fee5
--- /dev/null
+++ b/samples/build/vs2012/VolumetricLightingTest.vcxproj
@@ -0,0 +1,338 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="debug|x64">
+ <Configuration>debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="profile|x64">
+ <Configuration>profile</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="checked|x64">
+ <Configuration>checked</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="release|x64">
+ <Configuration>release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ApplicationEnvironment>title</ApplicationEnvironment>
+ <!-- - - - -->
+ <PlatformToolset>v110</PlatformToolset>
+ <MinimumVisualStudioVersion>11.0</MinimumVisualStudioVersion>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='debug|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <PlatformToolset>v110</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='profile|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <PlatformToolset>v110</PlatformToolset>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='checked|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <PlatformToolset>v110</PlatformToolset>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='release|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <PlatformToolset>v110</PlatformToolset>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='debug|x64'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='profile|x64'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='checked|x64'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='release|x64'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='debug|x64'">
+ <OutDir>./../../bin\</OutDir>
+ <IntDir>./x64/VolumetricLightingTest/debug\</IntDir>
+ <TargetExt>.exe</TargetExt>
+ <TargetName>VolumetricLightingTest.win64.D</TargetName>
+ <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules />
+ <CodeAnalysisRuleAssemblies />
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='debug|x64'">
+ <ClCompile>
+ <CallingConvention>Cdecl</CallingConvention>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <RuntimeTypeInfo>false</RuntimeTypeInfo>
+ <OpenMPSupport>false</OpenMPSupport>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <FloatingPointModel>Fast</FloatingPointModel>
+ <AdditionalOptions>/wd4995 /W4 /Oy- /EHsc -D_ITERATOR_DEBUG_LEVEL=0 /d2Zi+</AdditionalOptions>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>./../../VolumetricLightingTest;./../../../include;$(IntDir);./../../../external/NvFoundation/1.1/include;./{user:ShaderOutputPath};%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>_WIN64;_UNICODE;UNICODE;_WINDOWS;WIN32_LEAN_AND_MEAN;_CRT_SECURE_NO_DEPRECATE;NV_FOUNDATION_DLL=0;NV_PLATFORM_D3D11=1;NV_DEBUG=1;NV_CHECKED=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <ExceptionHandling>false</ExceptionHandling>
+ <WarningLevel>Level4</WarningLevel>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <PrecompiledHeaderFile></PrecompiledHeaderFile>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <AdditionalOptions>/MACHINE:x64 /SUBSYSTEM:WINDOWS /NOLOGO</AdditionalOptions>
+ <AdditionalDependencies>comctl32.lib;dxguid.lib;d3d11.lib;NvVolumetricLighting.win64.D.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <OutputFile>$(OutDir)VolumetricLightingTest.win64.D.exe</OutputFile>
+ <AdditionalLibraryDirectories>./../../../lib/win64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <ProgramDatabaseFile>$(OutDir)/VolumetricLightingTest.win64.D.exe.pdb</ProgramDatabaseFile>
+ <SubSystem>Windows</SubSystem>
+ <ImportLibrary>$(OutDir)$(TargetName).lib</ImportLibrary>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <TargetMachine>MachineX64</TargetMachine>
+ </Link>
+ <ResourceCompile>
+ </ResourceCompile>
+ <ProjectReference>
+ </ProjectReference>
+ </ItemDefinitionGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='profile|x64'">
+ <OutDir>./../../bin\</OutDir>
+ <IntDir>./x64/VolumetricLightingTest/profile\</IntDir>
+ <TargetExt>.exe</TargetExt>
+ <TargetName>VolumetricLightingTest.win64.P</TargetName>
+ <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules />
+ <CodeAnalysisRuleAssemblies />
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='profile|x64'">
+ <ClCompile>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <RuntimeTypeInfo>false</RuntimeTypeInfo>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <OpenMPSupport>false</OpenMPSupport>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <FloatingPointModel>Fast</FloatingPointModel>
+ <AdditionalOptions>/wd4995 /W4 /Oy- /EHsc /d2Zi+</AdditionalOptions>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>./../../VolumetricLightingTest;./../../../include;$(IntDir);./../../../external/NvFoundation/1.1/include;./{user:ShaderOutputPath};%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>_WIN64;_UNICODE;UNICODE;_WINDOWS;WIN32_LEAN_AND_MEAN;_CRT_SECURE_NO_DEPRECATE;NV_FOUNDATION_DLL=0;NV_PLATFORM_D3D11=1;NV_PROFILE=1;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <ExceptionHandling>false</ExceptionHandling>
+ <WarningLevel>Level4</WarningLevel>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <PrecompiledHeaderFile></PrecompiledHeaderFile>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <AdditionalOptions>/MACHINE:x64 /SUBSYSTEM:WINDOWS /NOLOGO</AdditionalOptions>
+ <AdditionalDependencies>comctl32.lib;dxguid.lib;d3d11.lib;NvVolumetricLighting.win64.P.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <OutputFile>$(OutDir)VolumetricLightingTest.win64.P.exe</OutputFile>
+ <AdditionalLibraryDirectories>./../../../lib/win64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <ProgramDatabaseFile>$(OutDir)/VolumetricLightingTest.win64.P.exe.pdb</ProgramDatabaseFile>
+ <SubSystem>Windows</SubSystem>
+ <ImportLibrary>$(OutDir)$(TargetName).lib</ImportLibrary>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <TargetMachine>MachineX64</TargetMachine>
+ </Link>
+ <ResourceCompile>
+ </ResourceCompile>
+ <ProjectReference>
+ </ProjectReference>
+ </ItemDefinitionGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='checked|x64'">
+ <OutDir>./../../bin\</OutDir>
+ <IntDir>./x64/VolumetricLightingTest/checked\</IntDir>
+ <TargetExt>.exe</TargetExt>
+ <TargetName>VolumetricLightingTest.win64.C</TargetName>
+ <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules />
+ <CodeAnalysisRuleAssemblies />
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='checked|x64'">
+ <ClCompile>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <RuntimeTypeInfo>false</RuntimeTypeInfo>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <OpenMPSupport>false</OpenMPSupport>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <FloatingPointModel>Fast</FloatingPointModel>
+ <AdditionalOptions>/wd4995 /W4 /Oy- /EHsc /d2Zi+</AdditionalOptions>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>./../../VolumetricLightingTest;./../../../include;$(IntDir);./../../../external/NvFoundation/1.1/include;./{user:ShaderOutputPath};%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>_WIN64;_UNICODE;UNICODE;_WINDOWS;WIN32_LEAN_AND_MEAN;_CRT_SECURE_NO_DEPRECATE;NV_FOUNDATION_DLL=0;NV_PLATFORM_D3D11=1;NV_CHECKED=1;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <ExceptionHandling>false</ExceptionHandling>
+ <WarningLevel>Level4</WarningLevel>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <PrecompiledHeaderFile></PrecompiledHeaderFile>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <AdditionalOptions>/MACHINE:x64 /SUBSYSTEM:WINDOWS /NOLOGO</AdditionalOptions>
+ <AdditionalDependencies>comctl32.lib;dxguid.lib;d3d11.lib;NvVolumetricLighting.win64.C.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <OutputFile>$(OutDir)VolumetricLightingTest.win64.C.exe</OutputFile>
+ <AdditionalLibraryDirectories>./../../../lib/win64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <ProgramDatabaseFile>$(OutDir)/VolumetricLightingTest.win64.C.exe.pdb</ProgramDatabaseFile>
+ <SubSystem>Windows</SubSystem>
+ <ImportLibrary>$(OutDir)$(TargetName).lib</ImportLibrary>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <TargetMachine>MachineX64</TargetMachine>
+ </Link>
+ <ResourceCompile>
+ </ResourceCompile>
+ <ProjectReference>
+ </ProjectReference>
+ </ItemDefinitionGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='release|x64'">
+ <OutDir>./../../bin\</OutDir>
+ <IntDir>./x64/VolumetricLightingTest/release\</IntDir>
+ <TargetExt>.exe</TargetExt>
+ <TargetName>VolumetricLightingTest.win64</TargetName>
+ <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules />
+ <CodeAnalysisRuleAssemblies />
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='release|x64'">
+ <ClCompile>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <RuntimeTypeInfo>false</RuntimeTypeInfo>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <OpenMPSupport>false</OpenMPSupport>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <FloatingPointModel>Fast</FloatingPointModel>
+ <AdditionalOptions>/wd4995 /W4 /Oy- /EHsc /d2Zi+</AdditionalOptions>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>./../../VolumetricLightingTest;./../../../include;$(IntDir);./../../../external/NvFoundation/1.1/include;./{user:ShaderOutputPath};%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>_WIN64;_UNICODE;UNICODE;_WINDOWS;WIN32_LEAN_AND_MEAN;_CRT_SECURE_NO_DEPRECATE;NV_FOUNDATION_DLL=0;NV_PLATFORM_D3D11=1;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <ExceptionHandling>false</ExceptionHandling>
+ <WarningLevel>Level4</WarningLevel>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <PrecompiledHeaderFile></PrecompiledHeaderFile>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <AdditionalOptions>/MACHINE:x64 /SUBSYSTEM:WINDOWS /NOLOGO</AdditionalOptions>
+ <AdditionalDependencies>comctl32.lib;dxguid.lib;d3d11.lib;NvVolumetricLighting.win64.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <OutputFile>$(OutDir)VolumetricLightingTest.win64.exe</OutputFile>
+ <AdditionalLibraryDirectories>./../../../lib/win64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <ProgramDatabaseFile>$(OutDir)/VolumetricLightingTest.win64.exe.pdb</ProgramDatabaseFile>
+ <SubSystem>Windows</SubSystem>
+ <ImportLibrary>$(OutDir)$(TargetName).lib</ImportLibrary>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <TargetMachine>MachineX64</TargetMachine>
+ </Link>
+ <ResourceCompile>
+ </ResourceCompile>
+ <ProjectReference>
+ </ProjectReference>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClInclude Include="..\..\VolumetricLightingTest\common.h">
+ </ClInclude>
+ <ClInclude Include="..\..\VolumetricLightingTest\scene.h">
+ </ClInclude>
+ <ClCompile Include="..\..\VolumetricLightingTest\main.cpp">
+ </ClCompile>
+ <ClCompile Include="..\..\VolumetricLightingTest\scene.cpp">
+ </ClCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="..\..\VolumetricLightingTest\d3d11\compiled_shaders_d3d11.h">
+ </ClInclude>
+ <ClInclude Include="..\..\VolumetricLightingTest\d3d11\d3d11_util.h">
+ </ClInclude>
+ <ClInclude Include="..\..\VolumetricLightingTest\d3d11\DeviceManager.h">
+ </ClInclude>
+ <ClCompile Include="..\..\VolumetricLightingTest\d3d11\compiled_shaders_d3d11.cpp">
+ </ClCompile>
+ <ClCompile Include="..\..\VolumetricLightingTest\d3d11\d3d11_main.cpp">
+ </ClCompile>
+ <ClCompile Include="..\..\VolumetricLightingTest\d3d11\d3d11_util.cpp">
+ </ClCompile>
+ <ClCompile Include="..\..\VolumetricLightingTest\d3d11\DeviceManager.cpp">
+ </ClCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <CustomBuild Include="..\..\VolumetricLightingTest\shaders\quad_VS.hlsl">
+ <Command Condition="'$(Configuration)|$(Platform)'=='debug|x64'">"../../VolumetricLightingTest/../../tools/shadermux.exe" -l 0 -w -f -o "$(IntDir)shaders" -p d3d11 -c "/Tvs_5_0" ..\..\VolumetricLightingTest\shaders\quad_VS.hlsl</Command>
+ <Message Condition="'$(Configuration)|$(Platform)'=='debug|x64'">Precompiling shader permutations for %(Identity)</Message>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='debug|x64'">$(IntDir)shaders/quad_VS.mux.h;$(IntDir)shaders/quad_VS.mux.bytecode;</Outputs>
+ <Command Condition="'$(Configuration)|$(Platform)'=='profile|x64'">"../../VolumetricLightingTest/../../tools/shadermux.exe" -l 0 -w -f -o "$(IntDir)shaders" -p d3d11 -c "/Tvs_5_0" ..\..\VolumetricLightingTest\shaders\quad_VS.hlsl</Command>
+ <Message Condition="'$(Configuration)|$(Platform)'=='profile|x64'">Precompiling shader permutations for %(Identity)</Message>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='profile|x64'">$(IntDir)shaders/quad_VS.mux.h;$(IntDir)shaders/quad_VS.mux.bytecode;</Outputs>
+ <Command Condition="'$(Configuration)|$(Platform)'=='checked|x64'">"../../VolumetricLightingTest/../../tools/shadermux.exe" -l 0 -w -f -o "$(IntDir)shaders" -p d3d11 -c "/Tvs_5_0" ..\..\VolumetricLightingTest\shaders\quad_VS.hlsl</Command>
+ <Message Condition="'$(Configuration)|$(Platform)'=='checked|x64'">Precompiling shader permutations for %(Identity)</Message>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='checked|x64'">$(IntDir)shaders/quad_VS.mux.h;$(IntDir)shaders/quad_VS.mux.bytecode;</Outputs>
+ <Command Condition="'$(Configuration)|$(Platform)'=='release|x64'">"../../VolumetricLightingTest/../../tools/shadermux.exe" -l 0 -w -f -o "$(IntDir)shaders" -p d3d11 -c "/Tvs_5_0" ..\..\VolumetricLightingTest\shaders\quad_VS.hlsl</Command>
+ <Message Condition="'$(Configuration)|$(Platform)'=='release|x64'">Precompiling shader permutations for %(Identity)</Message>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='release|x64'">$(IntDir)shaders/quad_VS.mux.h;$(IntDir)shaders/quad_VS.mux.bytecode;</Outputs>
+ </CustomBuild>
+ <CustomBuild Include="..\..\VolumetricLightingTest\shaders\scene_VS.hlsl">
+ <Command Condition="'$(Configuration)|$(Platform)'=='debug|x64'">"../../VolumetricLightingTest/../../tools/shadermux.exe" -l 0 -w -f -o "$(IntDir)shaders" -p d3d11 -c "/Tvs_5_0" ..\..\VolumetricLightingTest\shaders\scene_VS.hlsl</Command>
+ <Message Condition="'$(Configuration)|$(Platform)'=='debug|x64'">Precompiling shader permutations for %(Identity)</Message>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='debug|x64'">$(IntDir)shaders/scene_VS.mux.h;$(IntDir)shaders/scene_VS.mux.bytecode;</Outputs>
+ <Command Condition="'$(Configuration)|$(Platform)'=='profile|x64'">"../../VolumetricLightingTest/../../tools/shadermux.exe" -l 0 -w -f -o "$(IntDir)shaders" -p d3d11 -c "/Tvs_5_0" ..\..\VolumetricLightingTest\shaders\scene_VS.hlsl</Command>
+ <Message Condition="'$(Configuration)|$(Platform)'=='profile|x64'">Precompiling shader permutations for %(Identity)</Message>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='profile|x64'">$(IntDir)shaders/scene_VS.mux.h;$(IntDir)shaders/scene_VS.mux.bytecode;</Outputs>
+ <Command Condition="'$(Configuration)|$(Platform)'=='checked|x64'">"../../VolumetricLightingTest/../../tools/shadermux.exe" -l 0 -w -f -o "$(IntDir)shaders" -p d3d11 -c "/Tvs_5_0" ..\..\VolumetricLightingTest\shaders\scene_VS.hlsl</Command>
+ <Message Condition="'$(Configuration)|$(Platform)'=='checked|x64'">Precompiling shader permutations for %(Identity)</Message>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='checked|x64'">$(IntDir)shaders/scene_VS.mux.h;$(IntDir)shaders/scene_VS.mux.bytecode;</Outputs>
+ <Command Condition="'$(Configuration)|$(Platform)'=='release|x64'">"../../VolumetricLightingTest/../../tools/shadermux.exe" -l 0 -w -f -o "$(IntDir)shaders" -p d3d11 -c "/Tvs_5_0" ..\..\VolumetricLightingTest\shaders\scene_VS.hlsl</Command>
+ <Message Condition="'$(Configuration)|$(Platform)'=='release|x64'">Precompiling shader permutations for %(Identity)</Message>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='release|x64'">$(IntDir)shaders/scene_VS.mux.h;$(IntDir)shaders/scene_VS.mux.bytecode;</Outputs>
+ </CustomBuild>
+ <CustomBuild Include="..\..\VolumetricLightingTest\shaders\scene_GS.hlsl">
+ <Command Condition="'$(Configuration)|$(Platform)'=='debug|x64'">"../../VolumetricLightingTest/../../tools/shadermux.exe" -l 0 -w -f -o "$(IntDir)shaders" -p d3d11 -c "/Tgs_5_0" ..\..\VolumetricLightingTest\shaders\scene_GS.hlsl</Command>
+ <Message Condition="'$(Configuration)|$(Platform)'=='debug|x64'">Precompiling shader permutations for %(Identity)</Message>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='debug|x64'">$(IntDir)shaders/scene_GS.mux.h;$(IntDir)shaders/scene_GS.mux.bytecode;</Outputs>
+ <Command Condition="'$(Configuration)|$(Platform)'=='profile|x64'">"../../VolumetricLightingTest/../../tools/shadermux.exe" -l 0 -w -f -o "$(IntDir)shaders" -p d3d11 -c "/Tgs_5_0" ..\..\VolumetricLightingTest\shaders\scene_GS.hlsl</Command>
+ <Message Condition="'$(Configuration)|$(Platform)'=='profile|x64'">Precompiling shader permutations for %(Identity)</Message>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='profile|x64'">$(IntDir)shaders/scene_GS.mux.h;$(IntDir)shaders/scene_GS.mux.bytecode;</Outputs>
+ <Command Condition="'$(Configuration)|$(Platform)'=='checked|x64'">"../../VolumetricLightingTest/../../tools/shadermux.exe" -l 0 -w -f -o "$(IntDir)shaders" -p d3d11 -c "/Tgs_5_0" ..\..\VolumetricLightingTest\shaders\scene_GS.hlsl</Command>
+ <Message Condition="'$(Configuration)|$(Platform)'=='checked|x64'">Precompiling shader permutations for %(Identity)</Message>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='checked|x64'">$(IntDir)shaders/scene_GS.mux.h;$(IntDir)shaders/scene_GS.mux.bytecode;</Outputs>
+ <Command Condition="'$(Configuration)|$(Platform)'=='release|x64'">"../../VolumetricLightingTest/../../tools/shadermux.exe" -l 0 -w -f -o "$(IntDir)shaders" -p d3d11 -c "/Tgs_5_0" ..\..\VolumetricLightingTest\shaders\scene_GS.hlsl</Command>
+ <Message Condition="'$(Configuration)|$(Platform)'=='release|x64'">Precompiling shader permutations for %(Identity)</Message>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='release|x64'">$(IntDir)shaders/scene_GS.mux.h;$(IntDir)shaders/scene_GS.mux.bytecode;</Outputs>
+ </CustomBuild>
+ <CustomBuild Include="..\..\VolumetricLightingTest\shaders\post_PS.hlsl">
+ <Command Condition="'$(Configuration)|$(Platform)'=='debug|x64'">"../../VolumetricLightingTest/../../tools/shadermux.exe" -l 0 -w -f -o "$(IntDir)shaders" -p d3d11 -c "/Tps_5_0" ..\..\VolumetricLightingTest\shaders\post_PS.hlsl</Command>
+ <Message Condition="'$(Configuration)|$(Platform)'=='debug|x64'">Precompiling shader permutations for %(Identity)</Message>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='debug|x64'">$(IntDir)shaders/post_PS.mux.h;$(IntDir)shaders/post_PS.mux.bytecode;</Outputs>
+ <Command Condition="'$(Configuration)|$(Platform)'=='profile|x64'">"../../VolumetricLightingTest/../../tools/shadermux.exe" -l 0 -w -f -o "$(IntDir)shaders" -p d3d11 -c "/Tps_5_0" ..\..\VolumetricLightingTest\shaders\post_PS.hlsl</Command>
+ <Message Condition="'$(Configuration)|$(Platform)'=='profile|x64'">Precompiling shader permutations for %(Identity)</Message>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='profile|x64'">$(IntDir)shaders/post_PS.mux.h;$(IntDir)shaders/post_PS.mux.bytecode;</Outputs>
+ <Command Condition="'$(Configuration)|$(Platform)'=='checked|x64'">"../../VolumetricLightingTest/../../tools/shadermux.exe" -l 0 -w -f -o "$(IntDir)shaders" -p d3d11 -c "/Tps_5_0" ..\..\VolumetricLightingTest\shaders\post_PS.hlsl</Command>
+ <Message Condition="'$(Configuration)|$(Platform)'=='checked|x64'">Precompiling shader permutations for %(Identity)</Message>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='checked|x64'">$(IntDir)shaders/post_PS.mux.h;$(IntDir)shaders/post_PS.mux.bytecode;</Outputs>
+ <Command Condition="'$(Configuration)|$(Platform)'=='release|x64'">"../../VolumetricLightingTest/../../tools/shadermux.exe" -l 0 -w -f -o "$(IntDir)shaders" -p d3d11 -c "/Tps_5_0" ..\..\VolumetricLightingTest\shaders\post_PS.hlsl</Command>
+ <Message Condition="'$(Configuration)|$(Platform)'=='release|x64'">Precompiling shader permutations for %(Identity)</Message>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='release|x64'">$(IntDir)shaders/post_PS.mux.h;$(IntDir)shaders/post_PS.mux.bytecode;</Outputs>
+ </CustomBuild>
+ <CustomBuild Include="..\..\VolumetricLightingTest\shaders\scene_PS.hlsl">
+ <Command Condition="'$(Configuration)|$(Platform)'=='debug|x64'">"../../VolumetricLightingTest/../../tools/shadermux.exe" -l 0 -w -f -o "$(IntDir)shaders" -p d3d11 -c "/Tps_5_0" ..\..\VolumetricLightingTest\shaders\scene_PS.hlsl</Command>
+ <Message Condition="'$(Configuration)|$(Platform)'=='debug|x64'">Precompiling shader permutations for %(Identity)</Message>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='debug|x64'">$(IntDir)shaders/scene_PS.mux.h;$(IntDir)shaders/scene_PS.mux.bytecode;</Outputs>
+ <Command Condition="'$(Configuration)|$(Platform)'=='profile|x64'">"../../VolumetricLightingTest/../../tools/shadermux.exe" -l 0 -w -f -o "$(IntDir)shaders" -p d3d11 -c "/Tps_5_0" ..\..\VolumetricLightingTest\shaders\scene_PS.hlsl</Command>
+ <Message Condition="'$(Configuration)|$(Platform)'=='profile|x64'">Precompiling shader permutations for %(Identity)</Message>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='profile|x64'">$(IntDir)shaders/scene_PS.mux.h;$(IntDir)shaders/scene_PS.mux.bytecode;</Outputs>
+ <Command Condition="'$(Configuration)|$(Platform)'=='checked|x64'">"../../VolumetricLightingTest/../../tools/shadermux.exe" -l 0 -w -f -o "$(IntDir)shaders" -p d3d11 -c "/Tps_5_0" ..\..\VolumetricLightingTest\shaders\scene_PS.hlsl</Command>
+ <Message Condition="'$(Configuration)|$(Platform)'=='checked|x64'">Precompiling shader permutations for %(Identity)</Message>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='checked|x64'">$(IntDir)shaders/scene_PS.mux.h;$(IntDir)shaders/scene_PS.mux.bytecode;</Outputs>
+ <Command Condition="'$(Configuration)|$(Platform)'=='release|x64'">"../../VolumetricLightingTest/../../tools/shadermux.exe" -l 0 -w -f -o "$(IntDir)shaders" -p d3d11 -c "/Tps_5_0" ..\..\VolumetricLightingTest\shaders\scene_PS.hlsl</Command>
+ <Message Condition="'$(Configuration)|$(Platform)'=='release|x64'">Precompiling shader permutations for %(Identity)</Message>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='release|x64'">$(IntDir)shaders/scene_PS.mux.h;$(IntDir)shaders/scene_PS.mux.bytecode;</Outputs>
+ </CustomBuild>
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets"></ImportGroup>
+</Project>
diff --git a/samples/build/vs2012/VolumetricLightingTest.vcxproj.filters b/samples/build/vs2012/VolumetricLightingTest.vcxproj.filters
new file mode 100644
index 0000000..845b330
--- /dev/null
+++ b/samples/build/vs2012/VolumetricLightingTest.vcxproj.filters
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="src"><!-- -->
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="..\..\VolumetricLightingTest\common.h">
+ <Filter>src</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\VolumetricLightingTest\scene.h">
+ <Filter>src</Filter>
+ </ClInclude>
+ <ClCompile Include="..\..\VolumetricLightingTest\main.cpp">
+ <Filter>src</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\VolumetricLightingTest\scene.cpp">
+ <Filter>src</Filter>
+ </ClCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <Filter Include="src (platform)"><!-- -->
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="..\..\VolumetricLightingTest\d3d11\compiled_shaders_d3d11.h">
+ <Filter>src (platform)</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\VolumetricLightingTest\d3d11\d3d11_util.h">
+ <Filter>src (platform)</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\VolumetricLightingTest\d3d11\DeviceManager.h">
+ <Filter>src (platform)</Filter>
+ </ClInclude>
+ <ClCompile Include="..\..\VolumetricLightingTest\d3d11\compiled_shaders_d3d11.cpp">
+ <Filter>src (platform)</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\VolumetricLightingTest\d3d11\d3d11_main.cpp">
+ <Filter>src (platform)</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\VolumetricLightingTest\d3d11\d3d11_util.cpp">
+ <Filter>src (platform)</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\VolumetricLightingTest\d3d11\DeviceManager.cpp">
+ <Filter>src (platform)</Filter>
+ </ClCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <Filter Include="src (shaders)"><!-- Shadermux -->
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <CustomBuild Include="..\..\VolumetricLightingTest\shaders\quad_VS.hlsl">
+ <Filter>src (shaders)</Filter>
+ </CustomBuild>
+ <CustomBuild Include="..\..\VolumetricLightingTest\shaders\scene_VS.hlsl">
+ <Filter>src (shaders)</Filter>
+ </CustomBuild>
+ <CustomBuild Include="..\..\VolumetricLightingTest\shaders\scene_GS.hlsl">
+ <Filter>src (shaders)</Filter>
+ </CustomBuild>
+ <CustomBuild Include="..\..\VolumetricLightingTest\shaders\post_PS.hlsl">
+ <Filter>src (shaders)</Filter>
+ </CustomBuild>
+ <CustomBuild Include="..\..\VolumetricLightingTest\shaders\scene_PS.hlsl">
+ <Filter>src (shaders)</Filter>
+ </CustomBuild>
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/samples/build/vs2012/VolumetricLighting_Samples.sln b/samples/build/vs2012/VolumetricLighting_Samples.sln
new file mode 100644
index 0000000..3887eb4
--- /dev/null
+++ b/samples/build/vs2012/VolumetricLighting_Samples.sln
@@ -0,0 +1,30 @@
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 2012
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "VolumetricLightingTest", "./VolumetricLightingTest.vcxproj", "{00F4B5B4-B6F4-3D3F-6500-2878F07A3100}"
+ ProjectSection(ProjectDependencies) = postProject
+ EndProjectSection
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ checked|x64 = checked|x64
+ debug|x64 = debug|x64
+ profile|x64 = profile|x64
+ release|x64 = release|x64
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {00F4B5B4-B6F4-3D3F-6500-2878F07A3100}.checked|x64.ActiveCfg = checked|x64
+ {00F4B5B4-B6F4-3D3F-6500-2878F07A3100}.checked|x64.Build.0 = checked|x64
+ {00F4B5B4-B6F4-3D3F-6500-2878F07A3100}.debug|x64.ActiveCfg = debug|x64
+ {00F4B5B4-B6F4-3D3F-6500-2878F07A3100}.debug|x64.Build.0 = debug|x64
+ {00F4B5B4-B6F4-3D3F-6500-2878F07A3100}.profile|x64.ActiveCfg = profile|x64
+ {00F4B5B4-B6F4-3D3F-6500-2878F07A3100}.profile|x64.Build.0 = profile|x64
+ {00F4B5B4-B6F4-3D3F-6500-2878F07A3100}.release|x64.ActiveCfg = release|x64
+ {00F4B5B4-B6F4-3D3F-6500-2878F07A3100}.release|x64.Build.0 = release|x64
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ EndGlobalSection
+ GlobalSection(ExtensibilityAddins) = postSolution
+ EndGlobalSection
+ GlobalSection(NestedProjects) = preSolution
+ EndGlobalSection
+EndGlobal
diff --git a/samples/build/vs2013/VolumetricLightingTest.vcxproj b/samples/build/vs2013/VolumetricLightingTest.vcxproj
new file mode 100644
index 0000000..18c69e1
--- /dev/null
+++ b/samples/build/vs2013/VolumetricLightingTest.vcxproj
@@ -0,0 +1,338 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="debug|x64">
+ <Configuration>debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="profile|x64">
+ <Configuration>profile</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="checked|x64">
+ <Configuration>checked</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="release|x64">
+ <Configuration>release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ApplicationEnvironment>title</ApplicationEnvironment>
+ <!-- - - - -->
+ <PlatformToolset>v110</PlatformToolset>
+ <MinimumVisualStudioVersion>11.0</MinimumVisualStudioVersion>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='debug|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <PlatformToolset>v120</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='profile|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <PlatformToolset>v120</PlatformToolset>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='checked|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <PlatformToolset>v120</PlatformToolset>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='release|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <PlatformToolset>v120</PlatformToolset>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='debug|x64'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='profile|x64'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='checked|x64'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='release|x64'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='debug|x64'">
+ <OutDir>./../../bin\</OutDir>
+ <IntDir>./x64/VolumetricLightingTest/debug\</IntDir>
+ <TargetExt>.exe</TargetExt>
+ <TargetName>VolumetricLightingTest.win64.D</TargetName>
+ <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules />
+ <CodeAnalysisRuleAssemblies />
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='debug|x64'">
+ <ClCompile>
+ <CallingConvention>Cdecl</CallingConvention>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <RuntimeTypeInfo>false</RuntimeTypeInfo>
+ <OpenMPSupport>false</OpenMPSupport>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <FloatingPointModel>Fast</FloatingPointModel>
+ <AdditionalOptions>/wd4995 /W4 /Oy- /EHsc -D_ITERATOR_DEBUG_LEVEL=0 /d2Zi+</AdditionalOptions>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>./../../VolumetricLightingTest;./../../../include;$(IntDir);./../../../external/NvFoundation/1.1/include;./{user:ShaderOutputPath};%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>_WIN64;_UNICODE;UNICODE;_WINDOWS;WIN32_LEAN_AND_MEAN;_CRT_SECURE_NO_DEPRECATE;NV_FOUNDATION_DLL=0;NV_PLATFORM_D3D11=1;NV_DEBUG=1;NV_CHECKED=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <ExceptionHandling>false</ExceptionHandling>
+ <WarningLevel>Level4</WarningLevel>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <PrecompiledHeaderFile></PrecompiledHeaderFile>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <AdditionalOptions>/MACHINE:x64 /SUBSYSTEM:WINDOWS /NOLOGO</AdditionalOptions>
+ <AdditionalDependencies>comctl32.lib;dxguid.lib;d3d11.lib;NvVolumetricLighting.win64.D.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <OutputFile>$(OutDir)VolumetricLightingTest.win64.D.exe</OutputFile>
+ <AdditionalLibraryDirectories>./../../../lib/win64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <ProgramDatabaseFile>$(OutDir)/VolumetricLightingTest.win64.D.exe.pdb</ProgramDatabaseFile>
+ <SubSystem>Windows</SubSystem>
+ <ImportLibrary>$(OutDir)$(TargetName).lib</ImportLibrary>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <TargetMachine>MachineX64</TargetMachine>
+ </Link>
+ <ResourceCompile>
+ </ResourceCompile>
+ <ProjectReference>
+ </ProjectReference>
+ </ItemDefinitionGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='profile|x64'">
+ <OutDir>./../../bin\</OutDir>
+ <IntDir>./x64/VolumetricLightingTest/profile\</IntDir>
+ <TargetExt>.exe</TargetExt>
+ <TargetName>VolumetricLightingTest.win64.P</TargetName>
+ <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules />
+ <CodeAnalysisRuleAssemblies />
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='profile|x64'">
+ <ClCompile>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <RuntimeTypeInfo>false</RuntimeTypeInfo>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <OpenMPSupport>false</OpenMPSupport>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <FloatingPointModel>Fast</FloatingPointModel>
+ <AdditionalOptions>/wd4995 /W4 /Oy- /EHsc /d2Zi+</AdditionalOptions>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>./../../VolumetricLightingTest;./../../../include;$(IntDir);./../../../external/NvFoundation/1.1/include;./{user:ShaderOutputPath};%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>_WIN64;_UNICODE;UNICODE;_WINDOWS;WIN32_LEAN_AND_MEAN;_CRT_SECURE_NO_DEPRECATE;NV_FOUNDATION_DLL=0;NV_PLATFORM_D3D11=1;NV_PROFILE=1;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <ExceptionHandling>false</ExceptionHandling>
+ <WarningLevel>Level4</WarningLevel>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <PrecompiledHeaderFile></PrecompiledHeaderFile>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <AdditionalOptions>/MACHINE:x64 /SUBSYSTEM:WINDOWS /NOLOGO</AdditionalOptions>
+ <AdditionalDependencies>comctl32.lib;dxguid.lib;d3d11.lib;NvVolumetricLighting.win64.P.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <OutputFile>$(OutDir)VolumetricLightingTest.win64.P.exe</OutputFile>
+ <AdditionalLibraryDirectories>./../../../lib/win64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <ProgramDatabaseFile>$(OutDir)/VolumetricLightingTest.win64.P.exe.pdb</ProgramDatabaseFile>
+ <SubSystem>Windows</SubSystem>
+ <ImportLibrary>$(OutDir)$(TargetName).lib</ImportLibrary>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <TargetMachine>MachineX64</TargetMachine>
+ </Link>
+ <ResourceCompile>
+ </ResourceCompile>
+ <ProjectReference>
+ </ProjectReference>
+ </ItemDefinitionGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='checked|x64'">
+ <OutDir>./../../bin\</OutDir>
+ <IntDir>./x64/VolumetricLightingTest/checked\</IntDir>
+ <TargetExt>.exe</TargetExt>
+ <TargetName>VolumetricLightingTest.win64.C</TargetName>
+ <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules />
+ <CodeAnalysisRuleAssemblies />
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='checked|x64'">
+ <ClCompile>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <RuntimeTypeInfo>false</RuntimeTypeInfo>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <OpenMPSupport>false</OpenMPSupport>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <FloatingPointModel>Fast</FloatingPointModel>
+ <AdditionalOptions>/wd4995 /W4 /Oy- /EHsc /d2Zi+</AdditionalOptions>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>./../../VolumetricLightingTest;./../../../include;$(IntDir);./../../../external/NvFoundation/1.1/include;./{user:ShaderOutputPath};%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>_WIN64;_UNICODE;UNICODE;_WINDOWS;WIN32_LEAN_AND_MEAN;_CRT_SECURE_NO_DEPRECATE;NV_FOUNDATION_DLL=0;NV_PLATFORM_D3D11=1;NV_CHECKED=1;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <ExceptionHandling>false</ExceptionHandling>
+ <WarningLevel>Level4</WarningLevel>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <PrecompiledHeaderFile></PrecompiledHeaderFile>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <AdditionalOptions>/MACHINE:x64 /SUBSYSTEM:WINDOWS /NOLOGO</AdditionalOptions>
+ <AdditionalDependencies>comctl32.lib;dxguid.lib;d3d11.lib;NvVolumetricLighting.win64.C.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <OutputFile>$(OutDir)VolumetricLightingTest.win64.C.exe</OutputFile>
+ <AdditionalLibraryDirectories>./../../../lib/win64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <ProgramDatabaseFile>$(OutDir)/VolumetricLightingTest.win64.C.exe.pdb</ProgramDatabaseFile>
+ <SubSystem>Windows</SubSystem>
+ <ImportLibrary>$(OutDir)$(TargetName).lib</ImportLibrary>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <TargetMachine>MachineX64</TargetMachine>
+ </Link>
+ <ResourceCompile>
+ </ResourceCompile>
+ <ProjectReference>
+ </ProjectReference>
+ </ItemDefinitionGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='release|x64'">
+ <OutDir>./../../bin\</OutDir>
+ <IntDir>./x64/VolumetricLightingTest/release\</IntDir>
+ <TargetExt>.exe</TargetExt>
+ <TargetName>VolumetricLightingTest.win64</TargetName>
+ <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules />
+ <CodeAnalysisRuleAssemblies />
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='release|x64'">
+ <ClCompile>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <RuntimeTypeInfo>false</RuntimeTypeInfo>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <OpenMPSupport>false</OpenMPSupport>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <FloatingPointModel>Fast</FloatingPointModel>
+ <AdditionalOptions>/wd4995 /W4 /Oy- /EHsc /d2Zi+</AdditionalOptions>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>./../../VolumetricLightingTest;./../../../include;$(IntDir);./../../../external/NvFoundation/1.1/include;./{user:ShaderOutputPath};%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>_WIN64;_UNICODE;UNICODE;_WINDOWS;WIN32_LEAN_AND_MEAN;_CRT_SECURE_NO_DEPRECATE;NV_FOUNDATION_DLL=0;NV_PLATFORM_D3D11=1;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <ExceptionHandling>false</ExceptionHandling>
+ <WarningLevel>Level4</WarningLevel>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <PrecompiledHeaderFile></PrecompiledHeaderFile>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <AdditionalOptions>/MACHINE:x64 /SUBSYSTEM:WINDOWS /NOLOGO</AdditionalOptions>
+ <AdditionalDependencies>comctl32.lib;dxguid.lib;d3d11.lib;NvVolumetricLighting.win64.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <OutputFile>$(OutDir)VolumetricLightingTest.win64.exe</OutputFile>
+ <AdditionalLibraryDirectories>./../../../lib/win64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <ProgramDatabaseFile>$(OutDir)/VolumetricLightingTest.win64.exe.pdb</ProgramDatabaseFile>
+ <SubSystem>Windows</SubSystem>
+ <ImportLibrary>$(OutDir)$(TargetName).lib</ImportLibrary>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <TargetMachine>MachineX64</TargetMachine>
+ </Link>
+ <ResourceCompile>
+ </ResourceCompile>
+ <ProjectReference>
+ </ProjectReference>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClInclude Include="..\..\VolumetricLightingTest\common.h">
+ </ClInclude>
+ <ClInclude Include="..\..\VolumetricLightingTest\scene.h">
+ </ClInclude>
+ <ClCompile Include="..\..\VolumetricLightingTest\main.cpp">
+ </ClCompile>
+ <ClCompile Include="..\..\VolumetricLightingTest\scene.cpp">
+ </ClCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="..\..\VolumetricLightingTest\d3d11\compiled_shaders_d3d11.h">
+ </ClInclude>
+ <ClInclude Include="..\..\VolumetricLightingTest\d3d11\d3d11_util.h">
+ </ClInclude>
+ <ClInclude Include="..\..\VolumetricLightingTest\d3d11\DeviceManager.h">
+ </ClInclude>
+ <ClCompile Include="..\..\VolumetricLightingTest\d3d11\compiled_shaders_d3d11.cpp">
+ </ClCompile>
+ <ClCompile Include="..\..\VolumetricLightingTest\d3d11\d3d11_main.cpp">
+ </ClCompile>
+ <ClCompile Include="..\..\VolumetricLightingTest\d3d11\d3d11_util.cpp">
+ </ClCompile>
+ <ClCompile Include="..\..\VolumetricLightingTest\d3d11\DeviceManager.cpp">
+ </ClCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <CustomBuild Include="..\..\VolumetricLightingTest\shaders\quad_VS.hlsl">
+ <Command Condition="'$(Configuration)|$(Platform)'=='debug|x64'">"../../VolumetricLightingTest/../../tools/shadermux.exe" -l 0 -w -f -o "$(IntDir)shaders" -p d3d11 -c "/Tvs_5_0" ..\..\VolumetricLightingTest\shaders\quad_VS.hlsl</Command>
+ <Message Condition="'$(Configuration)|$(Platform)'=='debug|x64'">Precompiling shader permutations for %(Identity)</Message>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='debug|x64'">$(IntDir)shaders/quad_VS.mux.h;$(IntDir)shaders/quad_VS.mux.bytecode;</Outputs>
+ <Command Condition="'$(Configuration)|$(Platform)'=='profile|x64'">"../../VolumetricLightingTest/../../tools/shadermux.exe" -l 0 -w -f -o "$(IntDir)shaders" -p d3d11 -c "/Tvs_5_0" ..\..\VolumetricLightingTest\shaders\quad_VS.hlsl</Command>
+ <Message Condition="'$(Configuration)|$(Platform)'=='profile|x64'">Precompiling shader permutations for %(Identity)</Message>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='profile|x64'">$(IntDir)shaders/quad_VS.mux.h;$(IntDir)shaders/quad_VS.mux.bytecode;</Outputs>
+ <Command Condition="'$(Configuration)|$(Platform)'=='checked|x64'">"../../VolumetricLightingTest/../../tools/shadermux.exe" -l 0 -w -f -o "$(IntDir)shaders" -p d3d11 -c "/Tvs_5_0" ..\..\VolumetricLightingTest\shaders\quad_VS.hlsl</Command>
+ <Message Condition="'$(Configuration)|$(Platform)'=='checked|x64'">Precompiling shader permutations for %(Identity)</Message>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='checked|x64'">$(IntDir)shaders/quad_VS.mux.h;$(IntDir)shaders/quad_VS.mux.bytecode;</Outputs>
+ <Command Condition="'$(Configuration)|$(Platform)'=='release|x64'">"../../VolumetricLightingTest/../../tools/shadermux.exe" -l 0 -w -f -o "$(IntDir)shaders" -p d3d11 -c "/Tvs_5_0" ..\..\VolumetricLightingTest\shaders\quad_VS.hlsl</Command>
+ <Message Condition="'$(Configuration)|$(Platform)'=='release|x64'">Precompiling shader permutations for %(Identity)</Message>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='release|x64'">$(IntDir)shaders/quad_VS.mux.h;$(IntDir)shaders/quad_VS.mux.bytecode;</Outputs>
+ </CustomBuild>
+ <CustomBuild Include="..\..\VolumetricLightingTest\shaders\scene_VS.hlsl">
+ <Command Condition="'$(Configuration)|$(Platform)'=='debug|x64'">"../../VolumetricLightingTest/../../tools/shadermux.exe" -l 0 -w -f -o "$(IntDir)shaders" -p d3d11 -c "/Tvs_5_0" ..\..\VolumetricLightingTest\shaders\scene_VS.hlsl</Command>
+ <Message Condition="'$(Configuration)|$(Platform)'=='debug|x64'">Precompiling shader permutations for %(Identity)</Message>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='debug|x64'">$(IntDir)shaders/scene_VS.mux.h;$(IntDir)shaders/scene_VS.mux.bytecode;</Outputs>
+ <Command Condition="'$(Configuration)|$(Platform)'=='profile|x64'">"../../VolumetricLightingTest/../../tools/shadermux.exe" -l 0 -w -f -o "$(IntDir)shaders" -p d3d11 -c "/Tvs_5_0" ..\..\VolumetricLightingTest\shaders\scene_VS.hlsl</Command>
+ <Message Condition="'$(Configuration)|$(Platform)'=='profile|x64'">Precompiling shader permutations for %(Identity)</Message>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='profile|x64'">$(IntDir)shaders/scene_VS.mux.h;$(IntDir)shaders/scene_VS.mux.bytecode;</Outputs>
+ <Command Condition="'$(Configuration)|$(Platform)'=='checked|x64'">"../../VolumetricLightingTest/../../tools/shadermux.exe" -l 0 -w -f -o "$(IntDir)shaders" -p d3d11 -c "/Tvs_5_0" ..\..\VolumetricLightingTest\shaders\scene_VS.hlsl</Command>
+ <Message Condition="'$(Configuration)|$(Platform)'=='checked|x64'">Precompiling shader permutations for %(Identity)</Message>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='checked|x64'">$(IntDir)shaders/scene_VS.mux.h;$(IntDir)shaders/scene_VS.mux.bytecode;</Outputs>
+ <Command Condition="'$(Configuration)|$(Platform)'=='release|x64'">"../../VolumetricLightingTest/../../tools/shadermux.exe" -l 0 -w -f -o "$(IntDir)shaders" -p d3d11 -c "/Tvs_5_0" ..\..\VolumetricLightingTest\shaders\scene_VS.hlsl</Command>
+ <Message Condition="'$(Configuration)|$(Platform)'=='release|x64'">Precompiling shader permutations for %(Identity)</Message>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='release|x64'">$(IntDir)shaders/scene_VS.mux.h;$(IntDir)shaders/scene_VS.mux.bytecode;</Outputs>
+ </CustomBuild>
+ <CustomBuild Include="..\..\VolumetricLightingTest\shaders\scene_GS.hlsl">
+ <Command Condition="'$(Configuration)|$(Platform)'=='debug|x64'">"../../VolumetricLightingTest/../../tools/shadermux.exe" -l 0 -w -f -o "$(IntDir)shaders" -p d3d11 -c "/Tgs_5_0" ..\..\VolumetricLightingTest\shaders\scene_GS.hlsl</Command>
+ <Message Condition="'$(Configuration)|$(Platform)'=='debug|x64'">Precompiling shader permutations for %(Identity)</Message>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='debug|x64'">$(IntDir)shaders/scene_GS.mux.h;$(IntDir)shaders/scene_GS.mux.bytecode;</Outputs>
+ <Command Condition="'$(Configuration)|$(Platform)'=='profile|x64'">"../../VolumetricLightingTest/../../tools/shadermux.exe" -l 0 -w -f -o "$(IntDir)shaders" -p d3d11 -c "/Tgs_5_0" ..\..\VolumetricLightingTest\shaders\scene_GS.hlsl</Command>
+ <Message Condition="'$(Configuration)|$(Platform)'=='profile|x64'">Precompiling shader permutations for %(Identity)</Message>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='profile|x64'">$(IntDir)shaders/scene_GS.mux.h;$(IntDir)shaders/scene_GS.mux.bytecode;</Outputs>
+ <Command Condition="'$(Configuration)|$(Platform)'=='checked|x64'">"../../VolumetricLightingTest/../../tools/shadermux.exe" -l 0 -w -f -o "$(IntDir)shaders" -p d3d11 -c "/Tgs_5_0" ..\..\VolumetricLightingTest\shaders\scene_GS.hlsl</Command>
+ <Message Condition="'$(Configuration)|$(Platform)'=='checked|x64'">Precompiling shader permutations for %(Identity)</Message>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='checked|x64'">$(IntDir)shaders/scene_GS.mux.h;$(IntDir)shaders/scene_GS.mux.bytecode;</Outputs>
+ <Command Condition="'$(Configuration)|$(Platform)'=='release|x64'">"../../VolumetricLightingTest/../../tools/shadermux.exe" -l 0 -w -f -o "$(IntDir)shaders" -p d3d11 -c "/Tgs_5_0" ..\..\VolumetricLightingTest\shaders\scene_GS.hlsl</Command>
+ <Message Condition="'$(Configuration)|$(Platform)'=='release|x64'">Precompiling shader permutations for %(Identity)</Message>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='release|x64'">$(IntDir)shaders/scene_GS.mux.h;$(IntDir)shaders/scene_GS.mux.bytecode;</Outputs>
+ </CustomBuild>
+ <CustomBuild Include="..\..\VolumetricLightingTest\shaders\post_PS.hlsl">
+ <Command Condition="'$(Configuration)|$(Platform)'=='debug|x64'">"../../VolumetricLightingTest/../../tools/shadermux.exe" -l 0 -w -f -o "$(IntDir)shaders" -p d3d11 -c "/Tps_5_0" ..\..\VolumetricLightingTest\shaders\post_PS.hlsl</Command>
+ <Message Condition="'$(Configuration)|$(Platform)'=='debug|x64'">Precompiling shader permutations for %(Identity)</Message>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='debug|x64'">$(IntDir)shaders/post_PS.mux.h;$(IntDir)shaders/post_PS.mux.bytecode;</Outputs>
+ <Command Condition="'$(Configuration)|$(Platform)'=='profile|x64'">"../../VolumetricLightingTest/../../tools/shadermux.exe" -l 0 -w -f -o "$(IntDir)shaders" -p d3d11 -c "/Tps_5_0" ..\..\VolumetricLightingTest\shaders\post_PS.hlsl</Command>
+ <Message Condition="'$(Configuration)|$(Platform)'=='profile|x64'">Precompiling shader permutations for %(Identity)</Message>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='profile|x64'">$(IntDir)shaders/post_PS.mux.h;$(IntDir)shaders/post_PS.mux.bytecode;</Outputs>
+ <Command Condition="'$(Configuration)|$(Platform)'=='checked|x64'">"../../VolumetricLightingTest/../../tools/shadermux.exe" -l 0 -w -f -o "$(IntDir)shaders" -p d3d11 -c "/Tps_5_0" ..\..\VolumetricLightingTest\shaders\post_PS.hlsl</Command>
+ <Message Condition="'$(Configuration)|$(Platform)'=='checked|x64'">Precompiling shader permutations for %(Identity)</Message>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='checked|x64'">$(IntDir)shaders/post_PS.mux.h;$(IntDir)shaders/post_PS.mux.bytecode;</Outputs>
+ <Command Condition="'$(Configuration)|$(Platform)'=='release|x64'">"../../VolumetricLightingTest/../../tools/shadermux.exe" -l 0 -w -f -o "$(IntDir)shaders" -p d3d11 -c "/Tps_5_0" ..\..\VolumetricLightingTest\shaders\post_PS.hlsl</Command>
+ <Message Condition="'$(Configuration)|$(Platform)'=='release|x64'">Precompiling shader permutations for %(Identity)</Message>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='release|x64'">$(IntDir)shaders/post_PS.mux.h;$(IntDir)shaders/post_PS.mux.bytecode;</Outputs>
+ </CustomBuild>
+ <CustomBuild Include="..\..\VolumetricLightingTest\shaders\scene_PS.hlsl">
+ <Command Condition="'$(Configuration)|$(Platform)'=='debug|x64'">"../../VolumetricLightingTest/../../tools/shadermux.exe" -l 0 -w -f -o "$(IntDir)shaders" -p d3d11 -c "/Tps_5_0" ..\..\VolumetricLightingTest\shaders\scene_PS.hlsl</Command>
+ <Message Condition="'$(Configuration)|$(Platform)'=='debug|x64'">Precompiling shader permutations for %(Identity)</Message>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='debug|x64'">$(IntDir)shaders/scene_PS.mux.h;$(IntDir)shaders/scene_PS.mux.bytecode;</Outputs>
+ <Command Condition="'$(Configuration)|$(Platform)'=='profile|x64'">"../../VolumetricLightingTest/../../tools/shadermux.exe" -l 0 -w -f -o "$(IntDir)shaders" -p d3d11 -c "/Tps_5_0" ..\..\VolumetricLightingTest\shaders\scene_PS.hlsl</Command>
+ <Message Condition="'$(Configuration)|$(Platform)'=='profile|x64'">Precompiling shader permutations for %(Identity)</Message>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='profile|x64'">$(IntDir)shaders/scene_PS.mux.h;$(IntDir)shaders/scene_PS.mux.bytecode;</Outputs>
+ <Command Condition="'$(Configuration)|$(Platform)'=='checked|x64'">"../../VolumetricLightingTest/../../tools/shadermux.exe" -l 0 -w -f -o "$(IntDir)shaders" -p d3d11 -c "/Tps_5_0" ..\..\VolumetricLightingTest\shaders\scene_PS.hlsl</Command>
+ <Message Condition="'$(Configuration)|$(Platform)'=='checked|x64'">Precompiling shader permutations for %(Identity)</Message>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='checked|x64'">$(IntDir)shaders/scene_PS.mux.h;$(IntDir)shaders/scene_PS.mux.bytecode;</Outputs>
+ <Command Condition="'$(Configuration)|$(Platform)'=='release|x64'">"../../VolumetricLightingTest/../../tools/shadermux.exe" -l 0 -w -f -o "$(IntDir)shaders" -p d3d11 -c "/Tps_5_0" ..\..\VolumetricLightingTest\shaders\scene_PS.hlsl</Command>
+ <Message Condition="'$(Configuration)|$(Platform)'=='release|x64'">Precompiling shader permutations for %(Identity)</Message>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='release|x64'">$(IntDir)shaders/scene_PS.mux.h;$(IntDir)shaders/scene_PS.mux.bytecode;</Outputs>
+ </CustomBuild>
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets"></ImportGroup>
+</Project>
diff --git a/samples/build/vs2013/VolumetricLightingTest.vcxproj.filters b/samples/build/vs2013/VolumetricLightingTest.vcxproj.filters
new file mode 100644
index 0000000..845b330
--- /dev/null
+++ b/samples/build/vs2013/VolumetricLightingTest.vcxproj.filters
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="src"><!-- -->
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="..\..\VolumetricLightingTest\common.h">
+ <Filter>src</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\VolumetricLightingTest\scene.h">
+ <Filter>src</Filter>
+ </ClInclude>
+ <ClCompile Include="..\..\VolumetricLightingTest\main.cpp">
+ <Filter>src</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\VolumetricLightingTest\scene.cpp">
+ <Filter>src</Filter>
+ </ClCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <Filter Include="src (platform)"><!-- -->
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="..\..\VolumetricLightingTest\d3d11\compiled_shaders_d3d11.h">
+ <Filter>src (platform)</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\VolumetricLightingTest\d3d11\d3d11_util.h">
+ <Filter>src (platform)</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\VolumetricLightingTest\d3d11\DeviceManager.h">
+ <Filter>src (platform)</Filter>
+ </ClInclude>
+ <ClCompile Include="..\..\VolumetricLightingTest\d3d11\compiled_shaders_d3d11.cpp">
+ <Filter>src (platform)</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\VolumetricLightingTest\d3d11\d3d11_main.cpp">
+ <Filter>src (platform)</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\VolumetricLightingTest\d3d11\d3d11_util.cpp">
+ <Filter>src (platform)</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\VolumetricLightingTest\d3d11\DeviceManager.cpp">
+ <Filter>src (platform)</Filter>
+ </ClCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <Filter Include="src (shaders)"><!-- Shadermux -->
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <CustomBuild Include="..\..\VolumetricLightingTest\shaders\quad_VS.hlsl">
+ <Filter>src (shaders)</Filter>
+ </CustomBuild>
+ <CustomBuild Include="..\..\VolumetricLightingTest\shaders\scene_VS.hlsl">
+ <Filter>src (shaders)</Filter>
+ </CustomBuild>
+ <CustomBuild Include="..\..\VolumetricLightingTest\shaders\scene_GS.hlsl">
+ <Filter>src (shaders)</Filter>
+ </CustomBuild>
+ <CustomBuild Include="..\..\VolumetricLightingTest\shaders\post_PS.hlsl">
+ <Filter>src (shaders)</Filter>
+ </CustomBuild>
+ <CustomBuild Include="..\..\VolumetricLightingTest\shaders\scene_PS.hlsl">
+ <Filter>src (shaders)</Filter>
+ </CustomBuild>
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/samples/build/vs2013/VolumetricLighting_Samples.sln b/samples/build/vs2013/VolumetricLighting_Samples.sln
new file mode 100644
index 0000000..7b2b63d
--- /dev/null
+++ b/samples/build/vs2013/VolumetricLighting_Samples.sln
@@ -0,0 +1,30 @@
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 2013
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "VolumetricLightingTest", "./VolumetricLightingTest.vcxproj", "{00F4B5B4-B6F4-3D3F-6500-2878F07A3100}"
+ ProjectSection(ProjectDependencies) = postProject
+ EndProjectSection
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ checked|x64 = checked|x64
+ debug|x64 = debug|x64
+ profile|x64 = profile|x64
+ release|x64 = release|x64
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {00F4B5B4-B6F4-3D3F-6500-2878F07A3100}.checked|x64.ActiveCfg = checked|x64
+ {00F4B5B4-B6F4-3D3F-6500-2878F07A3100}.checked|x64.Build.0 = checked|x64
+ {00F4B5B4-B6F4-3D3F-6500-2878F07A3100}.debug|x64.ActiveCfg = debug|x64
+ {00F4B5B4-B6F4-3D3F-6500-2878F07A3100}.debug|x64.Build.0 = debug|x64
+ {00F4B5B4-B6F4-3D3F-6500-2878F07A3100}.profile|x64.ActiveCfg = profile|x64
+ {00F4B5B4-B6F4-3D3F-6500-2878F07A3100}.profile|x64.Build.0 = profile|x64
+ {00F4B5B4-B6F4-3D3F-6500-2878F07A3100}.release|x64.ActiveCfg = release|x64
+ {00F4B5B4-B6F4-3D3F-6500-2878F07A3100}.release|x64.Build.0 = release|x64
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ EndGlobalSection
+ GlobalSection(ExtensibilityAddins) = postSolution
+ EndGlobalSection
+ GlobalSection(NestedProjects) = preSolution
+ EndGlobalSection
+EndGlobal