diff options
| author | Jason Maskell <[email protected]> | 2016-05-12 10:58:15 +0200 |
|---|---|---|
| committer | Jason Maskell <[email protected]> | 2016-05-12 10:58:15 +0200 |
| commit | 72b21c69e32c73abf3a18b0e962746e64faebba4 (patch) | |
| tree | cd22b1b298bc865c3ae6037e8eb89a64a94203ea /sample/opengl | |
| parent | Merge branch 'master' of https://github.com/NVIDIAGameWorks/WaveWorks (diff) | |
| download | waveworks_archive-72b21c69e32c73abf3a18b0e962746e64faebba4.tar.xz waveworks_archive-72b21c69e32c73abf3a18b0e962746e64faebba4.zip | |
Restructuring starts. Got some initial CMake problems sorted. Need to extend.
Diffstat (limited to 'sample/opengl')
19 files changed, 0 insertions, 2831 deletions
diff --git a/sample/opengl/AntTweakBar/AntTweakBar.dll b/sample/opengl/AntTweakBar/AntTweakBar.dll Binary files differdeleted file mode 100644 index eeeff2a..0000000 --- a/sample/opengl/AntTweakBar/AntTweakBar.dll +++ /dev/null diff --git a/sample/opengl/AntTweakBar/AntTweakBar.h b/sample/opengl/AntTweakBar/AntTweakBar.h deleted file mode 100644 index a1cf277..0000000 --- a/sample/opengl/AntTweakBar/AntTweakBar.h +++ /dev/null @@ -1,378 +0,0 @@ -// ---------------------------------------------------------------------------- -// -// @file AntTweakBar.h -// -// @brief AntTweakBar is a light and intuitive graphical user interface -// that can be readily integrated into OpenGL and DirectX -// applications in order to interactively tweak parameters. -// -// @author Philippe Decaudin -// -// @doc http://anttweakbar.sourceforge.net/doc -// -// @license This file is part of the AntTweakBar library. -// AntTweakBar is a free software released under the zlib license. -// For conditions of distribution and use, see License.txt -// -// ---------------------------------------------------------------------------- - - -#if !defined TW_INCLUDED -#define TW_INCLUDED - -#include <stddef.h> - -#define TW_VERSION 116 // Version Mmm : M=Major mm=minor (e.g., 102 is version 1.02) - - -#ifdef __cplusplus -# if defined(_MSC_VER) -# pragma warning(push) -# pragma warning(disable: 4995 4530) -# include <string> -# pragma warning(pop) -# else -# include <string> -# endif - extern "C" { -#endif // __cplusplus - - -// ---------------------------------------------------------------------------- -// OS specific definitions -// ---------------------------------------------------------------------------- - -#if (defined(_WIN32) || defined(_WIN64)) && !defined(TW_STATIC) -# define TW_CALL __stdcall -# define TW_CDECL_CALL __cdecl -# define TW_EXPORT_API __declspec(dllexport) -# define TW_IMPORT_API __declspec(dllimport) -#else -# define TW_CALL -# define TW_CDECL_CALL -# define TW_EXPORT_API -# define TW_IMPORT_API -#endif - -#if defined TW_EXPORTS -# define TW_API TW_EXPORT_API -#elif defined TW_STATIC -# define TW_API -# if defined(_MSC_VER) && !defined(TW_NO_LIB_PRAGMA) -# ifdef _WIN64 -# pragma comment(lib, "AntTweakBarStatic64") -# else -# pragma comment(lib, "AntTweakBarStatic") -# endif -# endif -#else -# define TW_API TW_IMPORT_API -# if defined(_MSC_VER) && !defined(TW_NO_LIB_PRAGMA) -# ifdef _WIN64 -# pragma comment(lib, "AntTweakBar64") -# else -# pragma comment(lib, "AntTweakBar") -# endif -# endif -#endif - - -// ---------------------------------------------------------------------------- -// Bar functions and definitions -// ---------------------------------------------------------------------------- - -typedef struct CTwBar TwBar; // structure CTwBar is not exposed. - -TW_API TwBar * TW_CALL TwNewBar(const char *barName); -TW_API int TW_CALL TwDeleteBar(TwBar *bar); -TW_API int TW_CALL TwDeleteAllBars(); -TW_API int TW_CALL TwSetTopBar(const TwBar *bar); -TW_API TwBar * TW_CALL TwGetTopBar(); -TW_API int TW_CALL TwSetBottomBar(const TwBar *bar); -TW_API TwBar * TW_CALL TwGetBottomBar(); -TW_API const char * TW_CALL TwGetBarName(const TwBar *bar); -TW_API int TW_CALL TwGetBarCount(); -TW_API TwBar * TW_CALL TwGetBarByIndex(int barIndex); -TW_API TwBar * TW_CALL TwGetBarByName(const char *barName); -TW_API int TW_CALL TwRefreshBar(TwBar *bar); - -// ---------------------------------------------------------------------------- -// Var functions and definitions -// ---------------------------------------------------------------------------- - -typedef enum ETwType -{ - TW_TYPE_UNDEF = 0, -#ifdef __cplusplus - TW_TYPE_BOOLCPP = 1, -#endif // __cplusplus - TW_TYPE_BOOL8 = 2, - TW_TYPE_BOOL16, - TW_TYPE_BOOL32, - TW_TYPE_CHAR, - TW_TYPE_INT8, - TW_TYPE_UINT8, - TW_TYPE_INT16, - TW_TYPE_UINT16, - TW_TYPE_INT32, - TW_TYPE_UINT32, - TW_TYPE_FLOAT, - TW_TYPE_DOUBLE, - TW_TYPE_COLOR32, // 32 bits color. Order is RGBA if API is OpenGL or Direct3D10, and inversed if API is Direct3D9 (can be modified by defining 'colorOrder=...', see doc) - TW_TYPE_COLOR3F, // 3 floats color. Order is RGB. - TW_TYPE_COLOR4F, // 4 floats color. Order is RGBA. - TW_TYPE_CDSTRING, // Null-terminated C Dynamic String (pointer to an array of char dynamically allocated with malloc/realloc/strdup) -#ifdef __cplusplus -# if defined(_MSC_VER) && (_MSC_VER == 1600) - TW_TYPE_STDSTRING = (0x2ffe0000+sizeof(std::string)), // VS2010 C++ STL string (std::string) -# else - TW_TYPE_STDSTRING = (0x2fff0000+sizeof(std::string)), // C++ STL string (std::string) -# endif -#endif // __cplusplus - TW_TYPE_QUAT4F = TW_TYPE_CDSTRING+2, // 4 floats encoding a quaternion {qx,qy,qz,qs} - TW_TYPE_QUAT4D, // 4 doubles encoding a quaternion {qx,qy,qz,qs} - TW_TYPE_DIR3F, // direction vector represented by 3 floats - TW_TYPE_DIR3D // direction vector represented by 3 doubles -} TwType; -#define TW_TYPE_CSSTRING(n) ((TwType)(0x30000000+((n)&0xfffffff))) // Null-terminated C Static String of size n (defined as char[n], with n<2^28) - -typedef void (TW_CALL * TwSetVarCallback)(const void *value, void *clientData); -typedef void (TW_CALL * TwGetVarCallback)(void *value, void *clientData); -typedef void (TW_CALL * TwButtonCallback)(void *clientData); - -TW_API int TW_CALL TwAddVarRW(TwBar *bar, const char *name, TwType type, void *var, const char *def); -TW_API int TW_CALL TwAddVarRO(TwBar *bar, const char *name, TwType type, const void *var, const char *def); -TW_API int TW_CALL TwAddVarCB(TwBar *bar, const char *name, TwType type, TwSetVarCallback setCallback, TwGetVarCallback getCallback, void *clientData, const char *def); -TW_API int TW_CALL TwAddButton(TwBar *bar, const char *name, TwButtonCallback callback, void *clientData, const char *def); -TW_API int TW_CALL TwAddSeparator(TwBar *bar, const char *name, const char *def); -TW_API int TW_CALL TwRemoveVar(TwBar *bar, const char *name); -TW_API int TW_CALL TwRemoveAllVars(TwBar *bar); - -typedef struct CTwEnumVal -{ - int Value; - const char * Label; -} TwEnumVal; -typedef struct CTwStructMember -{ - const char * Name; - TwType Type; - size_t Offset; - const char * DefString; -} TwStructMember; -typedef void (TW_CALL * TwSummaryCallback)(char *summaryString, size_t summaryMaxLength, const void *value, void *clientData); - -TW_API int TW_CALL TwDefine(const char *def); -TW_API TwType TW_CALL TwDefineEnum(const char *name, const TwEnumVal *enumValues, unsigned int nbValues); -TW_API TwType TW_CALL TwDefineEnumFromString(const char *name, const char *enumString); -TW_API TwType TW_CALL TwDefineStruct(const char *name, const TwStructMember *structMembers, unsigned int nbMembers, size_t structSize, TwSummaryCallback summaryCallback, void *summaryClientData); - -typedef void (TW_CALL * TwCopyCDStringToClient)(char **destinationClientStringPtr, const char *sourceString); -TW_API void TW_CALL TwCopyCDStringToClientFunc(TwCopyCDStringToClient copyCDStringFunc); -TW_API void TW_CALL TwCopyCDStringToLibrary(char **destinationLibraryStringPtr, const char *sourceClientString); -#ifdef __cplusplus -typedef void (TW_CALL * TwCopyStdStringToClient)(std::string& destinationClientString, const std::string& sourceString); -TW_API void TW_CALL TwCopyStdStringToClientFunc(TwCopyStdStringToClient copyStdStringToClientFunc); -TW_API void TW_CALL TwCopyStdStringToLibrary(std::string& destinationLibraryString, const std::string& sourceClientString); -#endif // __cplusplus - -typedef enum ETwParamValueType -{ - TW_PARAM_INT32, - TW_PARAM_FLOAT, - TW_PARAM_DOUBLE, - TW_PARAM_CSTRING // Null-terminated array of char (ie, c-string) -} TwParamValueType; -TW_API int TW_CALL TwGetParam(TwBar *bar, const char *varName, const char *paramName, TwParamValueType paramValueType, unsigned int outValueMaxCount, void *outValues); -TW_API int TW_CALL TwSetParam(TwBar *bar, const char *varName, const char *paramName, TwParamValueType paramValueType, unsigned int inValueCount, const void *inValues); - - -// ---------------------------------------------------------------------------- -// Management functions and definitions -// ---------------------------------------------------------------------------- - -typedef enum ETwGraphAPI -{ - TW_OPENGL = 1, - TW_DIRECT3D9 = 2, - TW_DIRECT3D10 = 3, - TW_DIRECT3D11 = 4, - TW_OPENGL_CORE = 5 -} TwGraphAPI; - -TW_API int TW_CALL TwInit(TwGraphAPI graphAPI, void *device); -TW_API int TW_CALL TwTerminate(); - -TW_API int TW_CALL TwDraw(); -TW_API int TW_CALL TwWindowSize(int width, int height); - -TW_API int TW_CALL TwSetCurrentWindow(int windowID); // multi-windows support -TW_API int TW_CALL TwGetCurrentWindow(); -TW_API int TW_CALL TwWindowExists(int windowID); - -typedef enum ETwKeyModifier -{ - TW_KMOD_NONE = 0x0000, // same codes as SDL keysym.mod - TW_KMOD_SHIFT = 0x0003, - TW_KMOD_CTRL = 0x00c0, - TW_KMOD_ALT = 0x0100, - TW_KMOD_META = 0x0c00 -} TwKeyModifier; -typedef enum EKeySpecial -{ - TW_KEY_BACKSPACE = '\b', - TW_KEY_TAB = '\t', - TW_KEY_CLEAR = 0x0c, - TW_KEY_RETURN = '\r', - TW_KEY_PAUSE = 0x13, - TW_KEY_ESCAPE = 0x1b, - TW_KEY_SPACE = ' ', - TW_KEY_DELETE = 0x7f, - TW_KEY_UP = 273, // same codes and order as SDL 1.2 keysym.sym - TW_KEY_DOWN, - TW_KEY_RIGHT, - TW_KEY_LEFT, - TW_KEY_INSERT, - TW_KEY_HOME, - TW_KEY_END, - TW_KEY_PAGE_UP, - TW_KEY_PAGE_DOWN, - TW_KEY_F1, - TW_KEY_F2, - TW_KEY_F3, - TW_KEY_F4, - TW_KEY_F5, - TW_KEY_F6, - TW_KEY_F7, - TW_KEY_F8, - TW_KEY_F9, - TW_KEY_F10, - TW_KEY_F11, - TW_KEY_F12, - TW_KEY_F13, - TW_KEY_F14, - TW_KEY_F15, - TW_KEY_LAST -} TwKeySpecial; - -TW_API int TW_CALL TwKeyPressed(int key, int modifiers); -TW_API int TW_CALL TwKeyTest(int key, int modifiers); - -typedef enum ETwMouseAction -{ - TW_MOUSE_RELEASED, - TW_MOUSE_PRESSED -} TwMouseAction; -typedef enum ETwMouseButtonID -{ - TW_MOUSE_LEFT = 1, // same code as SDL_BUTTON_LEFT - TW_MOUSE_MIDDLE = 2, // same code as SDL_BUTTON_MIDDLE - TW_MOUSE_RIGHT = 3 // same code as SDL_BUTTON_RIGHT -} TwMouseButtonID; - -TW_API int TW_CALL TwMouseButton(TwMouseAction action, TwMouseButtonID button); -TW_API int TW_CALL TwMouseMotion(int mouseX, int mouseY); -TW_API int TW_CALL TwMouseWheel(int pos); - -TW_API const char * TW_CALL TwGetLastError(); -typedef void (TW_CALL * TwErrorHandler)(const char *errorMessage); -TW_API void TW_CALL TwHandleErrors(TwErrorHandler errorHandler); - - -// ---------------------------------------------------------------------------- -// Helper functions to translate events from some common window management -// frameworks to AntTweakBar. -// They call TwKeyPressed, TwMouse* and TwWindowSize for you (implemented in -// files TwEventWin.c TwEventSDL*.c TwEventGLFW.c TwEventGLUT.c) -// ---------------------------------------------------------------------------- - -// For Windows message proc -#ifndef _W64 // Microsoft specific (detection of 64 bits portability issues) -# define _W64 -#endif // _W64 -#ifdef _WIN64 - TW_API int TW_CALL TwEventWin(void *wnd, unsigned int msg, unsigned __int64 _W64 wParam, __int64 _W64 lParam); -#else - TW_API int TW_CALL TwEventWin(void *wnd, unsigned int msg, unsigned int _W64 wParam, int _W64 lParam); -#endif -#define TwEventWin32 TwEventWin // For compatibility with AntTweakBar versions prior to 1.11 - -// For libSDL event loop -TW_API int TW_CALL TwEventSDL(const void *sdlEvent, unsigned char sdlMajorVersion, unsigned char sdlMinorVersion); - -// For GLFW event callbacks -// You should define GLFW_CDECL before including AntTweakBar.h if your version of GLFW uses cdecl calling convensions -#ifdef GLFW_CDECL - TW_API int TW_CDECL_CALL TwEventMouseButtonGLFWcdecl(int glfwButton, int glfwAction); - TW_API int TW_CDECL_CALL TwEventKeyGLFWcdecl(int glfwKey, int glfwAction); - TW_API int TW_CDECL_CALL TwEventCharGLFWcdecl(int glfwChar, int glfwAction); - TW_API int TW_CDECL_CALL TwEventMousePosGLFWcdecl(int mouseX, int mouseY); - TW_API int TW_CDECL_CALL TwEventMouseWheelGLFWcdecl(int wheelPos); -# define TwEventMouseButtonGLFW TwEventMouseButtonGLFWcdecl -# define TwEventKeyGLFW TwEventKeyGLFWcdecl -# define TwEventCharGLFW TwEventCharGLFWcdecl -# define TwEventMousePosGLFW TwEventMousePosGLFWcdecl -# define TwEventMouseWheelGLFW TwEventMouseWheelGLFWcdecl -#else - TW_API int TW_CALL TwEventMouseButtonGLFW(int glfwButton, int glfwAction); - TW_API int TW_CALL TwEventKeyGLFW(int glfwKey, int glfwAction); - TW_API int TW_CALL TwEventCharGLFW(int glfwChar, int glfwAction); -# define TwEventMousePosGLFW TwMouseMotion -# define TwEventMouseWheelGLFW TwMouseWheel -#endif - -// For GLUT event callbacks (Windows calling convention for GLUT callbacks is cdecl) -#if defined(_WIN32) || defined(_WIN64) -# define TW_GLUT_CALL TW_CDECL_CALL -#else -# define TW_GLUT_CALL -#endif -TW_API int TW_GLUT_CALL TwEventMouseButtonGLUT(int glutButton, int glutState, int mouseX, int mouseY); -TW_API int TW_GLUT_CALL TwEventMouseMotionGLUT(int mouseX, int mouseY); -TW_API int TW_GLUT_CALL TwEventKeyboardGLUT(unsigned char glutKey, int mouseX, int mouseY); -TW_API int TW_GLUT_CALL TwEventSpecialGLUT(int glutKey, int mouseX, int mouseY); -TW_API int TW_CALL TwGLUTModifiersFunc(int (TW_CALL *glutGetModifiersFunc)(void)); -typedef void (TW_GLUT_CALL *GLUTmousebuttonfun)(int glutButton, int glutState, int mouseX, int mouseY); -typedef void (TW_GLUT_CALL *GLUTmousemotionfun)(int mouseX, int mouseY); -typedef void (TW_GLUT_CALL *GLUTkeyboardfun)(unsigned char glutKey, int mouseX, int mouseY); -typedef void (TW_GLUT_CALL *GLUTspecialfun)(int glutKey, int mouseX, int mouseY); - -// For SFML event loop -TW_API int TW_CALL TwEventSFML(const void *sfmlEvent, unsigned char sfmlMajorVersion, unsigned char sfmlMinorVersion); - -// For X11 event loop -#if defined(_UNIX) - TW_API int TW_CDECL_CALL TwEventX11(void *xevent); -#endif - -// ---------------------------------------------------------------------------- -// Make sure the types have the right sizes -// ---------------------------------------------------------------------------- - -#define TW_COMPILE_TIME_ASSERT(name, x) typedef int TW_DUMMY_ ## name[(x) * 2 - 1] - -TW_COMPILE_TIME_ASSERT(TW_CHAR, sizeof(char) == 1); -TW_COMPILE_TIME_ASSERT(TW_SHORT, sizeof(short) == 2); -TW_COMPILE_TIME_ASSERT(TW_INT, sizeof(int) == 4); -TW_COMPILE_TIME_ASSERT(TW_FLOAT, sizeof(float) == 4); -TW_COMPILE_TIME_ASSERT(TW_DOUBLE, sizeof(double) == 8); - -// Check pointer size on Windows -#if !defined(_WIN64) && defined(_WIN32) - // If the following assert failed, the platform is not 32-bit and _WIN64 is not defined. - // When targetting 64-bit Windows platform, _WIN64 must be defined. - TW_COMPILE_TIME_ASSERT(TW_PTR32, sizeof(void*) == 4); -#elif defined(_WIN64) - // If the following assert failed, _WIN64 is defined but the targeted platform is not 64-bit. - TW_COMPILE_TIME_ASSERT(TW_PTR64, sizeof(void*) == 8); -#endif - -// --------------------------------------------------------------------------- - - -#ifdef __cplusplus - } // extern "C" -#endif // __cplusplus - - -#endif // !defined TW_INCLUDED diff --git a/sample/opengl/AntTweakBar/AntTweakBar.lib b/sample/opengl/AntTweakBar/AntTweakBar.lib Binary files differdeleted file mode 100644 index 0301a12..0000000 --- a/sample/opengl/AntTweakBar/AntTweakBar.lib +++ /dev/null diff --git a/sample/opengl/AntTweakBar/AntTweakBar64.dll b/sample/opengl/AntTweakBar/AntTweakBar64.dll Binary files differdeleted file mode 100644 index 276b2c4..0000000 --- a/sample/opengl/AntTweakBar/AntTweakBar64.dll +++ /dev/null diff --git a/sample/opengl/AntTweakBar/AntTweakBar64.lib b/sample/opengl/AntTweakBar/AntTweakBar64.lib Binary files differdeleted file mode 100644 index 2d39b32..0000000 --- a/sample/opengl/AntTweakBar/AntTweakBar64.lib +++ /dev/null diff --git a/sample/opengl/GFSDK_WaveWorks_Attributes.fxh b/sample/opengl/GFSDK_WaveWorks_Attributes.fxh deleted file mode 100644 index 396afef..0000000 --- a/sample/opengl/GFSDK_WaveWorks_Attributes.fxh +++ /dev/null @@ -1,329 +0,0 @@ -/* - * 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 � 2008- 2013 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 _GFSDK_WAVEWORKS_ATTRIBUTES_FX -#define _GFSDK_WAVEWORKS_ATTRIBUTES_FX -/* - * - * - */ -#include "GFSDK_WaveWorks_Common.fxh" -/* - * - * - */ -#if defined(GFSDK_WAVEWORKS_SM3) || defined(GFSDK_WAVEWORKS_GL) - #define GFSDK_WAVEWORKS_BEGIN_ATTR_VS_CBUFFER(Label) - #define GFSDK_WAVEWORKS_END_ATTR_VS_CBUFFER - #define GFSDK_WAVEWORKS_BEGIN_ATTR_PS_CBUFFER(Label) - #define GFSDK_WAVEWORKS_END_ATTR_PS_CBUFFER -#endif -#if defined( GFSDK_WAVEWORKS_USE_TESSELLATION ) - #define GFSDK_WAVEWORKS_BEGIN_ATTR_DISPLACEMENT_CBUFFER(Label) GFSDK_WAVEWORKS_BEGIN_ATTR_DS_CBUFFER(Label) - #define GFSDK_WAVEWORKS_DECLARE_ATTR_DISPLACEMENT_CONSTANT(Type,Label,Regoff) GFSDK_WAVEWORKS_DECLARE_ATTR_DS_CONSTANT(Type,Label,Regoff) - #define GFSDK_WAVEWORKS_END_ATTR_DISPLACEMENT_CBUFFER GFSDK_WAVEWORKS_END_ATTR_DS_CBUFFER - #define GFSDK_WAVEWORKS_DECLARE_ATTR_DISPLACEMENT_SAMPLER(SampLabel,TexLabel,Regoff) GFSDK_WAVEWORKS_DECLARE_ATTR_DS_SAMPLER(SampLabel,TexLabel,Regoff) - #define GFSDK_WAVEWORKS_DECLARE_ATTR_DISPLACEMENT_SAMPLER_TEXTUREARRAY(SampLabel,TexLabel,Regoff) GFSDK_WAVEWORKS_DECLARE_ATTR_DS_SAMPLER_TEXTUREARRAY(SampLabel,TexLabel,Regoff) -#else - #define GFSDK_WAVEWORKS_BEGIN_ATTR_DISPLACEMENT_CBUFFER(Label) GFSDK_WAVEWORKS_BEGIN_ATTR_VS_CBUFFER(Label) - #define GFSDK_WAVEWORKS_DECLARE_ATTR_DISPLACEMENT_CONSTANT(Type,Label,Regoff) GFSDK_WAVEWORKS_DECLARE_ATTR_VS_CONSTANT(Type,Label,Regoff) - #define GFSDK_WAVEWORKS_END_ATTR_DISPLACEMENT_CBUFFER GFSDK_WAVEWORKS_END_ATTR_VS_CBUFFER - #define GFSDK_WAVEWORKS_DECLARE_ATTR_DISPLACEMENT_SAMPLER(SampLabel,TexLabel,Regoff) GFSDK_WAVEWORKS_DECLARE_ATTR_VS_SAMPLER(SampLabel,TexLabel,Regoff) - #define GFSDK_WAVEWORKS_DECLARE_ATTR_DISPLACEMENT_SAMPLER_TEXTUREARRAY(SampLabel,TexLabel,Regoff) GFSDK_WAVEWORKS_DECLARE_ATTR_VS_SAMPLER_TEXTUREARRAY(SampLabel,TexLabel,Regoff) -#endif -GFSDK_WAVEWORKS_BEGIN_ATTR_DISPLACEMENT_CBUFFER(nv_waveworks_attr0) -GFSDK_WAVEWORKS_DECLARE_ATTR_DISPLACEMENT_CONSTANT(float3, nv_waveworks_attr1, 0) -#if defined( GFSDK_WAVEWORKS_GL ) - GFSDK_WAVEWORKS_DECLARE_ATTR_DISPLACEMENT_CONSTANT(float, nv_waveworks_attr2, 1) -#else - GFSDK_WAVEWORKS_DECLARE_ATTR_DISPLACEMENT_CONSTANT(float, nv_waveworks_attr3, 1) -#endif -GFSDK_WAVEWORKS_DECLARE_ATTR_DISPLACEMENT_CONSTANT(float4, nv_waveworks_attr4, 2) -GFSDK_WAVEWORKS_END_ATTR_DISPLACEMENT_CBUFFER -GFSDK_WAVEWORKS_DECLARE_ATTR_DISPLACEMENT_SAMPLER(nv_waveworks_attr5, nv_waveworks_attr6, 0) -GFSDK_WAVEWORKS_DECLARE_ATTR_DISPLACEMENT_SAMPLER(nv_waveworks_attr7, nv_waveworks_attr8, 1) -GFSDK_WAVEWORKS_DECLARE_ATTR_DISPLACEMENT_SAMPLER(nv_waveworks_attr9, nv_waveworks_attr10, 2) -GFSDK_WAVEWORKS_DECLARE_ATTR_DISPLACEMENT_SAMPLER(nv_waveworks_attr11, nv_waveworks_attr12, 3) -#if defined( GFSDK_WAVEWORKS_GL ) - GFSDK_WAVEWORKS_DECLARE_ATTR_DISPLACEMENT_SAMPLER_TEXTUREARRAY(nv_waveworks_attr13, nv_waveworks_attr14, 4) -#endif -GFSDK_WAVEWORKS_BEGIN_ATTR_PS_CBUFFER(nv_waveworks_attr15) -GFSDK_WAVEWORKS_DECLARE_ATTR_PS_CONSTANT(float, nv_waveworks_attr16, 0) -GFSDK_WAVEWORKS_DECLARE_ATTR_PS_CONSTANT(float, nv_waveworks_attr17, 1) -GFSDK_WAVEWORKS_DECLARE_ATTR_PS_CONSTANT(float, nv_waveworks_attr18, 2) -GFSDK_WAVEWORKS_DECLARE_ATTR_PS_CONSTANT(float, nv_waveworks_attr19, 3) -GFSDK_WAVEWORKS_DECLARE_ATTR_PS_CONSTANT(float, nv_waveworks_attr20, 4) -GFSDK_WAVEWORKS_DECLARE_ATTR_PS_CONSTANT(float, nv_waveworks_attr21, 5) -GFSDK_WAVEWORKS_DECLARE_ATTR_PS_CONSTANT(float, nv_waveworks_attr22, 6) -GFSDK_WAVEWORKS_DECLARE_ATTR_PS_CONSTANT(float, nv_waveworks_attr23, 7) -GFSDK_WAVEWORKS_DECLARE_ATTR_PS_CONSTANT(float, nv_waveworks_attr24, 8) -GFSDK_WAVEWORKS_DECLARE_ATTR_PS_CONSTANT(float, nv_waveworks_attr25, 9) -GFSDK_WAVEWORKS_END_ATTR_PS_CBUFFER -GFSDK_WAVEWORKS_DECLARE_ATTR_PS_SAMPLER(nv_waveworks_attr26, nv_waveworks_attr27, 0) -GFSDK_WAVEWORKS_DECLARE_ATTR_PS_SAMPLER(nv_waveworks_attr28, nv_waveworks_attr29, 1) -GFSDK_WAVEWORKS_DECLARE_ATTR_PS_SAMPLER(nv_waveworks_attr30, nv_waveworks_attr31, 2) -GFSDK_WAVEWORKS_DECLARE_ATTR_PS_SAMPLER(nv_waveworks_attr32, nv_waveworks_attr33, 3) -#if defined( GFSDK_WAVEWORKS_GL ) - GFSDK_WAVEWORKS_DECLARE_ATTR_PS_SAMPLER_TEXTUREARRAY(nv_waveworks_attr34, nv_waveworks_attr35, 4) -#endif -struct GFSDK_WAVEWORKS_INTERPOLATED_VERTEX_OUTPUT -{ - float4 nv_waveworks_attr36 SEMANTIC(TEXCOORD0); - float4 nv_waveworks_attr37 SEMANTIC(TEXCOORD1); - float4 nv_waveworks_attr38 SEMANTIC(TEXCOORD2); - float3 nv_waveworks_attr39 SEMANTIC(TEXCOORD3); -}; -struct GFSDK_WAVEWORKS_VERTEX_OUTPUT -{ - centroid GFSDK_WAVEWORKS_INTERPOLATED_VERTEX_OUTPUT interp; - float3 pos_world; - float3 pos_world_undisplaced; - float3 world_displacement; -}; -GFSDK_WAVEWORKS_VERTEX_OUTPUT GFSDK_WaveWorks_GetDisplacedVertex(GFSDK_WAVEWORKS_VERTEX_INPUT In) -{ - float3 nv_waveworks_attr40 = GFSDK_WaveWorks_GetUndisplacedVertexWorldPosition(In); - float nv_waveworks_attr41 = length(nv_waveworks_attr1 - nv_waveworks_attr40); - float2 nv_waveworks_attr42 = nv_waveworks_attr40.xy * nv_waveworks_attr4.x; - float2 nv_waveworks_attr43 = nv_waveworks_attr40.xy * nv_waveworks_attr4.y; - float2 nv_waveworks_attr44 = nv_waveworks_attr40.xy * nv_waveworks_attr4.z; - float2 nv_waveworks_attr45 = nv_waveworks_attr40.xy * nv_waveworks_attr4.w; - float4 nv_waveworks_attr46; - float4 nv_waveworks_attr47 = 1.0/nv_waveworks_attr4.xyzw; - nv_waveworks_attr46.x = 1.0; - nv_waveworks_attr46.yzw = saturate(0.25*(nv_waveworks_attr47.yzw*24.0-nv_waveworks_attr41)/nv_waveworks_attr47.yzw); - nv_waveworks_attr46.yzw *= nv_waveworks_attr46.yzw; - #if defined(GFSDK_WAVEWORKS_GL) - float3 nv_waveworks_attr48; - if(nv_waveworks_attr2 > 0) - { - nv_waveworks_attr48 = nv_waveworks_attr46.x * SampleTex2Dlod(nv_waveworks_attr14, nv_waveworks_attr13, vec3(nv_waveworks_attr42, 0.0), 0).xyz; - nv_waveworks_attr48 += nv_waveworks_attr46.y==0? float3(0,0,0) : nv_waveworks_attr46.y * SampleTex2Dlod(nv_waveworks_attr14, nv_waveworks_attr13, vec3(nv_waveworks_attr43, 1.0), 0).xyz; - nv_waveworks_attr48 += nv_waveworks_attr46.z==0? float3(0,0,0) : nv_waveworks_attr46.z * SampleTex2Dlod(nv_waveworks_attr14, nv_waveworks_attr13, vec3(nv_waveworks_attr44, 2.0), 0).xyz; - nv_waveworks_attr48 += nv_waveworks_attr46.w==0? float3(0,0,0) : nv_waveworks_attr46.w * SampleTex2Dlod(nv_waveworks_attr14, nv_waveworks_attr13, vec3(nv_waveworks_attr45, 3.0), 0).xyz; - } - else - { - nv_waveworks_attr48 = nv_waveworks_attr46.x * SampleTex2Dlod(nv_waveworks_attr6, nv_waveworks_attr5, nv_waveworks_attr42, 0).xyz; - nv_waveworks_attr48 += nv_waveworks_attr46.y==0? float3(0,0,0) : nv_waveworks_attr46.y * SampleTex2Dlod(nv_waveworks_attr8, nv_waveworks_attr7, nv_waveworks_attr43, 0).xyz; - nv_waveworks_attr48 += nv_waveworks_attr46.z==0? float3(0,0,0) : nv_waveworks_attr46.z * SampleTex2Dlod(nv_waveworks_attr10, nv_waveworks_attr9, nv_waveworks_attr44, 0).xyz; - nv_waveworks_attr48 += nv_waveworks_attr46.w==0? float3(0,0,0) : nv_waveworks_attr46.w * SampleTex2Dlod(nv_waveworks_attr12, nv_waveworks_attr11, nv_waveworks_attr45, 0).xyz; - } - #else - float3 nv_waveworks_attr48 = nv_waveworks_attr46.x * SampleTex2Dlod(nv_waveworks_attr6, nv_waveworks_attr5, nv_waveworks_attr42, 0).xyz; - nv_waveworks_attr48 += nv_waveworks_attr46.y==0? float3(0,0,0) : nv_waveworks_attr46.y * SampleTex2Dlod(nv_waveworks_attr8, nv_waveworks_attr7, nv_waveworks_attr43, 0).xyz; - nv_waveworks_attr48 += nv_waveworks_attr46.z==0? float3(0,0,0) : nv_waveworks_attr46.z * SampleTex2Dlod(nv_waveworks_attr10, nv_waveworks_attr9, nv_waveworks_attr44, 0).xyz; - nv_waveworks_attr48 += nv_waveworks_attr46.w==0? float3(0,0,0) : nv_waveworks_attr46.w * SampleTex2Dlod(nv_waveworks_attr12, nv_waveworks_attr11, nv_waveworks_attr45, 0).xyz; - #endif - float3 nv_waveworks_attr49 = nv_waveworks_attr40 + nv_waveworks_attr48; - GFSDK_WAVEWORKS_VERTEX_OUTPUT Output; - Output.interp.nv_waveworks_attr39 = nv_waveworks_attr1 - nv_waveworks_attr49; - Output.interp.nv_waveworks_attr36.xy = nv_waveworks_attr42; - Output.interp.nv_waveworks_attr36.zw = nv_waveworks_attr43; - Output.interp.nv_waveworks_attr37.xy = nv_waveworks_attr44; - Output.interp.nv_waveworks_attr37.zw = nv_waveworks_attr45; - Output.interp.nv_waveworks_attr38 = nv_waveworks_attr46; - Output.pos_world = nv_waveworks_attr49; - Output.pos_world_undisplaced = nv_waveworks_attr40; - Output.world_displacement = nv_waveworks_attr48; - return Output; -} -GFSDK_WAVEWORKS_VERTEX_OUTPUT GFSDK_WaveWorks_GetDisplacedVertexAfterTessellation(float4 In0, float4 In1, float4 In2, float3 BarycentricCoords) -{ - float3 nv_waveworks_attr50 = In0.xyz * BarycentricCoords.x + - In1.xyz * BarycentricCoords.y + - In2.xyz * BarycentricCoords.z; - float3 nv_waveworks_attr40 = nv_waveworks_attr50; - float4 nv_waveworks_attr46; - float nv_waveworks_attr41 = length(nv_waveworks_attr1 - nv_waveworks_attr40); - float4 nv_waveworks_attr47 = 1.0/nv_waveworks_attr4.xyzw; - nv_waveworks_attr46.x = 1.0; - nv_waveworks_attr46.yzw = saturate(0.25*(nv_waveworks_attr47.yzw*24.0-nv_waveworks_attr41)/nv_waveworks_attr47.yzw); - nv_waveworks_attr46.yzw *= nv_waveworks_attr46.yzw; - float2 nv_waveworks_attr42 = nv_waveworks_attr40.xy * nv_waveworks_attr4.x; - float2 nv_waveworks_attr43 = nv_waveworks_attr40.xy * nv_waveworks_attr4.y; - float2 nv_waveworks_attr44 = nv_waveworks_attr40.xy * nv_waveworks_attr4.z; - float2 nv_waveworks_attr45 = nv_waveworks_attr40.xy * nv_waveworks_attr4.w; - #if defined(GFSDK_WAVEWORKS_GL) - float3 nv_waveworks_attr48; - if(nv_waveworks_attr2 > 0) - { - nv_waveworks_attr48 = nv_waveworks_attr46.x * SampleTex2Dlod(nv_waveworks_attr14, nv_waveworks_attr13, vec3(nv_waveworks_attr42, 0.0), 0).xyz; - nv_waveworks_attr48 += nv_waveworks_attr46.y==0? float3(0,0,0) : nv_waveworks_attr46.y * SampleTex2Dlod(nv_waveworks_attr14, nv_waveworks_attr13, vec3(nv_waveworks_attr43, 1.0), 0).xyz; - nv_waveworks_attr48 += nv_waveworks_attr46.z==0? float3(0,0,0) : nv_waveworks_attr46.z * SampleTex2Dlod(nv_waveworks_attr14, nv_waveworks_attr13, vec3(nv_waveworks_attr44, 2.0), 0).xyz; - nv_waveworks_attr48 += nv_waveworks_attr46.w==0? float3(0,0,0) : nv_waveworks_attr46.w * SampleTex2Dlod(nv_waveworks_attr14, nv_waveworks_attr13, vec3(nv_waveworks_attr45, 3.0), 0).xyz; - } - else - { - nv_waveworks_attr48 = nv_waveworks_attr46.x * SampleTex2Dlod(nv_waveworks_attr6, nv_waveworks_attr5, nv_waveworks_attr42, 0).xyz; - nv_waveworks_attr48 += nv_waveworks_attr46.y==0? float3(0,0,0) : nv_waveworks_attr46.y * SampleTex2Dlod(nv_waveworks_attr8, nv_waveworks_attr7, nv_waveworks_attr43, 0).xyz; - nv_waveworks_attr48 += nv_waveworks_attr46.z==0? float3(0,0,0) : nv_waveworks_attr46.z * SampleTex2Dlod(nv_waveworks_attr10, nv_waveworks_attr9, nv_waveworks_attr44, 0).xyz; - nv_waveworks_attr48 += nv_waveworks_attr46.w==0? float3(0,0,0) : nv_waveworks_attr46.w * SampleTex2Dlod(nv_waveworks_attr12, nv_waveworks_attr11, nv_waveworks_attr45, 0).xyz; - } - #else - float3 nv_waveworks_attr48 = nv_waveworks_attr46.x * SampleTex2Dlod(nv_waveworks_attr6, nv_waveworks_attr5, nv_waveworks_attr42, 0).xyz; - nv_waveworks_attr48 += nv_waveworks_attr46.y==0? float3(0,0,0) : nv_waveworks_attr46.y * SampleTex2Dlod(nv_waveworks_attr8, nv_waveworks_attr7, nv_waveworks_attr43, 0).xyz; - nv_waveworks_attr48 += nv_waveworks_attr46.z==0? float3(0,0,0) : nv_waveworks_attr46.z * SampleTex2Dlod(nv_waveworks_attr10, nv_waveworks_attr9, nv_waveworks_attr44, 0).xyz; - nv_waveworks_attr48 += nv_waveworks_attr46.w==0? float3(0,0,0) : nv_waveworks_attr46.w * SampleTex2Dlod(nv_waveworks_attr12, nv_waveworks_attr11, nv_waveworks_attr45, 0).xyz; - #endif - float3 nv_waveworks_attr49 = nv_waveworks_attr40 + nv_waveworks_attr48; - GFSDK_WAVEWORKS_VERTEX_OUTPUT Output; - Output.interp.nv_waveworks_attr39 = nv_waveworks_attr1 - nv_waveworks_attr49; - Output.interp.nv_waveworks_attr36.xy = nv_waveworks_attr42; - Output.interp.nv_waveworks_attr36.zw = nv_waveworks_attr43; - Output.interp.nv_waveworks_attr37.xy = nv_waveworks_attr44; - Output.interp.nv_waveworks_attr37.zw = nv_waveworks_attr45; - Output.interp.nv_waveworks_attr38 = nv_waveworks_attr46; - Output.pos_world = nv_waveworks_attr49; - Output.pos_world_undisplaced = nv_waveworks_attr40; - Output.world_displacement = nv_waveworks_attr48; - return Output; -} -GFSDK_WAVEWORKS_VERTEX_OUTPUT GFSDK_WaveWorks_GetDisplacedVertexAfterTessellationQuad(float4 In0, float4 In1, float4 In2, float4 In3, float2 UV) -{ - float3 nv_waveworks_attr50 = In2.xyz*UV.x*UV.y + - In0.xyz*(1.0-UV.x)*UV.y + - In1.xyz*(1.0-UV.x)*(1.0-UV.y) + - In3.xyz*UV.x*(1.0-UV.y); - float3 nv_waveworks_attr40 = nv_waveworks_attr50; - float4 nv_waveworks_attr46; - float nv_waveworks_attr41 = length(nv_waveworks_attr1 - nv_waveworks_attr40); - float4 nv_waveworks_attr47 = 1.0/nv_waveworks_attr4.xyzw; - nv_waveworks_attr46.x = 1.0; - nv_waveworks_attr46.yzw = saturate(0.25*(nv_waveworks_attr47.yzw*24.0-nv_waveworks_attr41)/nv_waveworks_attr47.yzw); - nv_waveworks_attr46.yzw *= nv_waveworks_attr46.yzw; - float2 nv_waveworks_attr42 = nv_waveworks_attr40.xy * nv_waveworks_attr4.x; - float2 nv_waveworks_attr43 = nv_waveworks_attr40.xy * nv_waveworks_attr4.y; - float2 nv_waveworks_attr44 = nv_waveworks_attr40.xy * nv_waveworks_attr4.z; - float2 nv_waveworks_attr45 = nv_waveworks_attr40.xy * nv_waveworks_attr4.w; - #if defined(GFSDK_WAVEWORKS_GL) - float3 nv_waveworks_attr48; - if(nv_waveworks_attr2 > 0) - { - nv_waveworks_attr48 = nv_waveworks_attr46.x * SampleTex2Dlod(nv_waveworks_attr14, nv_waveworks_attr13, vec3(nv_waveworks_attr42, 0.0), 0).xyz; - nv_waveworks_attr48 += nv_waveworks_attr46.y==0? float3(0,0,0) : nv_waveworks_attr46.y * SampleTex2Dlod(nv_waveworks_attr14, nv_waveworks_attr13, vec3(nv_waveworks_attr43, 1.0), 0).xyz; - nv_waveworks_attr48 += nv_waveworks_attr46.z==0? float3(0,0,0) : nv_waveworks_attr46.z * SampleTex2Dlod(nv_waveworks_attr14, nv_waveworks_attr13, vec3(nv_waveworks_attr44, 2.0), 0).xyz; - nv_waveworks_attr48 += nv_waveworks_attr46.w==0? float3(0,0,0) : nv_waveworks_attr46.w * SampleTex2Dlod(nv_waveworks_attr14, nv_waveworks_attr13, vec3(nv_waveworks_attr45, 3.0), 0).xyz; - } - else - { - nv_waveworks_attr48 = nv_waveworks_attr46.x * SampleTex2Dlod(nv_waveworks_attr6, nv_waveworks_attr5, nv_waveworks_attr42, 0).xyz; - nv_waveworks_attr48 += nv_waveworks_attr46.y==0? float3(0,0,0) : nv_waveworks_attr46.y * SampleTex2Dlod(nv_waveworks_attr8, nv_waveworks_attr7, nv_waveworks_attr43, 0).xyz; - nv_waveworks_attr48 += nv_waveworks_attr46.z==0? float3(0,0,0) : nv_waveworks_attr46.z * SampleTex2Dlod(nv_waveworks_attr10, nv_waveworks_attr9, nv_waveworks_attr44, 0).xyz; - nv_waveworks_attr48 += nv_waveworks_attr46.w==0? float3(0,0,0) : nv_waveworks_attr46.w * SampleTex2Dlod(nv_waveworks_attr12, nv_waveworks_attr11, nv_waveworks_attr45, 0).xyz; - } - #else - float3 nv_waveworks_attr48 = nv_waveworks_attr46.x * SampleTex2Dlod(nv_waveworks_attr6, nv_waveworks_attr5, nv_waveworks_attr42, 0).xyz; - nv_waveworks_attr48 += nv_waveworks_attr46.y==0? float3(0,0,0) : nv_waveworks_attr46.y * SampleTex2Dlod(nv_waveworks_attr8, nv_waveworks_attr7, nv_waveworks_attr43, 0).xyz; - nv_waveworks_attr48 += nv_waveworks_attr46.z==0? float3(0,0,0) : nv_waveworks_attr46.z * SampleTex2Dlod(nv_waveworks_attr10, nv_waveworks_attr9, nv_waveworks_attr44, 0).xyz; - nv_waveworks_attr48 += nv_waveworks_attr46.w==0? float3(0,0,0) : nv_waveworks_attr46.w * SampleTex2Dlod(nv_waveworks_attr12, nv_waveworks_attr11, nv_waveworks_attr45, 0).xyz; - #endif - float3 nv_waveworks_attr49 = nv_waveworks_attr40 + nv_waveworks_attr48; - GFSDK_WAVEWORKS_VERTEX_OUTPUT Output; - Output.interp.nv_waveworks_attr39 = nv_waveworks_attr1 - nv_waveworks_attr49; - Output.interp.nv_waveworks_attr36.xy = nv_waveworks_attr42; - Output.interp.nv_waveworks_attr36.zw = nv_waveworks_attr43; - Output.interp.nv_waveworks_attr37.xy = nv_waveworks_attr44; - Output.interp.nv_waveworks_attr37.zw = nv_waveworks_attr45; - Output.interp.nv_waveworks_attr38 = nv_waveworks_attr46; - Output.pos_world = nv_waveworks_attr49; - Output.pos_world_undisplaced = nv_waveworks_attr40; - Output.world_displacement = nv_waveworks_attr48; - return Output; -} -struct GFSDK_WAVEWORKS_SURFACE_ATTRIBUTES -{ - float3 normal; - float3 eye_dir; - float foam_surface_folding; - float foam_turbulent_energy; - float foam_wave_hats; -}; -GFSDK_WAVEWORKS_SURFACE_ATTRIBUTES GFSDK_WaveWorks_GetSurfaceAttributes(GFSDK_WAVEWORKS_INTERPOLATED_VERTEX_OUTPUT In) -{ - float3 nv_waveworks_attr51 = normalize(In.nv_waveworks_attr39); - float4 nv_waveworks_attr52; - float4 nv_waveworks_attr53; - float4 nv_waveworks_attr54; - float4 nv_waveworks_attr55; - #if defined(GFSDK_WAVEWORKS_GL) - float3 nv_waveworks_attr48; - if(nv_waveworks_attr2 > 0) - { - nv_waveworks_attr52 = SampleTex2D(nv_waveworks_attr35, nv_waveworks_attr34, vec3(In.nv_waveworks_attr36.xy, 0.0)); - nv_waveworks_attr53 = SampleTex2D(nv_waveworks_attr35, nv_waveworks_attr34, vec3(In.nv_waveworks_attr36.zw, 1.0)); - nv_waveworks_attr54 = SampleTex2D(nv_waveworks_attr35, nv_waveworks_attr34, vec3(In.nv_waveworks_attr37.xy, 2.0)); - nv_waveworks_attr55 = SampleTex2D(nv_waveworks_attr35, nv_waveworks_attr34, vec3(In.nv_waveworks_attr37.zw, 3.0)); - } - else - { - nv_waveworks_attr52 = SampleTex2D(nv_waveworks_attr27, nv_waveworks_attr26, In.nv_waveworks_attr36.xy); - nv_waveworks_attr53 = SampleTex2D(nv_waveworks_attr29, nv_waveworks_attr28, In.nv_waveworks_attr36.zw); - nv_waveworks_attr54 = SampleTex2D(nv_waveworks_attr31, nv_waveworks_attr30, In.nv_waveworks_attr37.xy); - nv_waveworks_attr55 = SampleTex2D(nv_waveworks_attr33, nv_waveworks_attr32, In.nv_waveworks_attr37.zw); - } - #else - nv_waveworks_attr52 = SampleTex2D(nv_waveworks_attr27, nv_waveworks_attr26, In.nv_waveworks_attr36.xy); - nv_waveworks_attr53 = SampleTex2D(nv_waveworks_attr29, nv_waveworks_attr28, In.nv_waveworks_attr36.zw); - nv_waveworks_attr54 = SampleTex2D(nv_waveworks_attr31, nv_waveworks_attr30, In.nv_waveworks_attr37.xy); - nv_waveworks_attr55 = SampleTex2D(nv_waveworks_attr33, nv_waveworks_attr32, In.nv_waveworks_attr37.zw); - #endif - float2 nv_waveworks_attr56; - nv_waveworks_attr56.xy = nv_waveworks_attr52.xy*In.nv_waveworks_attr38.x + - nv_waveworks_attr53.xy*In.nv_waveworks_attr38.y*nv_waveworks_attr18 + - nv_waveworks_attr54.xy*In.nv_waveworks_attr38.z*nv_waveworks_attr21 + - nv_waveworks_attr55.xy*In.nv_waveworks_attr38.w*nv_waveworks_attr24; - float nv_waveworks_attr57 = 0.25; - float nv_waveworks_attr58 = - 100.0*nv_waveworks_attr52.w * - lerp(nv_waveworks_attr57, nv_waveworks_attr53.w, In.nv_waveworks_attr38.y)* - lerp(nv_waveworks_attr57, nv_waveworks_attr54.w, In.nv_waveworks_attr38.z)* - lerp(nv_waveworks_attr57, nv_waveworks_attr55.w, In.nv_waveworks_attr38.w); - float nv_waveworks_attr59 = - max(-100, - (1.0-nv_waveworks_attr52.z) + - (1.0-nv_waveworks_attr53.z) + - (1.0-nv_waveworks_attr54.z) + - (1.0-nv_waveworks_attr55.z)); - float3 nv_waveworks_attr60 = normalize(float3(nv_waveworks_attr56, nv_waveworks_attr16)); - float nv_waveworks_attr61 = 0.5; - float nv_waveworks_attr62 = - 10.0*(-0.55 + - (1.0-nv_waveworks_attr52.z) + - nv_waveworks_attr61*(1.0-nv_waveworks_attr53.z) + - nv_waveworks_attr61*nv_waveworks_attr61*(1.0-nv_waveworks_attr54.z) + - nv_waveworks_attr61*nv_waveworks_attr61*nv_waveworks_attr61*(1.0-nv_waveworks_attr55.z)); - GFSDK_WAVEWORKS_SURFACE_ATTRIBUTES Output; - Output.normal = nv_waveworks_attr60; - Output.eye_dir = nv_waveworks_attr51; - Output.foam_surface_folding = nv_waveworks_attr59; - Output.foam_turbulent_energy = log(1.0 + nv_waveworks_attr58); - Output.foam_wave_hats = nv_waveworks_attr62; - return Output; -} -#endif /* _GFSDK_WAVEWORKS_ATTRIBUTES_FX */ diff --git a/sample/opengl/GFSDK_WaveWorks_Common.fxh b/sample/opengl/GFSDK_WaveWorks_Common.fxh deleted file mode 100644 index 8ee0fd2..0000000 --- a/sample/opengl/GFSDK_WaveWorks_Common.fxh +++ /dev/null @@ -1,77 +0,0 @@ -/* - * 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 � 2008- 2013 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 _GFSDK_WAVEWORKS_COMMON_FX -#define _GFSDK_WAVEWORKS_COMMON_FX -/* - * - * - */ -#if defined(GFSDK_WAVEWORKS_SM4) || defined(GFSDK_WAVEWORKS_SM5) - #define SampleTex2D(nv_waveworks_comm0,nv_waveworks_comm1,nv_waveworks_comm2) nv_waveworks_comm0.Sample(nv_waveworks_comm1,nv_waveworks_comm2) - #define SampleTex2Dlod(nv_waveworks_comm0,nv_waveworks_comm1,nv_waveworks_comm2,nv_waveworks_comm3) nv_waveworks_comm0.SampleLevel(nv_waveworks_comm1,nv_waveworks_comm2,nv_waveworks_comm3) - #define BEGIN_CBUFFER(name,slot) cbuffer name : register(b##slot) { - #define END_CBUFFER }; - #define SEMANTIC(x) : x -#elif defined(GFSDK_WAVEWORKS_SM3) - #define SampleTex2D(nv_waveworks_comm0,nv_waveworks_comm1,nv_waveworks_comm2) tex2D(nv_waveworks_comm1,nv_waveworks_comm2) - #define SampleTex2Dlod(nv_waveworks_comm0,nv_waveworks_comm1,nv_waveworks_comm2,nv_waveworks_comm3) tex2Dlod(nv_waveworks_comm1,float4(nv_waveworks_comm2,0,nv_waveworks_comm3)) - #define BEGIN_CBUFFER(name,slot) - #define END_CBUFFER - #define SV_Target COLOR - #define SV_Position POSITION - #define SEMANTIC(x) : x -#elif defined(GFSDK_WAVEWORKS_GNM) - #define SampleTex2D(nv_waveworks_comm0,nv_waveworks_comm1,nv_waveworks_comm2) nv_waveworks_comm0.Sample(nv_waveworks_comm1,nv_waveworks_comm2) - #define SampleTex2Dlod(nv_waveworks_comm0,nv_waveworks_comm1,nv_waveworks_comm2,nv_waveworks_comm3) nv_waveworks_comm0.SampleLOD(nv_waveworks_comm1,nv_waveworks_comm2,nv_waveworks_comm3) - #define BEGIN_CBUFFER(name,slot) ConstantBuffer name : register(b##slot) { - #define END_CBUFFER }; - #define SV_Target S_TARGET_OUTPUT - #define SV_Position S_POSITION - #define SEMANTIC(x) : x -#elif defined(GFSDK_WAVEWORKS_GL) - #define SampleTex2D(nv_waveworks_comm0,nv_waveworks_comm1,nv_waveworks_comm2) texture(nv_waveworks_comm1,nv_waveworks_comm2) - #define SampleTex2Dlod(nv_waveworks_comm0,nv_waveworks_comm1,nv_waveworks_comm2,nv_waveworks_comm3) textureLod(nv_waveworks_comm1,nv_waveworks_comm2,nv_waveworks_comm3) - #define BEGIN_CBUFFER(name,slot) - #define END_CBUFFER - #define SEMANTIC(x) - #define float2 vec2 - #define float3 vec3 - #define float4 vec4 - #define float4x3 mat3x4 - #define mul(v,m) ((v)*(m)) - #define lerp mix - #define saturate(x) clamp(x,0.0,1.0) -#else - #error Shader model not defined (expected GFSDK_WAVEWORKS_SM3, GFSDK_WAVEWORKS_SM4, GFSDK_WAVEWORKS_SM5, GFSDK_WAVEWORKS_GNM or GFSDK_WAVEWORKS_GL) -#endif -/* - * - * - */ -#endif /* _GFSDK_WAVEWORKS_COMMON_FX */ diff --git a/sample/opengl/GFSDK_WaveWorks_Quadtree.fxh b/sample/opengl/GFSDK_WaveWorks_Quadtree.fxh deleted file mode 100644 index 1144e28..0000000 --- a/sample/opengl/GFSDK_WaveWorks_Quadtree.fxh +++ /dev/null @@ -1,145 +0,0 @@ -/* - * 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 � 2008- 2013 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 "GFSDK_WaveWorks_Common.fxh" -/* - * - * - */ -#if defined(GFSDK_WAVEWORKS_SM3) || defined(GFSDK_WAVEWORKS_GL) - #define GFSDK_WAVEWORKS_BEGIN_GEOM_VS_CBUFFER(Label) - #define GFSDK_WAVEWORKS_END_GEOM_VS_CBUFFER -#endif -#if defined( GFSDK_WAVEWORKS_USE_TESSELLATION ) - GFSDK_WAVEWORKS_BEGIN_GEOM_HS_CBUFFER(nv_waveworks_quad0) - GFSDK_WAVEWORKS_DECLARE_GEOM_HS_CONSTANT(float4, nv_waveworks_quad1, 0) - GFSDK_WAVEWORKS_DECLARE_GEOM_HS_CONSTANT(float4, nv_waveworks_quad2, 1) - GFSDK_WAVEWORKS_END_GEOM_HS_CBUFFER -#endif -GFSDK_WAVEWORKS_BEGIN_GEOM_VS_CBUFFER(nv_waveworks_quad3) -GFSDK_WAVEWORKS_DECLARE_GEOM_VS_CONSTANT(float4x3, nv_waveworks_quad4, 0) -GFSDK_WAVEWORKS_DECLARE_GEOM_VS_CONSTANT(float4, nv_waveworks_quad5, 3) -GFSDK_WAVEWORKS_DECLARE_GEOM_VS_CONSTANT(float4, nv_waveworks_quad6, 4) -GFSDK_WAVEWORKS_END_GEOM_VS_CBUFFER -struct GFSDK_WAVEWORKS_VERTEX_INPUT -{ - float4 nv_waveworks_quad7 SEMANTIC(POSITION); -}; -#if !defined(GFSDK_WAVEWORKS_USE_TESSELLATION) -float3 GFSDK_WaveWorks_GetUndisplacedVertexWorldPosition(GFSDK_WAVEWORKS_VERTEX_INPUT In) -{ - float2 nv_waveworks_quad8 = In.nv_waveworks_quad7.xy; - float nv_waveworks_quad9 = 0.25f; - float2 nv_waveworks_quad10 = float2(nv_waveworks_quad6.w,nv_waveworks_quad6.w); - float2 nv_waveworks_quad11 = nv_waveworks_quad8; - float2 nv_waveworks_quad12 = nv_waveworks_quad11; - float nv_waveworks_quad13 = 0.f; - for(int nv_waveworks_quad14 = 0; nv_waveworks_quad14 != 4; ++nv_waveworks_quad14) { - float2 nv_waveworks_quad15; - float2 nv_waveworks_quad16 = modf(nv_waveworks_quad9*nv_waveworks_quad11.xy,nv_waveworks_quad15); - float2 nv_waveworks_quad17 = float2(1.0f, 1.0f); - if(nv_waveworks_quad16.x > 0.5f) - { - nv_waveworks_quad16.x = 1.0f - nv_waveworks_quad16.x; - nv_waveworks_quad17.x = -nv_waveworks_quad17.x; - } - if(nv_waveworks_quad16.y > 0.5f) - { - nv_waveworks_quad16.y = 1.0f - nv_waveworks_quad16.y; - nv_waveworks_quad17.y = -nv_waveworks_quad17.y; - } - if(0.25f == nv_waveworks_quad16.x && 0.25f == nv_waveworks_quad16.y) nv_waveworks_quad12.xy = nv_waveworks_quad11.xy - nv_waveworks_quad10*nv_waveworks_quad17; - else if(0.25f == nv_waveworks_quad16.x) nv_waveworks_quad12.x = nv_waveworks_quad11.x + nv_waveworks_quad10.x*nv_waveworks_quad17.x; - else if(0.25f == nv_waveworks_quad16.y) nv_waveworks_quad12.y = nv_waveworks_quad11.y + nv_waveworks_quad10.y*nv_waveworks_quad17.y; - float3 nv_waveworks_quad18 = mul(float4(nv_waveworks_quad12,0.f,1.f), nv_waveworks_quad4) - nv_waveworks_quad5.xyz; - float nv_waveworks_quad19 = length(nv_waveworks_quad18); - float nv_waveworks_quad20 = log2(nv_waveworks_quad19 * nv_waveworks_quad6.x) + 1.f; - nv_waveworks_quad13 = saturate(2.0*(nv_waveworks_quad20 - float(nv_waveworks_quad14))); - if(nv_waveworks_quad13 < 1.f) - { - break; - } - else - { - nv_waveworks_quad11 = nv_waveworks_quad12; - nv_waveworks_quad9 *= 0.5f; - nv_waveworks_quad10 *= -2.f; - } - } - nv_waveworks_quad8.xy = lerp(nv_waveworks_quad11, nv_waveworks_quad12, nv_waveworks_quad13); - return mul(float4(nv_waveworks_quad8,In.nv_waveworks_quad7.zw), nv_waveworks_quad4); -} -#endif -#if defined(GFSDK_WAVEWORKS_USE_TESSELLATION) -float3 GFSDK_WaveWorks_GetUndisplacedVertexWorldPosition(GFSDK_WAVEWORKS_VERTEX_INPUT In) -{ - float2 nv_waveworks_quad8 = In.nv_waveworks_quad7.xy; - float nv_waveworks_quad9 = 0.5f; - float nv_waveworks_quad10 = abs(nv_waveworks_quad6.w); - float2 nv_waveworks_quad11 = nv_waveworks_quad8; - float2 nv_waveworks_quad12 = nv_waveworks_quad11; - float nv_waveworks_quad13 = 0.f; - for(int nv_waveworks_quad14 = 0; nv_waveworks_quad14 != 4; ++nv_waveworks_quad14) { - float2 nv_waveworks_quad15; - float2 nv_waveworks_quad16 = modf(nv_waveworks_quad9*nv_waveworks_quad11.xy,nv_waveworks_quad15); - if(0.5f == nv_waveworks_quad16.x) - { - nv_waveworks_quad12.x = nv_waveworks_quad11.x + nv_waveworks_quad10; - } - if(0.5f == nv_waveworks_quad16.y) - { - nv_waveworks_quad12.y = nv_waveworks_quad11.y + nv_waveworks_quad10; - } - float3 nv_waveworks_quad18 = mul(float4(nv_waveworks_quad12,0.f,1.f), nv_waveworks_quad4) - nv_waveworks_quad5.xyz; - float nv_waveworks_quad19 = length(nv_waveworks_quad18); - float nv_waveworks_quad20 = log2(nv_waveworks_quad19 * nv_waveworks_quad6.x) + 1.f; - nv_waveworks_quad13 = saturate(3.0*(nv_waveworks_quad20 - float(nv_waveworks_quad14))); - if(nv_waveworks_quad13 < 1.f) { - break; - } else { - nv_waveworks_quad11 = nv_waveworks_quad12; - nv_waveworks_quad9 *= 0.5f; - nv_waveworks_quad10 *= 2.f; - } - } - nv_waveworks_quad8.xy = lerp(nv_waveworks_quad11, nv_waveworks_quad12, nv_waveworks_quad13); - return mul(float4(nv_waveworks_quad8,In.nv_waveworks_quad7.zw), nv_waveworks_quad4); -} -float GFSDK_WaveWorks_GetEdgeTessellationFactor(float4 vertex1, float4 vertex2) -{ - float3 nv_waveworks_quad21 = 0.5*(vertex1.xyz + vertex2.xyz); - float nv_waveworks_quad22 = length (vertex1.xyz - vertex2.xyz); - float nv_waveworks_quad23 = length(nv_waveworks_quad1.xyz - nv_waveworks_quad21.xyz); - return nv_waveworks_quad2.x * nv_waveworks_quad22 / nv_waveworks_quad23; -} -float GFSDK_WaveWorks_GetVertexTargetTessellatedEdgeLength(float3 vertex) -{ - float nv_waveworks_quad24 = length(nv_waveworks_quad1.xyz - vertex.xyz); - return nv_waveworks_quad24 / nv_waveworks_quad2.x; -} -#endif diff --git a/sample/opengl/math_code.cpp b/sample/opengl/math_code.cpp deleted file mode 100644 index b744f48..0000000 --- a/sample/opengl/math_code.cpp +++ /dev/null @@ -1,488 +0,0 @@ -/* - * math_code.cpp - * - * Created on: 21.03.2011 - * Author: ttcheblokov - */ - -#include "math_code.h" - -void cutLowerHalfspace(float result[4][4], float level, float position, float viewmatrix[4][4], float projectionmatrix[4][4]) -{ - float viewprojectionmatrix[4][4],tm[4][4],n[4][4]={1.0f,0.0f,0.0f,0.0f,0.0f,1.0f,0.0f,0.0f,0.0f,0.0f,1.0f,0.0f,0.0f,0.0f,0.0f,1.0f}; - float cplane[4],clip_plane[4]; - - cplane[0]=0.0f; - cplane[1]=0.1f; - cplane[2]=0.0f; - cplane[3]=-level*0.1f;//+0.1f; - - mat4Mat4Mul(viewprojectionmatrix, projectionmatrix, viewmatrix); - mat4Inverse(tm,viewprojectionmatrix); - mat4Vec4Mul(clip_plane,tm,cplane); - - //clip_plane[0]/=cplane[1]; - //clip_plane[1]/=cplane[1]; - //clip_plane[2]/=cplane[1]; - //clip_plane[3]/=cplane[1]; - - clip_plane[3] -= 1.0f; - - if((level<position)) - { - clip_plane[0] *= -1.0f; - clip_plane[1] *= -1.0f; - clip_plane[2] *= -1.0f; - clip_plane[3] *= -1.0f; - } - - n[0][2]=clip_plane[0]; - n[1][2]=clip_plane[1]; - n[2][2]=clip_plane[2]; - n[3][2]=clip_plane[3]; - - mat4Mat4Mul(result,n,projectionmatrix); -} - -void cutUpperHalfspace(float result[4][4], float level, float position, float viewmatrix[4][4], float projectionmatrix[4][4]) -{ - float viewprojectionmatrix[4][4],tm[4][4],n[4][4]={1.0f,0.0f,0.0f,0.0f,0.0f,1.0f,0.0f,0.0f,0.0f,0.0f,1.0f,0.0f,0.0f,0.0f,0.0f,1.0f}; - float cplane[4],clip_plane[4]; - - cplane[0]=0.0f; - cplane[1]=-0.1f; - cplane[2]=0.0f; - cplane[3]=level*0.1f;//-0.1f; - - mat4Mat4Mul(viewprojectionmatrix, projectionmatrix, viewmatrix); - mat4Inverse(tm,viewprojectionmatrix); - mat4Vec4Mul(clip_plane,tm,cplane); - - //clip_plane[0]/=cplane[1]; - //clip_plane[1]/=cplane[1]; - //clip_plane[2]/=cplane[1]; - //clip_plane[3]/=cplane[1]; - - clip_plane[3] -= 1.0f; - - if((level>position)) - { - clip_plane[0] *= -1.0f; - clip_plane[1] *= -1.0f; - clip_plane[2] *= -1.0f; - clip_plane[3] *= -1.0f; - } - - n[0][2]=clip_plane[0]; - n[1][2]=clip_plane[1]; - n[2][2]=clip_plane[2]; - n[3][2]=clip_plane[3]; - - mat4Mat4Mul(result,n,projectionmatrix); -} - -void vec3CrossProductNormalized(float result[3], float a[3], float b[3]) - { - float length; - result[0]=a[1]*b[2]-a[2]*b[1]; - result[1]=a[2]*b[0]-a[0]*b[2]; - result[2]=a[0]*b[1]-a[1]*b[0]; - length=sqrt(result[0]*result[0]+result[1]*result[1]+result[2]*result[2]); - result[0]/=length; - result[1]/=length; - result[2]/=length; - } - - void vec4Sub(float a[4], float b[4], float c[4]) - { - a[0]=b[0]-c[0]; - a[1]=b[1]-c[1]; - a[2]=b[2]-c[2]; - a[3]=b[3]-c[3]; - } - void vec4Add(float a[4], float b[4], float c[4]) - { - a[0]=b[0]+c[0]; - a[1]=b[1]+c[1]; - a[2]=b[2]+c[2]; - a[3]=b[3]+c[3]; - } - float vec4DotProduct(float a[4], float b[4]) - { - return (a[0]*b[0]+a[1]*b[1]+a[2]*b[2]+a[3]*b[3]); - } - - float vec3DotProduct(float a[3], float b[3]) - { - return (a[0]*b[0]+a[1]*b[1]+a[2]*b[2]); - } - - void vec4Normalize(float a[4]) - { - float length; - length=sqrt(a[0]*a[0]+a[1]*a[1]+a[2]*a[2]+a[3]*a[3]); - a[0]/=length; - a[1]/=length; - a[2]/=length; - a[3]/=length; - } - void vec3Normalize(float a[4]) - { - float length; - length=sqrt(a[0]*a[0]+a[1]*a[1]+a[2]*a[2]); - a[0]/=length; - a[1]/=length; - a[2]/=length; - } - void mat4Add(float result[4][4], float a[4][4], float b[4][4]) - { - int i,j; - for (i=0;i<4;++i) - for (j=0;j<4;++j) - result[i][j]=a[i][j]+b[i][j]; - } - void mat4ConstMul(float result[4][4], float a[4][4], float b) - { - int i,j; - for (i=0;i<4;++i) - for (j=0;j<4;++j) - result[i][j]=a[i][j]*b; - } - void mat4Transpose(float result[4][4], float a[4][4]) - { - int i,j; - for (i=0;i<4;++i) - for (j=0;j<4;++j) - result[i][j]=a[j][i]; - } - void mat4Mat4Mul(float result[4][4], float a[4][4], float b[4][4]) - { - int i,j,k; - float temp; - - for (i=0;i<4;++i) - for (j=0;j<4;++j) - { - temp=0; - for(k=0;k<4;++k) - { - temp+=a[k][j]*b[i][k]; - } - result[i][j]=temp; - } - } - void vec4Mat4Mul(float result[4], float a[4], float b[4][4]) - { - int i,k; - float temp; - - for (i=0;i<4;++i) - { - temp=0; - for(k=0;k<4;++k) - { - temp+=a[k]*b[k][i]; - } - result[i]=temp; - } - } - void mat4Vec4Mul(float result[4], float a[4][4], float b[4]) - { - int i,k; - float temp; - for (i=0;i<4;++i) - { - temp=0; - for(k=0;k<4;++k) - { - temp+=a[i][k]*b[k]; - } - result[i]=temp; - } - } - void mat4CreateIdentity (float result[4][4]) - { - int i; - for (i=0;i<4;i++) - { - result[i][0] = 0; - result[i][1] = 0; - result[i][2] = 0; - result[i][3] = 0; - } - result [0][0] = 1; - result [1][1] = 1; - result [2][2] = 1; - result [3][3] = 1; - } - void mat4CreateScale (float result[4][4], float x, float y, float z) - { - int i; - for (i=0;i<4;i++) - { - result[i][0] = 0; - result[i][1] = 0; - result[i][2] = 0; - result[i][3] = 0; - } - result [0][0] = x; - result [1][1] = y; - result [2][2] = z; - result [3][3] = 1; - } - - void mat4CreateTranslation (float result[4][4], float x, float y, float z) - { - int i; - for (i=0;i<4;i++) - { - result[i][0] = 0; - result[i][1] = 0; - result[i][2] = 0; - result[i][3] = 0; - } - result [3][0] = x; - result [3][1] = y; - result [3][2] = z; - result [0][0] = 1; - result [1][1] = 1; - result [2][2] = 1; - result [3][3] = 1; - - } - - void mat4CreateProjection (float result[4][4], float w, float h, float zn, float zf) - { - for (int i=0;i<4;i++) - { - result[i][0] = 0; - result[i][1] = 0; - result[i][2] = 0; - result[i][3] = 0; - } - result [0][0] = zn/w; - result [1][1] = zn/h; - result [2][2] = -(zf+zn)/(zf-zn); - result [3][2] = -2.0f*zf*zn/(zf-zn); - result [2][3] = -1.0f; - } - - void mat4CreateView (float result[4][4], float eyepoint[3], float lookatpoint[3]) - { - float xaxis[3]; - float yaxis[3]; - float zaxis[3]; - float up[3] = {0.0f,0.0f, 1.0f}; - - zaxis[0] = - lookatpoint[0] + eyepoint[0]; - zaxis[1] = - lookatpoint[1] + eyepoint[1]; - zaxis[2] = - lookatpoint[2] + eyepoint[2]; - - vec3Normalize(zaxis); - vec3CrossProductNormalized(xaxis, up, zaxis); - vec3CrossProductNormalized(yaxis, zaxis, xaxis); - - result[0][0] = xaxis[0]; - result[0][1] = yaxis[0]; - result[0][2] = zaxis[0]; - result[0][3] = 0; - result[1][0] = xaxis[1]; - result[1][1] = yaxis[1]; - result[1][2] = zaxis[1]; - result[1][3] = 0; - result[2][0] = xaxis[2]; - result[2][1] = yaxis[2]; - result[2][2] = zaxis[2]; - result[2][3] = 0; - result[3][0] = -vec3DotProduct(xaxis,eyepoint); - result[3][1] = -vec3DotProduct(yaxis,eyepoint); - result[3][2] = -vec3DotProduct(zaxis,eyepoint); - result[3][3] = 1.0f; - } - - void mat4CreateOrthoProjection (float result[4][4], float xmin, float xmax, float ymin, float ymax, float zmin, float zmax) - { - for(int i=0;i<4;i++) - { - result[i][0]=0; - result[i][1]=0; - result[i][2]=0; - result[i][3]=0; - } - result[0][0] = 2.0f/(xmax-xmin); - result[1][1] = 2.0f/(ymax-ymin); - result[2][2] = -2.0f/(zmax-zmin); - result[3][3] = 1.0f; - result[3][0] = - (xmax + xmin) / (xmax - xmin); - result[3][1] = - (ymax + ymin) / (ymax - ymin); - result[3][2] = - (zmax + zmin) / (zmax - zmin); - - } - - void mat4CreateRotation (float result[4][4], float angle, char axis) - { - int i; - for (i=0;i<4;i++) - { - result[i][0] = 0; - result[i][1] = 0; - result[i][2] = 0; - result[i][3] = 0; - } - result [3][3] = 1; - - switch (axis) - { - case 'x': - result[0][0]=1.0f; - result[0][1]=0.0f; - result[0][2]=0.0f; - result[1][0]=0.0f; - result[1][1]=cos(angle); - result[1][2]=sin(angle); - result[2][0]=0.0f; - result[2][1]=-sin(angle); - result[2][2]=cos(angle); - break; - case 'y': - result[0][0]=cos(angle); - result[0][1]=0.0f; - result[0][2]=-sin(angle); - result[1][0]=0.0f; - result[1][1]=1.0f; - result[1][2]=0.0f; - result[2][0]=sin(angle); - result[2][1]=0.0f; - result[2][2]=cos(angle); - break; - case 'z': - result[0][0]=cos(angle); - result[0][1]=sin(angle); - result[0][2]=0.0f; - result[1][0]=-sin(angle); - result[1][1]=cos(angle); - result[1][2]=0.0f; - result[2][0]=0.0f; - result[2][1]=0.0f; - result[2][2]=1.0f; - break; - } - - } - float sgn (float a) - { - if(a>0.0f) return (1.0f); - if(a<0.0f) return (-1.0f); - return(0.0f); - } - - float det2x2(float a,float b, - float c,float d) - { - return a * d - b * c; - } - - float det3x3(float a1,float a2,float a3, - float b1,float b2,float b3, - float c1,float c2,float c3) - { - float ans; - ans = a1 * det2x2( b2, b3, c2, c3) - - b1 * det2x2( a2, a3, c2, c3) - + c1 * det2x2( a2, a3, b2, b3); - return ans; - } - - float det4x4(float m[4][4]) - { - float a1,a2,a3,a4,b1,b2,b3,b4,c1,c2,c3,c4,d1,d2,d3,d4; - - - a1 = m[0][0]; b1 = m[0][1]; - c1 = m[0][2]; d1 = m[0][3]; - - a2 = m[1][0]; b2 = m[1][1]; - c2 = m[1][2]; d2 = m[1][3]; - - a3 = m[2][0]; b3 = m[2][1]; - c3 = m[2][2]; d3 = m[2][3]; - - a4 = m[3][0]; b4 = m[3][1]; - c4 = m[3][2]; d4 = m[3][3]; - - return a1 * det3x3( b2, b3, b4, c2, c3, c4, d2, d3, d4) - - b1 * det3x3( a2, a3, a4, c2, c3, c4, d2, d3, d4) - + c1 * det3x3( a2, a3, a4, b2, b3, b4, d2, d3, d4) - - d1 * det3x3( a2, a3, a4, b2, b3, b4, c2, c3, c4); - } - - void adjoint(float adj[4][4],float m[4][4]) - { - float a1,a2,a3,a4,b1,b2,b3,b4,c1,c2,c3,c4,d1,d2,d3,d4; - - a1 = m[0][0]; b1 = m[0][1]; - c1 = m[0][2]; d1 = m[0][3]; - - a2 = m[1][0]; b2 = m[1][1]; - c2 = m[1][2]; d2 = m[1][3]; - - a3 = m[2][0]; b3 = m[2][1]; - c3 = m[2][2]; d3 = m[2][3]; - - a4 = m[3][0]; b4 = m[3][1]; - c4 = m[3][2]; d4 = m[3][3]; - - adj[0][0] = det3x3( b2, b3, b4, c2, c3, c4, d2, d3, d4); - adj[1][0] = - det3x3( a2, a3, a4, c2, c3, c4, d2, d3, d4); - adj[2][0] = det3x3( a2, a3, a4, b2, b3, b4, d2, d3, d4); - adj[3][0] = - det3x3( a2, a3, a4, b2, b3, b4, c2, c3, c4); - - adj[0][1] = - det3x3( b1, b3, b4, c1, c3, c4, d1, d3, d4); - adj[1][1] = det3x3( a1, a3, a4, c1, c3, c4, d1, d3, d4); - adj[2][1] = - det3x3( a1, a3, a4, b1, b3, b4, d1, d3, d4); - adj[3][1] = det3x3( a1, a3, a4, b1, b3, b4, c1, c3, c4); - - adj[0][2] = det3x3( b1, b2, b4, c1, c2, c4, d1, d2, d4); - adj[1][2] = - det3x3( a1, a2, a4, c1, c2, c4, d1, d2, d4); - adj[2][2] = det3x3( a1, a2, a4, b1, b2, b4, d1, d2, d4); - adj[3][2] = - det3x3( a1, a2, a4, b1, b2, b4, c1, c2, c4); - - adj[0][3] = - det3x3( b1, b2, b3, c1, c2, c3, d1, d2, d3); - adj[1][3] = det3x3( a1, a2, a3, c1, c2, c3, d1, d2, d3); - adj[2][3] = - det3x3( a1, a2, a3, b1, b2, b3, d1, d2, d3); - adj[3][3] = det3x3( a1, a2, a3, b1, b2, b3, c1, c2, c3); - } - - void mat4Inverse(float result[4][4],float source[4][4]) - { - float adj[4][4]; - float det; - int i,j; - - adjoint(adj,source); - - det = det4x4(source); - if (fabs(det) < 1e-8f) - { - return ; - } - else - { - det = 1 / det; - for (i = 0; i < 4; i++) - for (j = 0; j < 4; j++) - result[i][j] = adj[i][j] * det; - } - } - - void mat4Mat4Copy (float result[4][4], float source[4][4]) - { - int i; - for (i=0;i<4;i++) - { - result[i][0] = source[i][0]; - result[i][1] = source[i][1]; - result[i][2] = source[i][2]; - result[i][3] = source[i][3]; - } - } diff --git a/sample/opengl/math_code.h b/sample/opengl/math_code.h deleted file mode 100644 index e03da47..0000000 --- a/sample/opengl/math_code.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * math_code.h - * - * Created on: 21.03.2011 - * Author: ttcheblokov - */ -#include <math.h> - -#ifndef MATH_CODE_H_ -#define MATH_CODE_H_ - -// vector and matrix math functions - void cutLowerHalfspace(float result[4][4], float level, float position, float viewmatrix[4][4], float projectionmatrix[4][4]); - void cutUpperHalfspace(float result[4][4], float level, float position, float viewmatrix[4][4], float projectionmatrix[4][4]); - void vec3CrossProductNormalized(float result[3], float a[3], float b[3]); - void vec4Sub(float a[4], float b[4], float c[4]); - void vec4Add(float a[4], float b[4], float c[4]); - float vec3DotProduct(float a[3], float b[3]); - float vec4DotProduct(float a[4], float b[4]); - void vec4Normalize(float a[4]); - void vec3Normalize(float a[3]); - void mat4Add(float result[4][4], float a[4][4], float b[4][4]); - void mat4ConstMul(float result[4][4], float a[4][4], float b); - void mat4Transpose(float result[4][4], float a[4][4]); - void mat4Mat4Mul(float result[4][4], float a[4][4], float b[4][4]); - void vec4Mat4Mul(float result[4], float a[4], float b[4][4]); - void mat4Vec4Mul(float result[4], float a[4][4], float b[4]); - void mat4CreateIdentity (float result[4][4]); - void mat4CreateScale (float result[4][4], float x, float y, float z); - void mat4CreateTranslation (float result[4][4], float x, float y, float z); - void mat4CreateView(float result[4][4], float eyepoint[3], float lookatpoint[3]); - void mat4CreateProjection (float result[4][4], float w, float h, float zn, float zf); - void mat4CreateOrthoProjection (float result[4][4], float xmin, float xmax, float ymin, float ymax, float zmin, float zmax); - void mat4CreateRotation (float result[4][4], float angle, char axis); - void mat4Inverse(float result[4][4],float source[4][4]); - void mat4Mat4Copy (float result[4][4], float source[4][4]); - - float sgn (float a); - float det2x2(float a,float b, float c,float d); - float det3x3(float a1,float a2,float a3, - float b1,float b2,float b3, - float c1,float c2,float c3); - float det4x4(float m[4][4]); - void adjoint(float adj[4][4],float m[4][4]); - - - - -#endif /* MATH_CODE_H_ */ diff --git a/sample/opengl/ocean_surface.cpp b/sample/opengl/ocean_surface.cpp Binary files differdeleted file mode 100644 index 8542e01..0000000 --- a/sample/opengl/ocean_surface.cpp +++ /dev/null diff --git a/sample/opengl/ocean_surface.h b/sample/opengl/ocean_surface.h deleted file mode 100644 index 945d2d7..0000000 --- a/sample/opengl/ocean_surface.h +++ /dev/null @@ -1,345 +0,0 @@ -// Copyright (c) 2011 NVIDIA Corporation. All rights reserved. -// -// TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED -// *AS IS* AND NVIDIA AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES, EITHER EXPRESS -// OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, NONINFRINGEMENT,IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL NVIDIA -// OR ITS SUPPLIERS BE LIABLE FOR ANY DIRECT, SPECIAL, INCIDENTAL, INDIRECT, OR -// CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS -// OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR ANY -// OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, -// EVEN IF NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -// -// Please direct any bugs or questions to [email protected] - -#include <GFSDK_WaveWorks.h> -#include <windows.h> -#include <stdio.h> -#include <GL/gl.h> - -// types for GL functoins not defined in WaveWorks -typedef void (APIENTRYP PFNGLCLEARDEPTHFPROC) (GLfloat d); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); - -// GL constants -#define GL_FRAMEBUFFER 0x8D40 -#define GL_TEXTURE0 0x84C0 -#define GL_COLOR_ATTACHMENT0 0x8CE0 -#define GL_FRAMEBUFFER_COMPLETE 0x8CD5 -#define GL_COMPILE_STATUS 0x8B81 -#define GL_LINK_STATUS 0x8B82 -#define GL_FRAGMENT_SHADER 0x8B30 -#define GL_VERTEX_SHADER 0x8B31 -#define GL_TESS_EVALUATION_SHADER 0x8E87 -#define GL_TESS_CONTROL_SHADER 0x8E88 -#define GL_GEOMETRY_SHADER 0x8DD9 -#define GL_ARRAY_BUFFER 0x8892 -#define GL_ELEMENT_ARRAY_BUFFER 0x8893 -#define GL_STATIC_DRAW 0x88E4 -#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 -#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2 -#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 -#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 -#define GL_SHADING_LANGUAGE_VERSION 0x8B8C -#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE -#define GL_ACTIVE_ATTRIBUTES 0x8B89 - -// DDS file reading related structures -typedef struct -{ - GLsizei width; - GLsizei height; - GLint components; - GLenum format; - GLint numMipmaps; - GLubyte *pixels; -} gliGenericImage; - -#ifndef _DDSURFACEDESC2 - // following structs & defines are copied from ddraw.h - - #ifndef DUMMYUNIONNAMEN - #if defined(__cplusplus) || !defined(NONAMELESSUNION) - #define DUMMYUNIONNAMEN(n) - #else - #define DUMMYUNIONNAMEN(n) u##n - #endif - #endif - - #ifndef MAKEFOURCC - #define MAKEFOURCC(ch0, ch1, ch2, ch3) \ - ((DWORD)(BYTE)(ch0) | ((DWORD)(BYTE)(ch1) << 8) | \ - ((DWORD)(BYTE)(ch2) << 16) | ((DWORD)(BYTE)(ch3) << 24 )) - #endif //defined(MAKEFOURCC) - - #define DDSD_PIXELFORMAT 0x00001000l - #define DDSD_CAPS 0x00000001l - #define DDSD_HEIGHT 0x00000002l - #define DDSD_WIDTH 0x00000004l - #define DDSD_PITCH 0x00000008l - #define DDSD_MIPMAPCOUNT 0x00020000l - #define DDPF_FOURCC 0x00000004l - #define DDPF_RGB 0x00000040l - #define FOURCC_DXT1 (MAKEFOURCC('D','X','T','1')) - #define FOURCC_DXT2 (MAKEFOURCC('D','X','T','2')) - #define FOURCC_DXT3 (MAKEFOURCC('D','X','T','3')) - #define FOURCC_DXT4 (MAKEFOURCC('D','X','T','4')) - #define FOURCC_DXT5 (MAKEFOURCC('D','X','T','5')) - - typedef struct _DDCOLORKEY - { - DWORD dwColorSpaceLowValue; // low boundary of color space that is to - // be treated as Color Key, inclusive - DWORD dwColorSpaceHighValue; // high boundary of color space that is - // to be treated as Color Key, inclusive - } DDCOLORKEY; - - typedef struct _DDPIXELFORMAT - { - DWORD dwSize; // size of structure - DWORD dwFlags; // pixel format flags - DWORD dwFourCC; // (FOURCC code) - union - { - DWORD dwRGBBitCount; // how many bits per pixel - DWORD dwYUVBitCount; // how many bits per pixel - DWORD dwZBufferBitDepth; // how many total bits/pixel in z buffer (including any stencil bits) - DWORD dwAlphaBitDepth; // how many bits for alpha channels - DWORD dwLuminanceBitCount; // how many bits per pixel - DWORD dwBumpBitCount; // how many bits per "buxel", total - DWORD dwPrivateFormatBitCount;// Bits per pixel of private driver formats. Only valid in texture - // format list and if DDPF_D3DFORMAT is set - } DUMMYUNIONNAMEN(1); - union - { - DWORD dwRBitMask; // mask for red bit - DWORD dwYBitMask; // mask for Y bits - DWORD dwStencilBitDepth; // how many stencil bits (note: dwZBufferBitDepth-dwStencilBitDepth is total Z-only bits) - DWORD dwLuminanceBitMask; // mask for luminance bits - DWORD dwBumpDuBitMask; // mask for bump map U delta bits - DWORD dwOperations; // DDPF_D3DFORMAT Operations - } DUMMYUNIONNAMEN(2); - union - { - DWORD dwGBitMask; // mask for green bits - DWORD dwUBitMask; // mask for U bits - DWORD dwZBitMask; // mask for Z bits - DWORD dwBumpDvBitMask; // mask for bump map V delta bits - struct - { - WORD wFlipMSTypes; // Multisample methods supported via flip for this D3DFORMAT - WORD wBltMSTypes; // Multisample methods supported via blt for this D3DFORMAT - } MultiSampleCaps; - - } DUMMYUNIONNAMEN(3); - union - { - DWORD dwBBitMask; // mask for blue bits - DWORD dwVBitMask; // mask for V bits - DWORD dwStencilBitMask; // mask for stencil bits - DWORD dwBumpLuminanceBitMask; // mask for luminance in bump map - } DUMMYUNIONNAMEN(4); - union - { - DWORD dwRGBAlphaBitMask; // mask for alpha channel - DWORD dwYUVAlphaBitMask; // mask for alpha channel - DWORD dwLuminanceAlphaBitMask;// mask for alpha channel - DWORD dwRGBZBitMask; // mask for Z channel - DWORD dwYUVZBitMask; // mask for Z channel - } DUMMYUNIONNAMEN(5); - } DDPIXELFORMAT; - - typedef struct _DDSCAPS2 - { - DWORD dwCaps; // capabilities of surface wanted - DWORD dwCaps2; - DWORD dwCaps3; - union - { - DWORD dwCaps4; - DWORD dwVolumeDepth; - } DUMMYUNIONNAMEN(1); - } DDSCAPS2; - - typedef struct _DDSURFACEDESC2 - { - DWORD dwSize; // size of the DDSURFACEDESC structure - DWORD dwFlags; // determines what fields are valid - DWORD dwHeight; // height of surface to be created - DWORD dwWidth; // width of input surface - union - { - LONG lPitch; // distance to start of next line (return value only) - DWORD dwLinearSize; // Formless late-allocated optimized surface size - } DUMMYUNIONNAMEN(1); - union - { - DWORD dwBackBufferCount; // number of back buffers requested - DWORD dwDepth; // the depth if this is a volume texture - } DUMMYUNIONNAMEN(5); - union - { - DWORD dwMipMapCount; // number of mip-map levels requestde - // dwZBufferBitDepth removed, use ddpfPixelFormat one instead - DWORD dwRefreshRate; // refresh rate (used when display mode is described) - DWORD dwSrcVBHandle; // The source used in VB::Optimize - } DUMMYUNIONNAMEN(2); - DWORD dwAlphaBitDepth; // depth of alpha buffer requested - DWORD dwReserved; // reserved - DWORD lpSurface; // pointer to the associated surface memory - union - { - DDCOLORKEY ddckCKDestOverlay; // color key for destination overlay use - DWORD dwEmptyFaceColor; // Physical color for empty cubemap faces - } DUMMYUNIONNAMEN(3); - DDCOLORKEY ddckCKDestBlt; // color key for destination blt use - DDCOLORKEY ddckCKSrcOverlay; // color key for source overlay use - DDCOLORKEY ddckCKSrcBlt; // color key for source blt use - union - { - DDPIXELFORMAT ddpfPixelFormat; // pixel format description of the surface - DWORD dwFVF; // vertex format description of vertex buffers - } DUMMYUNIONNAMEN(4); - DDSCAPS2 ddsCaps; // direct draw surface capabilities - DWORD dwTextureStage; // stage in multitexture cascade - } DDSURFACEDESC2; -#endif - - -class OceanSurface -{ - public: - OceanSurface(bool use_texture_arrays); - ~OceanSurface(); - - // Quadtree handle and shader mappings - GFSDK_WaveWorks_QuadtreeHandle hOceanQuadTree; - UINT* pQuadTreeShaderInputMappings; - UINT* pSimulationShaderInputMappings; - - // Quadtree initialization - gfsdk_waveworks_result InitQuadTree(const GFSDK_WaveWorks_Quadtree_Params& params); - - - // Initializing OpenGL functions addresses - HRESULT InitGLFunctions(void); - - // Creating OpenGL programs - GLuint LoadProgram(char *); - GLuint CompileShader(char *text, GLenum type); - - // Texture loading related methods - int LoadTexture(char * filename, GLuint * texID); - void CreateTextures(void); - - // Rendering related methods - void SetupNormalView(void); - void Render(GFSDK_WaveWorks_SimulationHandle hSim, GFSDK_WaveWorks_Simulation_Settings settings, bool Wireframe); - - // Constants - UINT ScreenWidth; - UINT ScreenHeight; - UINT MultiSampleCount; - UINT MultiSampleQuality; - - // Programs - GLuint WaterProgram; - - // Textures - GLuint FoamIntensityTextureID; - GLuint FoamIntensityTextureBindLocation; - GLuint FoamDiffuseTextureID; - GLuint FoamDiffuseTextureBindLocation; - - // GL resources allocated for WaveWorks during ocean surface rendering - GFSDK_WaveWorks_Simulation_GL_Pool glPool; - - // Camera reated variables - float CameraPosition[3]; - float LookAtPosition[3]; - - float NormalViewMatrix[4][4]; - float NormalProjMatrix[4][4]; - float NormalViewProjMatrix[4][4]; - - // Counters - double total_time; - float delta_time; - - // Input - int MouseX,MouseY; - float MouseDX,MouseDY; - float Alpha; - float Beta; - - // GL functions - PFNGLACTIVETEXTUREPROC glActiveTexture; - PFNGLATTACHSHADERPROC glAttachShader; - PFNGLBINDBUFFERPROC glBindBuffer; - PFNGLBINDFRAMEBUFFERPROC glBindFramebuffer; - PFNGLBINDTEXTUREPROC glBindTexture; - PFNGLBUFFERDATAPROC glBufferData; - PFNGLCHECKFRAMEBUFFERSTATUSPROC glCheckFramebufferStatus; - PFNGLCLEARCOLORPROC glClearColor; - PFNGLCLEARDEPTHFPROC glClearDepthf; - PFNGLCLEARPROC glClear; - PFNGLCOLORMASKPROC glColorMask; - PFNGLCOMPILESHADERPROC glCompileShader; - PFNGLCOMPRESSEDTEXIMAGE2DPROC glCompressedTexImage2D; - PFNGLCREATEPROGRAMPROC glCreateProgram; - PFNGLCREATESHADERPROC glCreateShader; - PFNGLDELETEBUFFERSPROC glDeleteBuffers; - PFNGLDELETEFRAMEBUFFERSPROC glDeleteFramebuffers; - PFNGLDELETEPROGRAMPROC glDeleteProgram; - PFNGLDELETESHADERPROC glDeleteShader; - PFNGLDELETETEXTURESPROC glDeleteTextures; - PFNGLDISABLEPROC glDisable; - PFNGLDISABLEVERTEXATTRIBARRAYPROC glDisableVertexAttribArray; - PFNGLDRAWELEMENTSPROC glDrawElements; - PFNGLENABLEVERTEXATTRIBARRAYPROC glEnableVertexAttribArray; - PFNGLFRAMEBUFFERTEXTURE2DPROC glFramebufferTexture2D; - PFNGLGENBUFFERSPROC glGenBuffers; - PFNGLGENERATEMIPMAPPROC glGenerateMipmap; - PFNGLGENFRAMEBUFFERSPROC glGenFramebuffers; - PFNGLGENTEXTURESPROC glGenTextures; - PFNGLGETATTRIBLOCATIONPROC glGetAttribLocation; - PFNGLGETERRORPROC glGetError; - PFNGLGETINTEGERVPROC glGetIntegerv; - PFNGLGETPROGRAMINFOLOGPROC glGetProgramInfoLog; - PFNGLGETPROGRAMIVPROC glGetProgramiv; - PFNGLGETSHADERINFOLOGPROC glGetShaderInfoLog; - PFNGLGETSHADERIVPROC glGetShaderiv; - PFNGLGETUNIFORMLOCATIONPROC glGetUniformLocation; - PFNGLLINKPROGRAMPROC glLinkProgram; - PFNGLMAPBUFFERRANGEPROC glMapBufferRange; - PFNGLPATCHPARAMETERIPROC glPatchParameteri; - PFNGLSHADERSOURCEPROC glShaderSource; - PFNGLTEXIMAGE2DPROC glTexImage2D; - PFNGLTEXPARAMETERFPROC glTexParameterf; - PFNGLTEXPARAMETERIPROC glTexParameteri; - PFNGLTEXSUBIMAGE2DPROC glTexSubImage2D; - PFNGLUNIFORM1FPROC glUniform1f; - PFNGLUNIFORM1IPROC glUniform1i; - PFNGLUNIFORM3FVPROC glUniform3fv; - PFNGLUNIFORM4FVPROC glUniform4fv; - PFNGLUNIFORMMATRIX3X4FVPROC glUniformMatrix3x4fv; - PFNGLUNIFORMMATRIX4FVPROC glUniformMatrix4fv; - PFNGLUNMAPBUFFERPROC glUnmapBuffer; - PFNGLUSEPROGRAMPROC glUseProgram; - PFNGLVERTEXATTRIBPOINTERPROC glVertexAttribPointer; - PFNGLVIEWPORTPROC glViewport; - PFNGLGENQUERIESPROC glGenQueries; - PFNGLDELETEQUERIESPROC glDeleteQueries; - PFNGLQUERYCOUNTERPROC glQueryCounter; - PFNGLGETQUERYOBJECTUI64VPROC glGetQueryObjectui64v; - PFNGLGETACTIVEATTRIBPROC glGetActiveAttrib; - PFNGLFRAMEBUFFERTEXTURELAYERPROC glFramebufferTextureLayer; - PFNGLTEXIMAGE3DPROC glTexImage3D; - PFNGLBLITFRAMEBUFFERPROC glBlitFramebuffer; - PFNGLREADBUFFERPROC glReadBuffer; - PFNGLDRAWBUFFERSPROC glDrawBuffers; -}; - -void checkError(const char *); - diff --git a/sample/opengl/sample_opengl.cpp b/sample/opengl/sample_opengl.cpp deleted file mode 100644 index 8bcebf6..0000000 --- a/sample/opengl/sample_opengl.cpp +++ /dev/null @@ -1,850 +0,0 @@ -// ocean_cufft_app.cpp : Defines the entry point for the console application. -// - -#include "math_code.h" -#include "ocean_surface.h" -#include "GFSDK_WaveWorks.h" -#include <windows.h> // for QueryPerformanceFrequency/QueryPerformanceCounter -#include "AntTweakBar.h" - -#ifndef PI -#define PI 3.14159265358979323846f -#endif - -OceanSurface* g_pOceanSurf = NULL; -GFSDK_WaveWorks_SimulationHandle g_hOceanSimulation = NULL; -GFSDK_WaveWorks_Simulation_Params g_ocean_simulation_param; -GFSDK_WaveWorks_Simulation_Settings g_ocean_simulation_settings; -GFSDK_WaveWorks_Quadtree_Params g_ocean_param_quadtree; -GFSDK_WaveWorks_Quadtree_Stats g_ocean_stats_quadtree; -GFSDK_WaveWorks_Simulation_Stats g_ocean_stats_simulation; -GFSDK_WaveWorks_Simulation_Stats g_ocean_stats_simulation_filtered; -GFSDK_WAVEWORKS_GLFunctions g_GLFunctions; -int g_max_detail_level; -long g_FPS; -long g_Second; -long g_FrameNumber; - -HINSTANCE g_hInstance; // GL window class instance -HWND g_hWnd; // GL window class handle -HDC g_hDC; // GL window device context handle -HGLRC g_hRC; // GL rendering context -LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); // forward declaration For WndProc -bool g_ExitApp = false; -bool g_WindowActive = true; -MSG g_Msg; // Windows message structure -bool g_PressedKeys[256]; // Array of pressed keys - -TwBar* g_pStatsBar; -TwBar* g_pControlsBar; - -// Controls -bool g_Wireframe = false; -bool g_SimulateWater = true; -bool g_ShowStats = false; - -// Callbacks for Controls AntTweakBar -static void TW_CALL CB_SetShowStats(const void *value, void * /*clientData*/) -{ - g_ShowStats = *(const bool *)value; - if(g_ShowStats) - { - TwDefine("Stats visible=true"); - } - else - { - TwDefine("Stats visible=false"); - } -} -static void TW_CALL CB_GetShowStats(void *value, void * /*clientData*/) -{ - *(bool *)value = g_ShowStats; -} - -static void TW_CALL CB_SetUseBeaufort(const void *value, void * /*clientData*/) -{ - g_ocean_simulation_settings.use_Beaufort_scale = *(const bool *)value; - if(g_ocean_simulation_settings.use_Beaufort_scale) - { - g_ocean_simulation_param.wind_speed = min(12.0f, g_ocean_simulation_param.wind_speed); - TwDefine("Controls/'Wind Speed' min=0 max = 12 step=0.1 precision=1"); - TwDefine("Controls/'Wave Amplitude' visible = false"); - TwDefine("Controls/'Chop Scale' visible = false"); - } - else - { - TwDefine("Controls/'Wind Speed' min=0 max = 50 step=0.1 precision=1"); - TwDefine("Controls/'Wave Amplitude' visible = true"); - TwDefine("Controls/'Chop Scale' visible = true"); - } - GFSDK_WaveWorks_Simulation_UpdateProperties(g_hOceanSimulation, g_ocean_simulation_settings, g_ocean_simulation_param); - GFSDK_WaveWorks_Quadtree_SetFrustumCullMargin(g_pOceanSurf->hOceanQuadTree, GFSDK_WaveWorks_Simulation_GetConservativeMaxDisplacementEstimate(g_hOceanSimulation)); -} -static void TW_CALL CB_GetUseBeaufort(void *value, void * /*clientData*/) -{ - *(bool *)value = g_ocean_simulation_settings.use_Beaufort_scale; -} - -static void TW_CALL CB_SetWaveAmplitude(const void *value, void * /*clientData*/) -{ - g_ocean_simulation_param.wave_amplitude = *(const float *)value; - GFSDK_WaveWorks_Simulation_UpdateProperties(g_hOceanSimulation, g_ocean_simulation_settings, g_ocean_simulation_param); - GFSDK_WaveWorks_Quadtree_SetFrustumCullMargin(g_pOceanSurf->hOceanQuadTree, GFSDK_WaveWorks_Simulation_GetConservativeMaxDisplacementEstimate(g_hOceanSimulation)); -} -static void TW_CALL CB_GetWaveAmplitude(void *value, void * /*clientData*/) -{ - *(float *)value = g_ocean_simulation_param.wave_amplitude; -} - -static void TW_CALL CB_SetChopScale(const void *value, void * /*clientData*/) -{ - g_ocean_simulation_param.choppy_scale = *(const float *)value; - GFSDK_WaveWorks_Simulation_UpdateProperties(g_hOceanSimulation, g_ocean_simulation_settings, g_ocean_simulation_param); -} -static void TW_CALL CB_GetChopScale(void *value, void * /*clientData*/) -{ - *(float *)value = g_ocean_simulation_param.choppy_scale; -} - -static void TW_CALL CB_SetWindSpeed(const void *value, void * /*clientData*/) -{ - g_ocean_simulation_param.wind_speed = *(const float *)value; - GFSDK_WaveWorks_Simulation_UpdateProperties(g_hOceanSimulation, g_ocean_simulation_settings, g_ocean_simulation_param); - GFSDK_WaveWorks_Quadtree_SetFrustumCullMargin(g_pOceanSurf->hOceanQuadTree, GFSDK_WaveWorks_Simulation_GetConservativeMaxDisplacementEstimate(g_hOceanSimulation)); -} -static void TW_CALL CB_GetWindSpeed(void *value, void * /*clientData*/) -{ - *(float *)value = g_ocean_simulation_param.wind_speed; -} - -static void TW_CALL CB_SetWindDependency(const void *value, void * /*clientData*/) -{ - g_ocean_simulation_param.wind_dependency = *(const float *)value; - GFSDK_WaveWorks_Simulation_UpdateProperties(g_hOceanSimulation, g_ocean_simulation_settings, g_ocean_simulation_param); - GFSDK_WaveWorks_Quadtree_SetFrustumCullMargin(g_pOceanSurf->hOceanQuadTree, GFSDK_WaveWorks_Simulation_GetConservativeMaxDisplacementEstimate(g_hOceanSimulation)); -} -static void TW_CALL CB_GetWindDependency(void *value, void * /*clientData*/) -{ - *(float *)value = g_ocean_simulation_param.wind_dependency; -} - -static void TW_CALL CB_SetTimeScale(const void *value, void * /*clientData*/) -{ - g_ocean_simulation_param.time_scale = *(const float *)value; - GFSDK_WaveWorks_Simulation_UpdateProperties(g_hOceanSimulation, g_ocean_simulation_settings, g_ocean_simulation_param); -} -static void TW_CALL CB_GetTimeScale(void *value, void * /*clientData*/) -{ - *(float *)value = g_ocean_simulation_param.time_scale; -} - -static void TW_CALL CB_SetAnisoLevel(const void *value, void * /*clientData*/) -{ - g_ocean_simulation_settings.aniso_level = *(const gfsdk_U8 *)value; - GFSDK_WaveWorks_Simulation_UpdateProperties(g_hOceanSimulation, g_ocean_simulation_settings, g_ocean_simulation_param); -} -static void TW_CALL CB_GetAnisoLevel(void *value, void * /*clientData*/) -{ - *(gfsdk_U8 *)value = g_ocean_simulation_settings.aniso_level; -} - -static void TW_CALL CB_SetDetailLevel(const void *value, void * /*clientData*/) -{ - if(GFSDK_WaveWorks_Simulation_DetailLevelIsSupported_GL2(*(const GFSDK_WaveWorks_Simulation_DetailLevel *)value)) - { - g_ocean_simulation_settings.detail_level = *(const GFSDK_WaveWorks_Simulation_DetailLevel *)value; - GFSDK_WaveWorks_Simulation_UpdateProperties(g_hOceanSimulation, g_ocean_simulation_settings, g_ocean_simulation_param); - } -} -static void TW_CALL CB_GetDetailLevel(void *value, void * /*clientData*/) -{ - *(gfsdk_U8 *)value = (gfsdk_U8)g_ocean_simulation_settings.detail_level; -} - -// Helper functions -void PrintGLInfo(void) -{ - printf ("\nVendor: %s", glGetString (GL_VENDOR)); - printf ("\nRenderer: %s", glGetString (GL_RENDERER)); - printf ("\nVersion: %s", glGetString (GL_VERSION)); - printf ("\nGLSL: %s", glGetString (GL_SHADING_LANGUAGE_VERSION)); - checkError ("dumpInfo"); -} - -// Rendering functions -void RenderFrame(void) -{ - static LARGE_INTEGER freq, counter, old_counter; - - if(g_SimulateWater) - do { - GFSDK_WaveWorks_Simulation_SetTime(g_hOceanSimulation, g_pOceanSurf->total_time); - GFSDK_WaveWorks_Simulation_KickGL2(g_hOceanSimulation, NULL); - } while(gfsdk_waveworks_result_NONE==GFSDK_WaveWorks_Simulation_GetStagingCursor(g_hOceanSimulation,NULL)); - - // getting simulation timings - GFSDK_WaveWorks_Simulation_GetStats(g_hOceanSimulation,g_ocean_stats_simulation); - - // rendering - g_pOceanSurf->Render(g_hOceanSimulation, g_ocean_simulation_settings, g_Wireframe); - - // getting quadtree stats - GFSDK_WaveWorks_Quadtree_GetStats(g_pOceanSurf->hOceanQuadTree, g_ocean_stats_quadtree); - - // Drawing AntTweakBars - TwDraw(); - SwapBuffers(g_hDC); - g_FrameNumber++; - - // timing - QueryPerformanceFrequency(&freq); - QueryPerformanceCounter(&counter); - - g_pOceanSurf->delta_time = (float)(((double)(counter.QuadPart) - (double)(old_counter.QuadPart))/(double)freq.QuadPart); - g_pOceanSurf->total_time += g_pOceanSurf->delta_time; - if(g_pOceanSurf->total_time>=36000.0f) g_pOceanSurf->total_time=0; - old_counter = counter; - - if((long)(floor(g_pOceanSurf->total_time)) > g_Second) - { - g_FPS = g_FrameNumber/((long)(floor(g_pOceanSurf->total_time)) - g_Second); - g_Second = (long)(ceil(g_pOceanSurf->total_time)); - g_FrameNumber = 0; - } - - // exponential filtering for stats - g_ocean_stats_simulation_filtered.CPU_main_thread_wait_time = g_ocean_stats_simulation_filtered.CPU_main_thread_wait_time*0.98f + 0.02f*g_ocean_stats_simulation.CPU_main_thread_wait_time; - g_ocean_stats_simulation_filtered.CPU_threads_start_to_finish_time = g_ocean_stats_simulation_filtered.CPU_threads_start_to_finish_time*0.98f + 0.02f*g_ocean_stats_simulation.CPU_threads_start_to_finish_time; - g_ocean_stats_simulation_filtered.CPU_threads_total_time = g_ocean_stats_simulation_filtered.CPU_threads_total_time*0.98f + 0.02f*g_ocean_stats_simulation.CPU_threads_total_time; - g_ocean_stats_simulation_filtered.GPU_simulation_time = g_ocean_stats_simulation_filtered.GPU_simulation_time*0.98f + 0.02f*g_ocean_stats_simulation.GPU_simulation_time; - g_ocean_stats_simulation_filtered.GPU_FFT_simulation_time = g_ocean_stats_simulation_filtered.GPU_FFT_simulation_time*0.98f + 0.02f*g_ocean_stats_simulation.GPU_FFT_simulation_time; - g_ocean_stats_simulation_filtered.GPU_gfx_time = g_ocean_stats_simulation_filtered.GPU_gfx_time*0.98f + 0.02f*g_ocean_stats_simulation.GPU_gfx_time; - g_ocean_stats_simulation_filtered.GPU_update_time = g_ocean_stats_simulation_filtered.GPU_update_time*0.98f + 0.02f*g_ocean_stats_simulation.GPU_update_time; -} - -// Input functions -void ProcessWSADKeys() -{ - if(g_pOceanSurf) - { - float direction[3]; - float strafe[3]; - float up[3] = {0.0f,0.0f,1.0f}; - - direction[0]=g_pOceanSurf->LookAtPosition[0] - g_pOceanSurf->CameraPosition[0]; - direction[1]=g_pOceanSurf->LookAtPosition[1] - g_pOceanSurf->CameraPosition[1]; - direction[2]=g_pOceanSurf->LookAtPosition[2] - g_pOceanSurf->CameraPosition[2]; - vec3Normalize(direction); - vec3CrossProductNormalized(strafe,up,direction); - - if(g_PressedKeys[87]) //'w' - { - g_pOceanSurf->CameraPosition[0]+=0.5f*direction[0]; - g_pOceanSurf->CameraPosition[1]+=0.5f*direction[1]; - g_pOceanSurf->CameraPosition[2]+=0.5f*direction[2]; - g_pOceanSurf->LookAtPosition[0]+=0.5f*direction[0]; - g_pOceanSurf->LookAtPosition[1]+=0.5f*direction[1]; - g_pOceanSurf->LookAtPosition[2]+=0.5f*direction[2]; - } - if(g_PressedKeys[83]) //'s' - { - g_pOceanSurf->CameraPosition[0]-=0.5f*direction[0]; - g_pOceanSurf->CameraPosition[1]-=0.5f*direction[1]; - g_pOceanSurf->CameraPosition[2]-=0.5f*direction[2]; - g_pOceanSurf->LookAtPosition[0]-=0.5f*direction[0]; - g_pOceanSurf->LookAtPosition[1]-=0.5f*direction[1]; - g_pOceanSurf->LookAtPosition[2]-=0.5f*direction[2]; - } - if(g_PressedKeys[65]) //'a' - { - g_pOceanSurf->CameraPosition[0]+=0.5f*strafe[0]; - g_pOceanSurf->CameraPosition[1]+=0.5f*strafe[1]; - g_pOceanSurf->CameraPosition[2]+=0.5f*strafe[2]; - g_pOceanSurf->LookAtPosition[0]+=0.5f*strafe[0]; - g_pOceanSurf->LookAtPosition[1]+=0.5f*strafe[1]; - g_pOceanSurf->LookAtPosition[2]+=0.5f*strafe[2]; - } - if(g_PressedKeys[68]) //'d' - { - g_pOceanSurf->CameraPosition[0]-=0.5f*strafe[0]; - g_pOceanSurf->CameraPosition[1]-=0.5f*strafe[1]; - g_pOceanSurf->CameraPosition[2]-=0.5f*strafe[2]; - g_pOceanSurf->LookAtPosition[0]-=0.5f*strafe[0]; - g_pOceanSurf->LookAtPosition[1]-=0.5f*strafe[1]; - g_pOceanSurf->LookAtPosition[2]-=0.5f*strafe[2]; - } - } -} - -void ProcessMouseMotion(int MouseX, int MouseY, int LButtonPressed) -{ - if(g_pOceanSurf) - { - float initial_direction[4]={1.0f,0.0f,0.0f,1.0f}; - float direction[4]; - float r1[4][4],r2[4][4],rotation[4][4]; - - if(LButtonPressed) - { - g_pOceanSurf->MouseDX = (float)MouseX - (float)g_pOceanSurf->MouseX; - g_pOceanSurf->MouseDY = (float)MouseY - (float)g_pOceanSurf->MouseY; - } - else - { - g_pOceanSurf->MouseDX = 0; - g_pOceanSurf->MouseDY = 0; - } - g_pOceanSurf->MouseX = MouseX; - g_pOceanSurf->MouseY = MouseY; - - - g_pOceanSurf->Alpha+=g_pOceanSurf->MouseDX*0.002f; - g_pOceanSurf->Beta+=g_pOceanSurf->MouseDY*0.002f; - if(g_pOceanSurf->Beta>PI*0.49f)g_pOceanSurf->Beta = PI*0.49f; - if(g_pOceanSurf->Beta<-PI*0.49f)g_pOceanSurf->Beta = -PI*0.49f; - mat4CreateRotation(r1,g_pOceanSurf->Alpha,'z'); - mat4CreateRotation(r2,-g_pOceanSurf->Beta,'y'); - mat4Mat4Mul(rotation,r1,r2); - vec4Mat4Mul(direction,initial_direction,rotation); - g_pOceanSurf->LookAtPosition[0]=g_pOceanSurf->CameraPosition[0]+direction[0]; - g_pOceanSurf->LookAtPosition[1]=g_pOceanSurf->CameraPosition[1]+direction[1]; - g_pOceanSurf->LookAtPosition[2]=g_pOceanSurf->CameraPosition[2]+direction[2]; - } -} - -// GL Window related functions -void KillGLWindow(void) -{ - // do we have a rendering context? - if (g_hRC) - { - // are we able to release the DC and RC? - if (!wglMakeCurrent(NULL,NULL)) - { - MessageBox(NULL,L"Release of DC and RC failed.",L"SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION); - } - // are we able to delete the RC? - if (!wglDeleteContext(g_hRC)) - { - MessageBox(NULL,L"Release rendering context failed.",L"SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION); - } - g_hRC = NULL; - } - - // are we able to release the DC - if (g_hDC && !ReleaseDC(g_hWnd,g_hDC)) - { - MessageBox(NULL,L"Release device context failed.",L"SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION); - g_hDC = NULL; - } - - // are we able to destroy the window? - if (g_hWnd && !DestroyWindow(g_hWnd)) - { - MessageBox(NULL,L"Could not release window handle.",L"SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION); - g_hWnd = NULL; - } - - // are we able to unregister class? - if (!UnregisterClass(L"OpenGL",g_hInstance)) - { - MessageBox(NULL,L"Could not unregister class.",L"SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION); - g_hInstance = NULL; - } -} - -BOOL CreateGLWindow(LPCWSTR title, int width, int height, byte bpp) -{ - GLuint PixelFormat; // holds the results after searching for a match - WNDCLASS wc; // windows class structure - DWORD dwExStyle; // window extended style - DWORD dwStyle; // window style - RECT WindowRect; // grabs rectangle upper left / lower right values - WindowRect.left=(long)0; // set left value to 0 - WindowRect.right=(long)width; // set right value to requested width - WindowRect.top=(long)0; // set top value to 0 - WindowRect.bottom=(long)height; // set bottom value to requested height - - g_hInstance = GetModuleHandle(NULL); // grab an instance for our window - wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; // redraw on size, and own DC for window. - wc.lpfnWndProc = (WNDPROC) WndProc; // WndProc handles messages - wc.cbClsExtra = 0; // no extra window data - wc.cbWndExtra = 0; // no extra window data - wc.hInstance = g_hInstance; // set the instance - wc.hIcon = LoadIcon(NULL, IDI_WINLOGO); // load the default icon - wc.hCursor = LoadCursor(NULL, IDC_ARROW); // load the arrow pointer - wc.hbrBackground = NULL; // no background required for GL - wc.lpszMenuName = NULL; // we don't want a menu - wc.lpszClassName = L"OpenGL"; // set the class name - - // attempt to register the window class - if (!RegisterClass(&wc)) - { - MessageBox(NULL,L"Failed to register the window class.",L"ERROR",MB_OK|MB_ICONEXCLAMATION); - return FALSE; // Return FALSE - } - dwExStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE; - dwStyle = WS_OVERLAPPEDWINDOW; - - // adjust window to true requested size - AdjustWindowRectEx(&WindowRect, dwStyle, FALSE, dwExStyle); - - // create the window - g_hWnd = CreateWindowEx(dwExStyle, // extended style for the window - L"OpenGL", // class name - title, // window title - dwStyle | // defined window style - WS_CLIPSIBLINGS | // required window style - WS_CLIPCHILDREN, // required window style - 0, 0, // window position - WindowRect.right-WindowRect.left, // calculate window width - WindowRect.bottom-WindowRect.top, // calculate window height - NULL, // no parent window - NULL, // no menu - g_hInstance, // instance - NULL); // dont pass anything to WM_CREATE - if (!g_hWnd) - { - KillGLWindow(); - MessageBox(NULL,L"Window creation error.",L"ERROR",MB_OK|MB_ICONEXCLAMATION); - return FALSE; - } - - static PIXELFORMATDESCRIPTOR pfd = - { - sizeof(PIXELFORMATDESCRIPTOR), // size of this pixel format descriptor - 1, // version number - PFD_DRAW_TO_WINDOW | // format must support window - PFD_SUPPORT_OPENGL | // format must support OpenGL - PFD_DOUBLEBUFFER, // must support double buffering - PFD_TYPE_RGBA, // request an RGBA format - bpp, // select our color depth - 0, 0, 0, 0, 0, 0, // color bits ignored - 0, // no alpha buffer - 0, // shift bit ignored - 0, // no accumulation buffer - 0, 0, 0, 0, // accumulation bits ignored - 32, // 32bit z-buffer (depth buffer) - 0, // no stencil buffer - 0, // no auxiliary buffer - PFD_MAIN_PLANE, // main drawing layer - 0, // reserved - 0, 0, 0 // layer masks ignored - }; - - // did we get a device context? - g_hDC = GetDC(g_hWnd); - if (!g_hDC) - { - KillGLWindow(); - MessageBox(NULL,L"Can't create a GL device context.",L"ERROR",MB_OK|MB_ICONEXCLAMATION); - return FALSE; - } - - // did windows find a matching pixel format? - PixelFormat = ChoosePixelFormat(g_hDC,&pfd); - if (!PixelFormat) - { - KillGLWindow(); - MessageBox(NULL,L"Can't find a suitable pixelformat.",L"ERROR",MB_OK|MB_ICONEXCLAMATION); - return FALSE; - } - - // are we able to set the pixel format? - if(!SetPixelFormat(g_hDC,PixelFormat,&pfd)) - { - KillGLWindow(); - MessageBox(NULL,L"Can't set the pixelformat.",L"ERROR",MB_OK|MB_ICONEXCLAMATION); - return FALSE; - } - - // are we able to get a rendering context? - g_hRC=wglCreateContext(g_hDC); - if (!g_hRC) - { - KillGLWindow(); - MessageBox(NULL,L"Can't create a GL rendering context.",L"ERROR",MB_OK|MB_ICONEXCLAMATION); - return FALSE; - } - - // try to activate the rendering context - if(!wglMakeCurrent(g_hDC,g_hRC)) - { - KillGLWindow(); - MessageBox(NULL,L"Can't activate the GL rendering context.",L"ERROR",MB_OK|MB_ICONEXCLAMATION); - return FALSE; - } - - ShowWindow(g_hWnd,SW_SHOW); - SetForegroundWindow(g_hWnd); - SetFocus(g_hWnd); - return TRUE; -} - - -int main(void) -{ - gfsdk_waveworks_result res; - if(!CreateGLWindow(L"sample_opengl", 1280, 720, 32)) - { - return 0; - } - - PrintGLInfo(); - - // Creating OceanSurface instance - - g_ocean_simulation_settings.fft_period = 1000.0f; - g_ocean_simulation_settings.detail_level = (GFSDK_WaveWorks_Simulation_DetailLevel)g_max_detail_level; - g_ocean_simulation_settings.readback_displacements = false; - g_ocean_simulation_settings.num_readback_FIFO_entries = 0; - g_ocean_simulation_settings.aniso_level = 4; - g_ocean_simulation_settings.CPU_simulation_threading_model = GFSDK_WaveWorks_Simulation_CPU_Threading_Model_Automatic; - g_ocean_simulation_settings.use_Beaufort_scale = true; - g_ocean_simulation_settings.num_GPUs = 1; - g_ocean_simulation_settings.use_texture_arrays = true; - g_ocean_simulation_settings.enable_CUDA_timers = true; - - g_pOceanSurf = new OceanSurface(g_ocean_simulation_settings.use_texture_arrays); - - // Initializing GL functions to be passed to WaveWorks, in alphabetic order - g_GLFunctions.glGetError = g_pOceanSurf->glGetError; - g_GLFunctions.glGetIntegerv = g_pOceanSurf->glGetIntegerv; - g_GLFunctions.glTexParameterf = g_pOceanSurf->glTexParameterf; - g_GLFunctions.glTexParameteri = g_pOceanSurf->glTexParameteri; - g_GLFunctions.glTexImage2D = g_pOceanSurf->glTexImage2D; - g_GLFunctions.glTexSubImage2D = g_pOceanSurf->glTexSubImage2D; - g_GLFunctions.glClear = g_pOceanSurf->glClear; - g_GLFunctions.glClearColor = g_pOceanSurf->glClearColor; - g_GLFunctions.glColorMask = g_pOceanSurf->glColorMask; - g_GLFunctions.glDisable = g_pOceanSurf->glDisable; - g_GLFunctions.glViewport = g_pOceanSurf->glViewport; - g_GLFunctions.glBindTexture = g_pOceanSurf->glBindTexture; - g_GLFunctions.glDeleteTextures = g_pOceanSurf->glDeleteTextures; - g_GLFunctions.glGenTextures = g_pOceanSurf->glGenTextures; - g_GLFunctions.glDrawElements = g_pOceanSurf->glDrawElements; - g_GLFunctions.glActiveTexture = g_pOceanSurf->glActiveTexture; - g_GLFunctions.glBindBuffer = g_pOceanSurf->glBindBuffer; - g_GLFunctions.glDeleteBuffers = g_pOceanSurf->glDeleteBuffers; - g_GLFunctions.glGenBuffers = g_pOceanSurf->glGenBuffers; - g_GLFunctions.glBufferData = g_pOceanSurf->glBufferData; - g_GLFunctions.glMapBufferRange = g_pOceanSurf->glMapBufferRange; - g_GLFunctions.glUnmapBuffer = g_pOceanSurf->glUnmapBuffer; - g_GLFunctions.glAttachShader = g_pOceanSurf->glAttachShader; - g_GLFunctions.glCompileShader = g_pOceanSurf->glCompileShader; - g_GLFunctions.glCreateProgram = g_pOceanSurf->glCreateProgram; - g_GLFunctions.glCreateShader = g_pOceanSurf->glCreateShader; - g_GLFunctions.glDeleteProgram = g_pOceanSurf->glDeleteProgram; - g_GLFunctions.glDeleteShader = g_pOceanSurf->glDeleteShader; - g_GLFunctions.glDisableVertexAttribArray = g_pOceanSurf->glDisableVertexAttribArray; - g_GLFunctions.glEnableVertexAttribArray = g_pOceanSurf->glEnableVertexAttribArray; - g_GLFunctions.glGetAttribLocation = g_pOceanSurf->glGetAttribLocation; - g_GLFunctions.glGetProgramiv = g_pOceanSurf->glGetProgramiv; - g_GLFunctions.glGetProgramInfoLog = g_pOceanSurf->glGetProgramInfoLog; - g_GLFunctions.glGetShaderiv = g_pOceanSurf->glGetShaderiv; - g_GLFunctions.glGetShaderInfoLog = g_pOceanSurf->glGetShaderInfoLog; - g_GLFunctions.glGetUniformLocation = g_pOceanSurf->glGetUniformLocation; - g_GLFunctions.glLinkProgram = g_pOceanSurf->glLinkProgram; - g_GLFunctions.glShaderSource = g_pOceanSurf->glShaderSource; - g_GLFunctions.glUseProgram = g_pOceanSurf->glUseProgram; - g_GLFunctions.glUniform1f = g_pOceanSurf->glUniform1f; - g_GLFunctions.glUniform1i = g_pOceanSurf->glUniform1i; - g_GLFunctions.glUniform3fv = g_pOceanSurf->glUniform3fv; - g_GLFunctions.glUniform4fv = g_pOceanSurf->glUniform4fv; - g_GLFunctions.glVertexAttribPointer = g_pOceanSurf->glVertexAttribPointer; - g_GLFunctions.glUniformMatrix3x4fv = g_pOceanSurf->glUniformMatrix3x4fv; - g_GLFunctions.glBindFramebuffer = g_pOceanSurf->glBindFramebuffer; - g_GLFunctions.glDeleteFramebuffers = g_pOceanSurf->glDeleteFramebuffers; - g_GLFunctions.glGenFramebuffers = g_pOceanSurf->glGenFramebuffers; - g_GLFunctions.glCheckFramebufferStatus = g_pOceanSurf->glCheckFramebufferStatus; - g_GLFunctions.glGenerateMipmap = g_pOceanSurf->glGenerateMipmap; - g_GLFunctions.glFramebufferTexture2D = g_pOceanSurf->glFramebufferTexture2D; - g_GLFunctions.glPatchParameteri = g_pOceanSurf->glPatchParameteri; - g_GLFunctions.glGenQueries = g_pOceanSurf->glGenQueries; - g_GLFunctions.glDeleteQueries = g_pOceanSurf->glDeleteQueries; - g_GLFunctions.glQueryCounter = g_pOceanSurf->glQueryCounter; - g_GLFunctions.glGetQueryObjectui64v = g_pOceanSurf->glGetQueryObjectui64v; - g_GLFunctions.glGetActiveAttrib = g_pOceanSurf->glGetActiveAttrib; - g_GLFunctions.glFramebufferTextureLayer = g_pOceanSurf->glFramebufferTextureLayer; - g_GLFunctions.glBlitFramebuffer = g_pOceanSurf->glBlitFramebuffer; - g_GLFunctions.glTexImage3D = g_pOceanSurf->glTexImage3D; - g_GLFunctions.glReadBuffer = g_pOceanSurf->glReadBuffer; - g_GLFunctions.glDrawBuffers = g_pOceanSurf->glDrawBuffers; - - - // initializing WaveWorks - fprintf(stdout, "\nInitializing:\n"); - res = GFSDK_WaveWorks_InitGL2(&g_GLFunctions, NULL, GFSDK_WAVEWORKS_API_GUID); - if(res == gfsdk_waveworks_result_OK) - { - fprintf(stdout, "GFSDK_WaveWorks_InitGL2: OK\n"); - } - else - { - fprintf(stdout, "GFSDK_WaveWorks_InitGL2 ERROR: %i, exiting..\n", res); - return res; - } - - // initializing QuadTree - g_ocean_param_quadtree.min_patch_length = 40.0f; - g_ocean_param_quadtree.upper_grid_coverage = 64.0f; - g_ocean_param_quadtree.mesh_dim = 128; - g_ocean_param_quadtree.sea_level = 0.f; - g_ocean_param_quadtree.auto_root_lod = 10; - g_ocean_param_quadtree.tessellation_lod = 100.0f; - g_ocean_param_quadtree.geomorphing_degree = 1.f; - g_ocean_param_quadtree.enable_CPU_timers = true; - res = g_pOceanSurf->InitQuadTree(g_ocean_param_quadtree); - if(res == gfsdk_waveworks_result_OK) - { - fprintf(stdout, "InitQuadTree: OK\n"); - } - else - { - fprintf(stdout, "InitQuadTree ERROR: %i, exiting..\n", res); - return res; - } - - // checking available detail level - int detail_level = 0; - for(; detail_level != Num_GFSDK_WaveWorks_Simulation_DetailLevels; ++detail_level) { - if(!GFSDK_WaveWorks_Simulation_DetailLevelIsSupported_GL2((GFSDK_WaveWorks_Simulation_DetailLevel)detail_level)) - break; - } - if(0 == detail_level) - return false; - g_max_detail_level = (GFSDK_WaveWorks_Simulation_DetailLevel)(detail_level - 1); - - // initializing simulation - g_ocean_simulation_param.time_scale = 0.5f; - g_ocean_simulation_param.wave_amplitude = 1.0f; - g_ocean_simulation_param.wind_dir.x = 0.8f; - g_ocean_simulation_param.wind_dir.y = 0.6f; - g_ocean_simulation_param.wind_speed = 9.0f; - g_ocean_simulation_param.wind_dependency = 0.98f; - g_ocean_simulation_param.choppy_scale = 1.f; - g_ocean_simulation_param.small_wave_fraction = 0.f; - g_ocean_simulation_param.foam_dissipation_speed = 0.6f; - g_ocean_simulation_param.foam_falloff_speed = 0.985f; - g_ocean_simulation_param.foam_generation_amount = 0.12f; - g_ocean_simulation_param.foam_generation_threshold = 0.37f; - - res = GFSDK_WaveWorks_Simulation_CreateGL2(g_ocean_simulation_settings, g_ocean_simulation_param, (void*) g_hRC, &g_hOceanSimulation); - if(res == gfsdk_waveworks_result_OK) - { - fprintf(stdout, "GFSDK_WaveWorks_Simulation_CreateGL2: OK\n"); - } - else - { - fprintf(stdout, "GFSDK_WaveWorks_Simulation_CreateGL2 ERROR: %i, exiting..\n", res); - return res; - } - GFSDK_WaveWorks_Simulation_UpdateProperties(g_hOceanSimulation, g_ocean_simulation_settings, g_ocean_simulation_param); - GFSDK_WaveWorks_Quadtree_SetFrustumCullMargin(g_pOceanSurf->hOceanQuadTree, GFSDK_WaveWorks_Simulation_GetConservativeMaxDisplacementEstimate(g_hOceanSimulation)); - - // initializing AntTweakBars - if(TwInit(TW_OPENGL, NULL)==0) - { - fprintf (stdout, "Error initializing AntTweakBar library, exiting..\n"); - // Cleanup WaveWorks - delete g_pOceanSurf; - GFSDK_WaveWorks_Simulation_Destroy(g_hOceanSimulation); - GFSDK_WaveWorks_ReleaseGL2(); - - // shutting down - KillGLWindow(); - return -1; - } - TwWindowSize(1280, 720); - - // Status bar - g_pStatsBar = TwNewBar("Stats"); - TwDefine(" Stats help='Times listed in Stats are Milliseconds'"); - TwDefine(" Stats size='400 200'"); - TwDefine(" Stats position='10 10'"); - TwDefine(" Stats alpha=0"); - TwDefine(" Stats movable=false"); - TwDefine(" Stats iconifiable=false"); - TwDefine(" Stats resizable=false"); - TwDefine(" Stats refresh=0.1"); - TwDefine(" Stats visible=false"); - TwAddVarRO(g_pStatsBar, "Frames Per Second", TW_TYPE_INT32, &g_FPS, ""); - TwAddVarRO(g_pStatsBar, "Quadtree Patches Drawn", TW_TYPE_INT32, &g_ocean_stats_quadtree.num_patches_drawn, ""); - TwAddSeparator(g_pStatsBar, NULL, NULL); - TwAddVarRO(g_pStatsBar, "CPU: Main Thread Wait Time", TW_TYPE_FLOAT, &g_ocean_stats_simulation_filtered.CPU_main_thread_wait_time, "precision=2"); - TwAddVarRO(g_pStatsBar, "CPU: Threads Start To Finish Time", TW_TYPE_FLOAT, &g_ocean_stats_simulation_filtered.CPU_threads_start_to_finish_time, "precision=2"); - TwAddVarRO(g_pStatsBar, "CPU: Threads Total Time", TW_TYPE_FLOAT, &g_ocean_stats_simulation_filtered.CPU_threads_total_time, "precision=2"); - TwAddVarRO(g_pStatsBar, "GPU: FFT Simulation Time", TW_TYPE_FLOAT, &g_ocean_stats_simulation_filtered.GPU_FFT_simulation_time, "precision=2"); - TwAddVarRO(g_pStatsBar, "GPU: GFX Time", TW_TYPE_FLOAT, &g_ocean_stats_simulation_filtered.GPU_gfx_time, "precision=2"); - TwAddVarRO(g_pStatsBar, "GPU: Simulation Time", TW_TYPE_FLOAT, &g_ocean_stats_simulation_filtered.GPU_simulation_time, "precision=2"); - TwAddVarRO(g_pStatsBar, "CPU: Update Time", TW_TYPE_FLOAT, &g_ocean_stats_simulation_filtered.GPU_update_time, "precision=2"); - - // Controls bar - g_pControlsBar = TwNewBar("Controls"); - TwDefine(" Controls size='300 700'"); - TwDefine(" Controls position='970 10'"); - TwDefine(" Controls alpha=0"); - TwDefine(" Controls movable=false"); - TwDefine(" Controls iconifiable=false"); - TwDefine(" Controls resizable=false"); - TwDefine(" Controls valueswidth=100"); - TwAddVarRW(g_pControlsBar, "Wireframe", TW_TYPE_BOOLCPP, &g_Wireframe, NULL); - TwAddVarRW(g_pControlsBar, "Simulate Water", TW_TYPE_BOOLCPP, &g_SimulateWater, NULL); - TwAddVarCB(g_pControlsBar, "Show Stats", TW_TYPE_BOOLCPP, CB_SetShowStats, CB_GetShowStats, &g_ShowStats, NULL); - TwAddSeparator(g_pControlsBar, NULL, NULL); - TwAddVarCB(g_pControlsBar, "Use Beaufort Presets", TW_TYPE_BOOLCPP, CB_SetUseBeaufort, CB_GetUseBeaufort, &g_ocean_simulation_settings.use_Beaufort_scale, NULL); - TwAddVarCB(g_pControlsBar, "Wave Amplitude", TW_TYPE_FLOAT, CB_SetWaveAmplitude, CB_GetWaveAmplitude, &g_ocean_simulation_param.wave_amplitude, "min=0 max=2 step=0.1 precision=1 visible=false"); - TwAddVarCB(g_pControlsBar, "Chop Scale", TW_TYPE_FLOAT, CB_SetChopScale, CB_GetChopScale, &g_ocean_simulation_param.choppy_scale, "min=0 max=1 step=0.1 precision=1 visible=false"); - TwAddVarCB(g_pControlsBar, "Wind Speed", TW_TYPE_FLOAT, CB_SetWindSpeed, CB_GetWindSpeed, &g_ocean_simulation_param.wind_speed, "min=0 max = 12 step=0.1 precision=1"); - TwAddVarCB(g_pControlsBar, "Wind Dependency", TW_TYPE_FLOAT, CB_SetWindDependency, CB_GetWindDependency, &g_ocean_simulation_param.wind_dependency, "min=0 max=1 step=0.1 precision=1"); - TwAddVarCB(g_pControlsBar, "Time Scale", TW_TYPE_FLOAT, CB_SetTimeScale, CB_GetTimeScale, &g_ocean_simulation_param.time_scale, "min=0.1 max=2 step=0.1 precision=1"); - TwAddVarCB(g_pControlsBar, "Aniso Level", TW_TYPE_INT8, CB_SetAnisoLevel, CB_GetAnisoLevel, &g_ocean_simulation_settings.aniso_level, "min=1 max=16 step=1"); - TwAddSeparator(g_pControlsBar, NULL, NULL); - TwEnumVal QualityEV[] = { {GFSDK_WaveWorks_Simulation_DetailLevel_Normal, "Normal"}, {GFSDK_WaveWorks_Simulation_DetailLevel_High, "High"}, {GFSDK_WaveWorks_Simulation_DetailLevel_Extreme, "Extreme"}}; - TwType qualityType; - qualityType = TwDefineEnum("Simulation Detail Level", QualityEV, 3); - TwAddVarCB(g_pControlsBar, "Simulation Detail Level", qualityType, CB_SetDetailLevel, CB_GetDetailLevel, &g_ocean_simulation_settings.detail_level, NULL); - - fprintf(stdout, "Entering main loop\n", res); - - // entering main loop - while(!g_ExitApp) - { - if (PeekMessage(&g_Msg,NULL,0,0,PM_REMOVE)) - { - if (g_Msg.message==WM_QUIT) - { - g_ExitApp=TRUE; - } - else - { - TranslateMessage(&g_Msg); - DispatchMessage(&g_Msg); - } - } - else - { - // draw the scene if there are no messages - if (g_WindowActive) - { - if (g_PressedKeys[VK_ESCAPE]) - { - g_ExitApp = TRUE; - } - else - { - ProcessWSADKeys(); - RenderFrame(); - // updating stats string for Stats AntTweakBar - - } - } - } - } - - // Cleanup AntTweakBars - TwTerminate(); - - // Cleanup WaveWorks - delete g_pOceanSurf; - GFSDK_WaveWorks_Simulation_Destroy(g_hOceanSimulation); - GFSDK_WaveWorks_ReleaseGL2(); - - // shutting down - KillGLWindow(); - return (int)g_Msg.wParam; -} - - -// message processing function -LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - - // pass messages to AntTweakBars - if( TwEventWin(hWnd, uMsg, wParam, lParam) ) // send event message to AntTweakBar - return 0; // event has been handled by AntTweakBar - - switch (uMsg) - { - case WM_ACTIVATE: // watch for window activate message - { - if (!HIWORD(wParam)) // check minimization state - { - g_WindowActive = TRUE; // program is active - } - else - { - g_WindowActive = FALSE; // program is no longer active - } - return 0; // return to the message loop - } - - case WM_SYSCOMMAND: - { - switch (wParam) - { - case SC_SCREENSAVE: // screensaver trying to start? - case SC_MONITORPOWER: // monitor trying to enter powersave? - return 0; // prevent from happening - } - break; - } - - case WM_CLOSE: - { - g_ExitApp = true; - PostQuitMessage(0); - return 0; - } - - case WM_KEYDOWN: - { - g_PressedKeys[wParam] = TRUE; - switch(wParam) - { - case 219: // "[" - g_ocean_simulation_settings.detail_level = GFSDK_WaveWorks_Simulation_DetailLevel((g_ocean_simulation_settings.detail_level + g_max_detail_level) % (g_max_detail_level+1)); - GFSDK_WaveWorks_Simulation_UpdateProperties(g_hOceanSimulation, g_ocean_simulation_settings, g_ocean_simulation_param); - GFSDK_WaveWorks_Quadtree_SetFrustumCullMargin(g_pOceanSurf->hOceanQuadTree, GFSDK_WaveWorks_Simulation_GetConservativeMaxDisplacementEstimate(g_hOceanSimulation)); - break; - case 221: // "]" - g_ocean_simulation_settings.detail_level = GFSDK_WaveWorks_Simulation_DetailLevel((g_ocean_simulation_settings.detail_level + 1) % (g_max_detail_level+1)); - GFSDK_WaveWorks_Simulation_UpdateProperties(g_hOceanSimulation, g_ocean_simulation_settings, g_ocean_simulation_param); - GFSDK_WaveWorks_Quadtree_SetFrustumCullMargin(g_pOceanSurf->hOceanQuadTree, GFSDK_WaveWorks_Simulation_GetConservativeMaxDisplacementEstimate(g_hOceanSimulation)); - break; - default: - break; - } - return 0; - } - - case WM_KEYUP: - { - g_PressedKeys[wParam] = FALSE; - return 0; - } - - case WM_SIZE: - { - if(g_pOceanSurf) - { - g_pOceanSurf->ScreenWidth = LOWORD(lParam); - g_pOceanSurf->ScreenHeight = HIWORD(lParam); - TwWindowSize(g_pOceanSurf->ScreenWidth, g_pOceanSurf->ScreenHeight); - int pos[2] = {g_pOceanSurf->ScreenWidth - 300 - 10, 10}; - int size[2] = {300, g_pOceanSurf->ScreenHeight - 20}; - TwSetParam(g_pControlsBar,NULL,"position",TW_PARAM_INT32, 2, &pos); - TwSetParam(g_pControlsBar,NULL,"size",TW_PARAM_INT32, 2, &size); - } - return 0; - } - - case WM_MOUSEMOVE: - { - ProcessMouseMotion(LOWORD(lParam), HIWORD(lParam), (wParam & MK_LBUTTON) > 0? true:false); - } - } - - // pass all remaining messages to DefWindowProc - return DefWindowProc(hWnd,uMsg,wParam,lParam); -} diff --git a/sample/opengl/water.glsl b/sample/opengl/water.glsl deleted file mode 100644 index 5dc2cf4..0000000 --- a/sample/opengl/water.glsl +++ /dev/null @@ -1,170 +0,0 @@ -<<<VSTEXT>>> -#version 420 core - -#define GFSDK_WAVEWORKS_GL - -#define GFSDK_WAVEWORKS_DECLARE_GEOM_VS_CONSTANT(Type,Label,Regoff) uniform Type Label; -#include "GFSDK_WaveWorks_Quadtree.fxh" - -#define GFSDK_WAVEWORKS_DECLARE_ATTR_VS_CONSTANT(Type,Label,Regoff) uniform Type Label; -#define GFSDK_WAVEWORKS_DECLARE_ATTR_VS_SAMPLER(Label,TextureLabel,Regoff) uniform sampler2D Label; -#define GFSDK_WAVEWORKS_DECLARE_ATTR_VS_SAMPLER_TEXTUREARRAY(Label,TextureLabel,Regoff) uniform sampler2DArray Label; -#define GFSDK_WAVEWORKS_DECLARE_ATTR_PS_CONSTANT(Type,Label,Regoff) uniform Type Label; -#define GFSDK_WAVEWORKS_DECLARE_ATTR_PS_SAMPLER(Label,TextureLabel,Regoff) uniform sampler2D Label; -#define GFSDK_WAVEWORKS_DECLARE_ATTR_PS_SAMPLER_TEXTUREARRAY(Label,TextureLabel,Regoff) uniform sampler2DArray Label; -#include "GFSDK_WaveWorks_Attributes.fxh" - -// User uniforms -uniform mat4x4 u_ViewProjMatrix; - -struct VSInputStruct -{ - GFSDK_WAVEWORKS_VERTEX_INPUT WaveWorksInput; -}; - -in VSInputStruct VSInput; -out GFSDK_WAVEWORKS_VERTEX_OUTPUT VSOutput; - -void main() -{ - VSOutput = GFSDK_WaveWorks_GetDisplacedVertex(VSInput.WaveWorksInput); - vec3 dwpos = VSOutput.pos_world; - gl_Position = u_ViewProjMatrix*vec4(dwpos,1.f); -} - - -<<<FSTEXT>>> -#version 420 core - -#define GFSDK_WAVEWORKS_GL - -#define GFSDK_WAVEWORKS_DECLARE_GEOM_VS_CONSTANT(Type,Label,Regoff) uniform Type Label; -#include "GFSDK_WaveWorks_Quadtree.fxh" - -#define GFSDK_WAVEWORKS_DECLARE_ATTR_VS_CONSTANT(Type,Label,Regoff) uniform Type Label; -#define GFSDK_WAVEWORKS_DECLARE_ATTR_VS_SAMPLER(Label,TextureLabel,Regoff) uniform sampler2D Label; -#define GFSDK_WAVEWORKS_DECLARE_ATTR_VS_SAMPLER_TEXTUREARRAY(Label,TextureLabel,Regoff) uniform sampler2DArray Label; -#define GFSDK_WAVEWORKS_DECLARE_ATTR_PS_CONSTANT(Type,Label,Regoff) uniform Type Label; -#define GFSDK_WAVEWORKS_DECLARE_ATTR_PS_SAMPLER(Label,TextureLabel,Regoff) uniform sampler2D Label; -#define GFSDK_WAVEWORKS_DECLARE_ATTR_PS_SAMPLER_TEXTUREARRAY(Label,TextureLabel,Regoff) uniform sampler2DArray Label; -#include "GFSDK_WaveWorks_Attributes.fxh" - -// User uniforms -uniform sampler2D g_texFoamIntensityMap; -uniform sampler2D g_texFoamDiffuseMap; - -// User local variables -vec3 g_SkyColor = {0.38, 0.45, 0.56}; -vec3 g_BendParam = {0.1, -0.4, 0.2}; - -vec3 g_SunDir = {0.936016, -0.343206, 0.0780013}; -vec3 g_WaterDeepColor={0.0,0.4,0.6}; -vec3 g_WaterScatterColor={0.0,0.7,0.6}; -vec2 g_WaterColorIntensity={0.2,0.1}; - -vec3 g_FoamColor = {0.90, 0.95, 1.0}; -vec3 g_FoamUnderwaterColor = {0.90, 0.95, 1.0}; - -// in & out variables -in GFSDK_WAVEWORKS_VERTEX_OUTPUT VSOutput; - -out vec4 color; - -void main() -{ - - GFSDK_WAVEWORKS_SURFACE_ATTRIBUTES surface_attributes = GFSDK_WaveWorks_GetSurfaceAttributes(VSOutput.interp); - - float fresnel_factor; - float diffuse_factor; - float specular_factor; - float scatter_factor; - - vec3 pixel_to_light_vector=g_SunDir; - vec3 pixel_to_eye_vector=surface_attributes.eye_dir; - vec3 reflected_eye_to_pixel_vector = reflect(-surface_attributes.eye_dir, surface_attributes.normal); - - // simulating scattering/double refraction: light hits the side of wave, travels some distance in water, and leaves wave on the other side - // it's difficult to do it physically correct without photon mapping/ray tracing, so using simple but plausible emulation below - - // only the crests of water waves generate double refracted light - scatter_factor=1.0*max(0,VSOutput.world_displacement.z*0.001+0.3); - - - // the waves that lie between camera and light projection on water plane generate maximal amount of double refracted light - scatter_factor*=pow(max(0.0,dot(normalize(vec3(pixel_to_light_vector.x,0.0,pixel_to_light_vector.z)),-pixel_to_eye_vector)),2.0); - - // the slopes of waves that are oriented back to light generate maximal amount of double refracted light - scatter_factor*=pow(max(0.0,0.5-0.5*dot(pixel_to_light_vector,surface_attributes.normal)),3.0); - - - // water crests gather more light than lobes, so more light is scattered under the crests - scatter_factor+=2.0*g_WaterColorIntensity.y*max(0,VSOutput.world_displacement.z*0.001+0.3)* - // the scattered light is best seen if observing direction is normal to slope surface - max(0,dot(pixel_to_eye_vector,surface_attributes.normal)); - - - // calculating fresnel factor - float r=(1.0 - 1.13)*(1.0 - 1.13)/(1.0 + 1.13); - fresnel_factor = r + (1.0-r)*pow(saturate(1.0 - dot(surface_attributes.normal,pixel_to_eye_vector)),4.0); - - // calculating diffuse intensity of water surface itself - diffuse_factor=g_WaterColorIntensity.x+g_WaterColorIntensity.y*max(0,dot(pixel_to_light_vector,surface_attributes.normal)); - - vec3 refraction_color=diffuse_factor*g_WaterDeepColor; - - // adding color that provide foam bubbles spread in water - refraction_color += g_FoamUnderwaterColor*saturate(surface_attributes.foam_turbulent_energy*0.2); - - // adding scatter light component - refraction_color+=g_WaterScatterColor*scatter_factor; - - // reflection color - vec3 reflection_color = g_SkyColor; - - // fading reflection color to half if reflected vector points below water surface - reflection_color.rgb *= 1.0 - 0.5*max(0.0,min(1.0,-reflected_eye_to_pixel_vector.z*4.0)); - - // applying Fresnel law - vec3 water_color = mix(refraction_color,reflection_color,fresnel_factor); - - // applying surface foam provided by turbulent energy - - // low frequency foam map - float foam_intensity_map_lf = 1.0*texture(g_texFoamIntensityMap, VSOutput.pos_world_undisplaced.xy*0.04*vec2(1,1)).x - 1.0; - - // high frequency foam map - float foam_intensity_map_hf = 1.0*texture(g_texFoamIntensityMap, VSOutput.pos_world_undisplaced.xy*0.15*vec2(1,1)).x - 1.0; - - // ultra high frequency foam map - float foam_intensity_map_uhf = 1.0*texture(g_texFoamIntensityMap, VSOutput.pos_world_undisplaced.xy*0.3*vec2(1,1)).x; - - float foam_intensity; - foam_intensity = saturate(foam_intensity_map_hf + min(3.5,1.0*surface_attributes.foam_turbulent_energy-0.2)); - foam_intensity += (foam_intensity_map_lf + min(1.5,1.0*surface_attributes.foam_turbulent_energy)); - - - foam_intensity -= 0.1*saturate(-surface_attributes.foam_surface_folding); - - foam_intensity = max(0,foam_intensity); - - foam_intensity *= 1.0+0.8*saturate(surface_attributes.foam_surface_folding); - - float foam_bubbles = texture(g_texFoamDiffuseMap, VSOutput.pos_world_undisplaced.xy).r; - foam_bubbles = saturate(5.0*(foam_bubbles-0.8)); - - // applying foam hats - foam_intensity += max(0,foam_intensity_map_uhf*2.0*surface_attributes.foam_wave_hats); - - foam_intensity = pow(foam_intensity, 0.7); - foam_intensity = saturate(foam_intensity*foam_bubbles*1.0); - // - - // foam diffuse color - float foam_diffuse_factor=max(0,0.8+max(0,0.2*dot(pixel_to_light_vector,surface_attributes.normal))); - - water_color = mix(water_color,foam_diffuse_factor*vec3(1.0,1.0,1.0),foam_intensity); - - color = vec4(water_color,0); -} - diff --git a/sample/opengl/win64/debug/AntTweakBar64.dll b/sample/opengl/win64/debug/AntTweakBar64.dll Binary files differdeleted file mode 100644 index 276b2c4..0000000 --- a/sample/opengl/win64/debug/AntTweakBar64.dll +++ /dev/null diff --git a/sample/opengl/win64/debug/cudart64_55.dll b/sample/opengl/win64/debug/cudart64_55.dll Binary files differdeleted file mode 100644 index d729fdc..0000000 --- a/sample/opengl/win64/debug/cudart64_55.dll +++ /dev/null diff --git a/sample/opengl/win64/debug/gfsdk_waveworks_debug.win64.dll b/sample/opengl/win64/debug/gfsdk_waveworks_debug.win64.dll Binary files differdeleted file mode 100644 index 91047d8..0000000 --- a/sample/opengl/win64/debug/gfsdk_waveworks_debug.win64.dll +++ /dev/null diff --git a/sample/opengl/win64/debug/sample_opengl_debug.exe b/sample/opengl/win64/debug/sample_opengl_debug.exe Binary files differdeleted file mode 100644 index 6465b1d..0000000 --- a/sample/opengl/win64/debug/sample_opengl_debug.exe +++ /dev/null diff --git a/sample/opengl/win64/debug/sample_opengl_debug.ilk b/sample/opengl/win64/debug/sample_opengl_debug.ilk Binary files differdeleted file mode 100644 index 864c6ae..0000000 --- a/sample/opengl/win64/debug/sample_opengl_debug.ilk +++ /dev/null |