port from perforce
This commit is contained in:
31
ocean4k/Backup/ocean4k.sln
Normal file
31
ocean4k/Backup/ocean4k.sln
Normal file
@@ -0,0 +1,31 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 10.00
|
||||
# Visual Studio 2008
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ocean4k", "src\ocean4k\ocean4k.vcproj", "{213903DE-E40A-4D23-9310-E520AC2B412E}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "4slang", "..\BP4k\src\4slang\4slang.vcproj", "{E0A366EF-1805-44C7-B644-426FEE32B9D9}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Compress (Slow)|Win32 = Compress (Slow)|Win32
|
||||
Debug|Win32 = Debug|Win32
|
||||
Release|Win32 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{213903DE-E40A-4D23-9310-E520AC2B412E}.Compress (Slow)|Win32.ActiveCfg = Compress (Slow)|Win32
|
||||
{213903DE-E40A-4D23-9310-E520AC2B412E}.Compress (Slow)|Win32.Build.0 = Compress (Slow)|Win32
|
||||
{213903DE-E40A-4D23-9310-E520AC2B412E}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{213903DE-E40A-4D23-9310-E520AC2B412E}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{213903DE-E40A-4D23-9310-E520AC2B412E}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{213903DE-E40A-4D23-9310-E520AC2B412E}.Release|Win32.Build.0 = Release|Win32
|
||||
{E0A366EF-1805-44C7-B644-426FEE32B9D9}.Compress (Slow)|Win32.ActiveCfg = Debug|Win32
|
||||
{E0A366EF-1805-44C7-B644-426FEE32B9D9}.Compress (Slow)|Win32.Build.0 = Debug|Win32
|
||||
{E0A366EF-1805-44C7-B644-426FEE32B9D9}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{E0A366EF-1805-44C7-B644-426FEE32B9D9}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{E0A366EF-1805-44C7-B644-426FEE32B9D9}.Release|Win32.ActiveCfg = Debug|Win32
|
||||
{E0A366EF-1805-44C7-B644-426FEE32B9D9}.Release|Win32.Build.0 = Debug|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
BIN
ocean4k/Backup/ocean4k.v11.suo
Normal file
BIN
ocean4k/Backup/ocean4k.v11.suo
Normal file
Binary file not shown.
BIN
ocean4k/UpgradeLog.XML
Normal file
BIN
ocean4k/UpgradeLog.XML
Normal file
Binary file not shown.
BIN
ocean4k/UpgradeLog.htm
Normal file
BIN
ocean4k/UpgradeLog.htm
Normal file
Binary file not shown.
BIN
ocean4k/link.exe
Normal file
BIN
ocean4k/link.exe
Normal file
Binary file not shown.
31
ocean4k/ocean4k.sln
Normal file
31
ocean4k/ocean4k.sln
Normal file
@@ -0,0 +1,31 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 2012
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ocean4k", "src\ocean4k\ocean4k.vcxproj", "{213903DE-E40A-4D23-9310-E520AC2B412E}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "4slang", "..\bp4k\src\4slang\4slang.vcxproj", "{E0A366EF-1805-44C7-B644-426FEE32B9D9}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Compress (Slow)|Win32 = Compress (Slow)|Win32
|
||||
Debug|Win32 = Debug|Win32
|
||||
Release|Win32 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{213903DE-E40A-4D23-9310-E520AC2B412E}.Compress (Slow)|Win32.ActiveCfg = Compress (Slow)|Win32
|
||||
{213903DE-E40A-4D23-9310-E520AC2B412E}.Compress (Slow)|Win32.Build.0 = Compress (Slow)|Win32
|
||||
{213903DE-E40A-4D23-9310-E520AC2B412E}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{213903DE-E40A-4D23-9310-E520AC2B412E}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{213903DE-E40A-4D23-9310-E520AC2B412E}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{213903DE-E40A-4D23-9310-E520AC2B412E}.Release|Win32.Build.0 = Release|Win32
|
||||
{E0A366EF-1805-44C7-B644-426FEE32B9D9}.Compress (Slow)|Win32.ActiveCfg = Debug|Win32
|
||||
{E0A366EF-1805-44C7-B644-426FEE32B9D9}.Compress (Slow)|Win32.Build.0 = Debug|Win32
|
||||
{E0A366EF-1805-44C7-B644-426FEE32B9D9}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{E0A366EF-1805-44C7-B644-426FEE32B9D9}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{E0A366EF-1805-44C7-B644-426FEE32B9D9}.Release|Win32.ActiveCfg = Debug|Win32
|
||||
{E0A366EF-1805-44C7-B644-426FEE32B9D9}.Release|Win32.Build.0 = Debug|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
BIN
ocean4k/ocean4k.suo
Normal file
BIN
ocean4k/ocean4k.suo
Normal file
Binary file not shown.
BIN
ocean4k/ocean4k.v11.suo
Normal file
BIN
ocean4k/ocean4k.v11.suo
Normal file
Binary file not shown.
BIN
ocean4k/src/ocean4k/4klang.obj
Normal file
BIN
ocean4k/src/ocean4k/4klang.obj
Normal file
Binary file not shown.
242
ocean4k/src/ocean4k/Shaders.cpp
Normal file
242
ocean4k/src/ocean4k/Shaders.cpp
Normal file
@@ -0,0 +1,242 @@
|
||||
#ifdef _DEBUG
|
||||
#include "Shaders.h"
|
||||
|
||||
PFNGLCREATESHADERPROC glCreateShader = NULL;
|
||||
PFNGLSHADERSOURCEPROC glShaderSource = NULL;
|
||||
PFNGLCOMPILESHADERPROC glCompileShader = NULL;
|
||||
PFNGLGETSHADERIVPROC glGetShaderiv = NULL;
|
||||
PFNGLGETPROGRAMIVPROC glGetProgramiv = NULL;
|
||||
PFNGLCREATEPROGRAMPROC glCreateProgram = NULL;
|
||||
PFNGLATTACHSHADERPROC glAttachShader = NULL;
|
||||
PFNGLLINKPROGRAMPROC glLinkProgram = NULL;
|
||||
PFNGLUSEPROGRAMPROC glUseProgram = NULL;
|
||||
PFNGLGETSHADERINFOLOGPROC glGetShaderInfoLog = NULL;
|
||||
PFNGLGETPROGRAMINFOLOGPROC glGetProgramInfoLog = NULL;
|
||||
|
||||
|
||||
void useProgram(GLhandleARB ah_Program)
|
||||
{
|
||||
glUseProgram(ah_Program);
|
||||
}
|
||||
|
||||
|
||||
void initShaders()
|
||||
{
|
||||
glCreateShader = (PFNGLCREATESHADERPROC)myGetProcAddress("glCreateShader");
|
||||
glShaderSource = (PFNGLSHADERSOURCEPROC)myGetProcAddress("glShaderSource");
|
||||
glCompileShader = (PFNGLCOMPILESHADERPROC)myGetProcAddress("glCompileShader");
|
||||
glGetShaderiv = (PFNGLGETSHADERIVPROC)myGetProcAddress("glGetShaderiv");
|
||||
glGetProgramiv = (PFNGLGETPROGRAMIVPROC)myGetProcAddress("glGetProgramiv");
|
||||
glCreateProgram = (PFNGLCREATEPROGRAMPROC)myGetProcAddress("glCreateProgram");
|
||||
glAttachShader = (PFNGLATTACHSHADERPROC)myGetProcAddress("glAttachShader");
|
||||
glLinkProgram = (PFNGLLINKPROGRAMPROC)myGetProcAddress("glLinkProgram");
|
||||
glUseProgram = (PFNGLUSEPROGRAMPROC)myGetProcAddress("glUseProgram");
|
||||
glGetShaderInfoLog = (PFNGLGETSHADERINFOLOGPROC)myGetProcAddress("glGetShaderInfoLog");
|
||||
glGetProgramInfoLog = (PFNGLGETPROGRAMINFOLOGPROC)myGetProcAddress("glGetProgramInfoLog");
|
||||
|
||||
if (!(glCreateShader && glShaderSource && glCompileShader && glGetShaderiv && glGetProgramiv && glCreateProgram && glAttachShader && glLinkProgram && glUseProgram && glGetShaderInfoLog && glGetProgramInfoLog))
|
||||
{
|
||||
std::cerr << "Some shader functions are not available!" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void PrintErrors()
|
||||
{
|
||||
GLenum lr_Error = GL_NO_ERROR;
|
||||
int li_ErrorCount = 5;
|
||||
do
|
||||
{
|
||||
lr_Error = glGetError();
|
||||
if (lr_Error != GL_NO_ERROR)
|
||||
{
|
||||
li_ErrorCount--;
|
||||
char* ls_ErrorString = (char*)gluErrorString(lr_Error);
|
||||
if (ls_ErrorString != 0)
|
||||
std::cout << "OPENGL :: ERROR " << ls_ErrorString << std::endl;
|
||||
}
|
||||
if (li_ErrorCount == 0)
|
||||
{
|
||||
std::cout << "OPENGL :: ERROR Too many errors!" << std::endl;
|
||||
break;
|
||||
}
|
||||
} while (lr_Error != GL_NO_ERROR);
|
||||
}
|
||||
|
||||
|
||||
GLhandleARB createVertexShader(const char* as_ShaderSource)
|
||||
{
|
||||
GLhandleARB lh_Shader = glCreateShader(GL_VERTEX_SHADER);
|
||||
|
||||
glShaderSource(lh_Shader, 1, &as_ShaderSource, NULL);
|
||||
glCompileShader(lh_Shader);
|
||||
|
||||
int li_Status = 0;
|
||||
glGetShaderiv(lh_Shader, GL_COMPILE_STATUS, &li_Status);
|
||||
|
||||
if (li_Status == GL_FALSE)
|
||||
{
|
||||
std::cerr << "Error compiling vertex shader!" << std::endl;
|
||||
printShaderInfoLog(lh_Shader);
|
||||
}
|
||||
|
||||
return lh_Shader;
|
||||
}
|
||||
|
||||
|
||||
GLhandleARB createFragmentShader(const char* as_FileName)
|
||||
{
|
||||
GLhandleARB lh_Shader = 0;
|
||||
|
||||
char* ls_ShaderSource = textFileRead(as_FileName);
|
||||
if (ls_ShaderSource == NULL)
|
||||
{
|
||||
std::cerr << "Error reading file: " << as_FileName << std::endl;
|
||||
return lh_Shader;
|
||||
}
|
||||
|
||||
lh_Shader = glCreateShader(GL_FRAGMENT_SHADER);
|
||||
|
||||
glShaderSource(lh_Shader, 1, (const char**)&ls_ShaderSource, NULL);
|
||||
glCompileShader(lh_Shader);
|
||||
|
||||
int li_Status = 0;
|
||||
|
||||
glGetShaderiv(lh_Shader, GL_COMPILE_STATUS, &li_Status);
|
||||
|
||||
if (li_Status == GL_FALSE)
|
||||
{
|
||||
std::cerr << "Error compiling fragment shader: " << as_FileName << std::endl;
|
||||
printShaderInfoLog(lh_Shader);
|
||||
}
|
||||
|
||||
free(ls_ShaderSource);
|
||||
|
||||
return lh_Shader;
|
||||
}
|
||||
|
||||
|
||||
GLhandleARB createProgram(GLhandleARB ah_VertexShader, GLhandleARB ah_FragmentShader)
|
||||
{
|
||||
GLhandleARB lh_Program = 0;
|
||||
|
||||
if (ah_VertexShader + ah_FragmentShader <= 1)
|
||||
{
|
||||
std::cerr << "Cannot create program." << std::endl;
|
||||
return lh_Program;
|
||||
}
|
||||
|
||||
lh_Program = glCreateProgram();
|
||||
|
||||
glAttachShader(lh_Program, ah_VertexShader);
|
||||
glAttachShader(lh_Program, ah_FragmentShader);
|
||||
glLinkProgram(lh_Program);
|
||||
|
||||
int li_Status = 0;
|
||||
|
||||
glGetProgramiv(lh_Program, GL_LINK_STATUS, &li_Status);
|
||||
|
||||
if (li_Status == GL_FALSE)
|
||||
{
|
||||
std::cerr << "Error linking shaders." << std::endl;
|
||||
printProgramInfoLog(lh_Program);
|
||||
}
|
||||
|
||||
return lh_Program;
|
||||
}
|
||||
|
||||
|
||||
char* textFileRead(const char* as_FileName)
|
||||
{
|
||||
FILE* lh_File;
|
||||
char* ls_Content = NULL;
|
||||
size_t li_Count = 0;
|
||||
|
||||
if (as_FileName != NULL)
|
||||
{
|
||||
fopen_s(&lh_File, as_FileName, "rt");
|
||||
|
||||
if (lh_File != NULL)
|
||||
{
|
||||
fseek(lh_File, 0, SEEK_END);
|
||||
li_Count = ftell(lh_File);
|
||||
rewind(lh_File);
|
||||
|
||||
if (li_Count > 0)
|
||||
{
|
||||
ls_Content = (char*) malloc(sizeof(char) * (li_Count + 1));
|
||||
li_Count = fread(ls_Content, sizeof(char), li_Count, lh_File);
|
||||
ls_Content[li_Count] = '\0';
|
||||
}
|
||||
|
||||
fclose(lh_File);
|
||||
}
|
||||
}
|
||||
|
||||
return ls_Content;
|
||||
}
|
||||
|
||||
|
||||
void printShaderInfoLog(GLhandleARB ah_Shader)
|
||||
{
|
||||
int li_InfologLength = 0;
|
||||
int li_CharsWritten = 0;
|
||||
char* li_InfoLog;
|
||||
|
||||
glGetShaderiv(ah_Shader, GL_INFO_LOG_LENGTH, &li_InfologLength);
|
||||
|
||||
if (li_InfologLength > 0)
|
||||
{
|
||||
li_InfoLog = (char*) malloc(li_InfologLength);
|
||||
|
||||
glGetShaderInfoLog(ah_Shader, li_InfologLength, &li_CharsWritten, li_InfoLog);
|
||||
|
||||
std::cerr << li_InfoLog << std::endl;
|
||||
free(li_InfoLog);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void printProgramInfoLog(GLhandleARB ah_Program)
|
||||
{
|
||||
int li_InfologLength = 0;
|
||||
int li_CharsWritten = 0;
|
||||
char* ls_InfoLog;
|
||||
|
||||
glGetProgramiv(ah_Program, GL_INFO_LOG_LENGTH, &li_InfologLength);
|
||||
|
||||
if (li_InfologLength > 0)
|
||||
{
|
||||
ls_InfoLog = (char *)malloc(li_InfologLength);
|
||||
|
||||
glGetProgramInfoLog(ah_Program, li_InfologLength, &li_CharsWritten, ls_InfoLog);
|
||||
|
||||
std::cerr << ls_InfoLog << std::endl;
|
||||
free(ls_InfoLog);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool printShaderStatistics()
|
||||
{
|
||||
if (GL_VERSION_2_1) std::cout << "Supports OpenGL 2.1. " << std::endl;
|
||||
else if (GL_VERSION_2_0) std::cout << "Supports OpenGL 2.0. " << std::endl;
|
||||
else if (GL_VERSION_1_5) std::cout << "Supports OpenGL 1.5. " << std::endl;
|
||||
else if (GL_VERSION_1_4) std::cout << "Supports OpenGL 1.4. " << std::endl;
|
||||
else if (GL_VERSION_1_3) std::cout << "Supports OpenGL 1.3. " << std::endl;
|
||||
else if (GL_VERSION_1_2) std::cout << "Supports OpenGL 1.2. " << std::endl;
|
||||
else if (GL_VERSION_1_1) std::cout << "Supports OpenGL 1.1. " << std::endl;
|
||||
|
||||
if (GL_ARB_shader_objects && GL_ARB_vertex_shader && GL_ARB_fragment_shader)
|
||||
{
|
||||
std::cout << "Status: Using GLSL " << glGetString(GL_SHADING_LANGUAGE_VERSION_ARB) << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "No GLSL support!" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
19
ocean4k/src/ocean4k/Shaders.h
Normal file
19
ocean4k/src/ocean4k/Shaders.h
Normal file
@@ -0,0 +1,19 @@
|
||||
#pragma once
|
||||
|
||||
#include <windows.h>
|
||||
#include <iostream>
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glu.h>
|
||||
#include "glext.h"
|
||||
#define myGetProcAddress(name) wglGetProcAddress((LPCSTR)name)
|
||||
|
||||
void initShaders();
|
||||
GLhandleARB createVertexShader(const char* as_FileName);
|
||||
GLhandleARB createFragmentShader(const char* as_FileName);
|
||||
GLhandleARB createProgram(GLhandleARB ah_VertexShader, GLhandleARB ah_FragmentShader);
|
||||
void PrintErrors();
|
||||
void useProgram(GLhandleARB ah_Program);
|
||||
char* textFileRead(const char* as_FileName);
|
||||
void printShaderInfoLog(GLhandleARB ah_Shader);
|
||||
void printProgramInfoLog(GLhandleARB ah_Program);
|
||||
bool printShaderStatistics();
|
||||
7271
ocean4k/src/ocean4k/glext.h
Normal file
7271
ocean4k/src/ocean4k/glext.h
Normal file
File diff suppressed because it is too large
Load Diff
356
ocean4k/src/ocean4k/main.cpp
Normal file
356
ocean4k/src/ocean4k/main.cpp
Normal file
@@ -0,0 +1,356 @@
|
||||
#ifdef _DEBUG
|
||||
#include <time.h>
|
||||
#include <io.h>
|
||||
#include <process.h>
|
||||
#include "Shaders.h"
|
||||
#include "small.h"
|
||||
#else
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_EXTRA_LEAN
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glu.h>
|
||||
#include "glext.h"
|
||||
#include "small.h"
|
||||
#endif
|
||||
#include "release.h"
|
||||
#include "mmsystem.h"
|
||||
#include "mmreg.h"
|
||||
|
||||
#define USE_SOUND_THREAD // define this if you have a multicore cpu and can spare ~15 bytes for realtime playback
|
||||
|
||||
#pragma data_seg(".vertexshader")
|
||||
// 4:3 (640x480, 800x600, 1024x768, 1280x960, 1400x1050)
|
||||
//static char* vsh = "varying vec4 Y;void main(){Y=gl_Color;Y.xy=gl_Vertex.xy*vec2(1.3,1)*.5+.5;gl_Position=gl_Vertex;}";
|
||||
// 16:9 (1280x720, 1920x1080)
|
||||
//static char* vsh = "varying vec4 Y;void main(){Y=gl_Color;Y.xy=gl_Vertex.xy*vec2(1.7,1)*.5+.5;gl_Position=gl_Vertex;}";
|
||||
// 16:10 (1680x1050, 1920x1200)
|
||||
//static char* vsh = "varying vec4 Y;void main(){Y=gl_Color;Y.xy=gl_Vertex.xy*vec2(1.6,1)*.5+.5;gl_Position=gl_Vertex;}";
|
||||
// 5:4 (1280x1024)
|
||||
static char* vsh = "varying vec4 Y;void main(){Y=gl_Color;Y.xy=gl_Vertex.xy*vec2(1.25,1)*.5+.5;gl_Position=gl_Vertex;}";
|
||||
|
||||
#pragma data_seg(".dms")
|
||||
static DEVMODE dmScreenSettings={
|
||||
"",0,0,sizeof(dmScreenSettings),0,DM_PELSWIDTH|DM_PELSHEIGHT,0,0,0,0,0,0,0,0,0,0,0,0,0,"",0,0,
|
||||
//640,480
|
||||
//800,600
|
||||
//1024,768
|
||||
//1280,960
|
||||
//1400,1050
|
||||
//1280,720
|
||||
//1920,1080
|
||||
//1680,1050
|
||||
//1920,1200
|
||||
1280,1024
|
||||
};
|
||||
|
||||
#pragma data_seg(".pfd")
|
||||
static const PIXELFORMATDESCRIPTOR pfd = {
|
||||
0, 1, PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER, PFD_TYPE_RGBA, 32, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 8
|
||||
};
|
||||
|
||||
#pragma data_seg(".glCreateProgram")
|
||||
static char* glCreateProgram = "glCreateProgram";
|
||||
#pragma data_seg(".glCreateShader")
|
||||
static char* glCreateShader = "glCreateShader";
|
||||
#pragma data_seg(".glShaderSource")
|
||||
static char* glShaderSource = "glShaderSource";
|
||||
#pragma data_seg(".glCompileShader")
|
||||
static char* glCompileShader = "glCompileShader";
|
||||
#pragma data_seg(".glAttachShader")
|
||||
static char* glAttachShader = "glAttachShader";
|
||||
#pragma data_seg(".glLinkProgram")
|
||||
static char* glLinkProgram = "glLinkProgram";
|
||||
#pragma data_seg(".glUseProgram")
|
||||
static char* glUseProgram = "glUseProgram";
|
||||
#pragma data_seg(".windowclass")
|
||||
static const char* gs_WindowClass = "edit";
|
||||
|
||||
#pragma data_seg(".samplerate")
|
||||
static const int gi_SampleRate = 44100;
|
||||
#define MAX_SAMPLES gi_SampleRate*2*60*30
|
||||
|
||||
#pragma bss_seg(".mainbss")
|
||||
static HDC gh_Dc;
|
||||
static int gi_Program;
|
||||
static int gi_FragmentShader;
|
||||
static int gi_VertexShader;
|
||||
static float gf_SoundBuffer_[MAX_SAMPLES];
|
||||
static HWAVEOUT gh_WaveOut;
|
||||
|
||||
#pragma data_seg(".wavefmt")
|
||||
WAVEFORMATEX gr_WaveFmt = { WAVE_FORMAT_IEEE_FLOAT, 2, gi_SampleRate, gi_SampleRate*4*2, 8, 32, 0};
|
||||
|
||||
#pragma data_seg(".wavehdr")
|
||||
WAVEHDR gr_WaveHdr = {(LPSTR)gf_SoundBuffer_, MAX_SAMPLES*4, 0, 0, 0, 0, 0, 0};
|
||||
|
||||
#pragma data_seg(".mmtime")
|
||||
MMTIME gr_MmTime = {TIME_SAMPLES, 0};
|
||||
|
||||
extern "C" void _4klang_render(float*);
|
||||
|
||||
#ifndef _DEBUG
|
||||
#pragma code_seg(".main")
|
||||
void _cdecl main()
|
||||
{
|
||||
_asm
|
||||
{
|
||||
xor esi, esi
|
||||
// ShowCursor:
|
||||
push esi
|
||||
|
||||
// CreateWindowEx:
|
||||
push esi
|
||||
push esi
|
||||
push esi
|
||||
push esi
|
||||
push esi
|
||||
push esi
|
||||
push esi
|
||||
push esi
|
||||
push esi
|
||||
push esi
|
||||
push WS_POPUP | WS_VISIBLE | WS_MAXIMIZE
|
||||
push esi
|
||||
push gs_WindowClass;
|
||||
push esi
|
||||
|
||||
// ChangeDisplaySettings:
|
||||
push CDS_FULLSCREEN
|
||||
push offset dmScreenSettings
|
||||
|
||||
call dword ptr [ChangeDisplaySettings]
|
||||
call dword ptr [CreateWindowExA]
|
||||
push eax
|
||||
call dword ptr [GetDC]
|
||||
mov dword ptr [gh_Dc], eax
|
||||
|
||||
call dword ptr [ShowCursor]
|
||||
|
||||
push dword ptr [gh_Dc]
|
||||
push offset pfd
|
||||
push offset pfd
|
||||
push dword ptr [gh_Dc]
|
||||
call dword ptr [ChoosePixelFormat]
|
||||
push eax
|
||||
push dword ptr [gh_Dc]
|
||||
call dword ptr [SetPixelFormat]
|
||||
call dword ptr [wglCreateContext]
|
||||
push eax
|
||||
push dword ptr [gh_Dc]
|
||||
call dword ptr [wglMakeCurrent]
|
||||
|
||||
push GL_FRAGMENT_SHADER
|
||||
push glCreateShader
|
||||
push GL_VERTEX_SHADER
|
||||
push glCreateShader
|
||||
push glCreateProgram
|
||||
call dword ptr [wglGetProcAddress]
|
||||
call eax
|
||||
mov gi_Program, eax
|
||||
call dword ptr [wglGetProcAddress]
|
||||
call eax
|
||||
mov gi_VertexShader, eax
|
||||
call dword ptr [wglGetProcAddress]
|
||||
call eax
|
||||
mov gi_FragmentShader, eax
|
||||
|
||||
push gi_Program
|
||||
push glUseProgram
|
||||
push gi_Program
|
||||
push glLinkProgram
|
||||
push gi_FragmentShader
|
||||
push gi_Program
|
||||
push glAttachShader
|
||||
push gi_FragmentShader
|
||||
push glCompileShader
|
||||
push esi
|
||||
push offset fsh
|
||||
push 1
|
||||
push gi_FragmentShader
|
||||
push glShaderSource
|
||||
push gi_VertexShader
|
||||
push gi_Program
|
||||
push glAttachShader
|
||||
push gi_VertexShader
|
||||
push glCompileShader
|
||||
push esi
|
||||
push offset vsh
|
||||
push 1
|
||||
push gi_VertexShader
|
||||
push glShaderSource
|
||||
call dword ptr [wglGetProcAddress]
|
||||
call eax
|
||||
call dword ptr [wglGetProcAddress]
|
||||
call eax
|
||||
call dword ptr [wglGetProcAddress]
|
||||
call eax
|
||||
call dword ptr [wglGetProcAddress]
|
||||
call eax
|
||||
call dword ptr [wglGetProcAddress]
|
||||
call eax
|
||||
call dword ptr [wglGetProcAddress]
|
||||
call eax
|
||||
call dword ptr [wglGetProcAddress]
|
||||
call eax
|
||||
call dword ptr [wglGetProcAddress]
|
||||
call eax
|
||||
|
||||
push esi //ExitProcess
|
||||
push 1
|
||||
push 1
|
||||
push 0FFFFFFFFh
|
||||
push 0FFFFFFFFh
|
||||
call dword ptr [glRects]
|
||||
|
||||
#ifdef USE_SOUND_THREAD
|
||||
push esi
|
||||
push esi
|
||||
push offset gf_SoundBuffer_
|
||||
push _4klang_render
|
||||
push esi
|
||||
push esi
|
||||
call dword ptr [CreateThread]
|
||||
#else
|
||||
push gf_SoundBuffer_
|
||||
call dword ptr [_4klang_render]
|
||||
#endif
|
||||
push esi
|
||||
push esi
|
||||
push esi
|
||||
push offset gr_WaveFmt
|
||||
push 0FFFFFFFFh
|
||||
push offset gh_WaveOut
|
||||
call dword ptr [waveOutOpen]
|
||||
|
||||
push 20h
|
||||
push offset gr_WaveHdr
|
||||
mov eax, dword ptr [gh_WaveOut]
|
||||
push eax
|
||||
push 20h
|
||||
push offset gr_WaveHdr
|
||||
mov eax,dword ptr [gh_WaveOut]
|
||||
push eax
|
||||
call dword ptr [waveOutPrepareHeader]
|
||||
call dword ptr [waveOutWrite]
|
||||
|
||||
myloop:
|
||||
push VK_ESCAPE
|
||||
push dword ptr [gh_Dc]
|
||||
push 1
|
||||
push 1
|
||||
push 0FFFFFFFFh
|
||||
push 0FFFFFFFFh
|
||||
push esi
|
||||
push esi
|
||||
push esi
|
||||
|
||||
push 0Ch
|
||||
push offset gr_MmTime
|
||||
mov eax, dword ptr [gh_WaveOut]
|
||||
push eax
|
||||
call dword ptr [waveOutGetPosition]
|
||||
fild dword ptr [gr_MmTime+4]
|
||||
fild dword ptr [gi_SampleRate]
|
||||
fdiv
|
||||
fstp dword ptr [esp+8]
|
||||
|
||||
call dword ptr [glColor3f]
|
||||
call dword ptr [glRects]
|
||||
call dword ptr [SwapBuffers]
|
||||
cmp dword ptr [gr_MmTime+4], 64EFD8h
|
||||
jae exit
|
||||
call dword ptr [GetAsyncKeyState]
|
||||
test ax,ax
|
||||
je myloop
|
||||
exit:
|
||||
call dword ptr [ExitProcess]
|
||||
}}
|
||||
#else
|
||||
HANDLE gh_ShaderCompileEvent;
|
||||
static char** gs_LastShader_;
|
||||
static __time64_t gi_ShaderChangedDate;
|
||||
static unsigned int gi_ShaderProgram;
|
||||
static unsigned int gi_LastShaderProgram;
|
||||
static const char* gs_ShaderFile = "mark.fs";
|
||||
|
||||
DWORD WINAPI filemon(void* args)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
_finddata_t fdata;
|
||||
long hfile = _findfirst(gs_ShaderFile, &fdata);
|
||||
if (hfile != -1)
|
||||
{
|
||||
if (fdata.time_write != gi_ShaderChangedDate)
|
||||
{
|
||||
gi_ShaderChangedDate = fdata.time_write;
|
||||
::SetEvent(gh_ShaderCompileEvent);
|
||||
std::cout << "Shader loaded." << std::endl;
|
||||
}
|
||||
_findclose(hfile);
|
||||
}
|
||||
::Sleep(100);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void _cdecl main()
|
||||
{
|
||||
HDC hDC = GetDC(CreateWindow("static", 0, WS_POPUP | WS_VISIBLE, 0, 0, dmScreenSettings.dmPelsWidth, dmScreenSettings.dmPelsHeight, 0, 0, 0, 0));
|
||||
SetPixelFormat(hDC, ChoosePixelFormat(hDC, &pfd), &pfd);
|
||||
wglMakeCurrent(hDC, wglCreateContext(hDC));
|
||||
ShowCursor(FALSE);
|
||||
initShaders();
|
||||
gh_ShaderCompileEvent = ::CreateEvent(NULL, FALSE, FALSE, TEXT("WriteEvent"));
|
||||
SetThreadPriority((HANDLE)CreateThread(0, 0, &filemon, 0, 0, 0), THREAD_PRIORITY_BELOW_NORMAL);
|
||||
::Sleep(100);
|
||||
|
||||
if (::WaitForSingleObject(gh_ShaderCompileEvent, 0) == WAIT_OBJECT_0)
|
||||
{
|
||||
::Sleep(250);
|
||||
gi_ShaderProgram = createProgram(createVertexShader(vsh), createFragmentShader(gs_ShaderFile));
|
||||
|
||||
((PFNGLUSEPROGRAMPROC)wglGetProcAddress("glUseProgram"))(gi_ShaderProgram);
|
||||
PrintErrors();
|
||||
}
|
||||
|
||||
glRects(-1, -1, 1, 1);
|
||||
|
||||
#ifdef USE_SOUND_THREAD
|
||||
CreateThread(0, 0, (LPTHREAD_START_ROUTINE)_4klang_render, gf_SoundBuffer_, 0, 0);
|
||||
#else
|
||||
_4klang_render(lpSoundBuffer);
|
||||
#endif
|
||||
waveOutOpen ( &gh_WaveOut, WAVE_MAPPER, &gr_WaveFmt, NULL, 0, CALLBACK_NULL );
|
||||
waveOutPrepareHeader( gh_WaveOut, &gr_WaveHdr, sizeof(WAVEHDR) );
|
||||
waveOutWrite ( gh_WaveOut, &gr_WaveHdr, sizeof(WAVEHDR) );
|
||||
|
||||
loop:
|
||||
|
||||
if (::WaitForSingleObject(gh_ShaderCompileEvent, 0) == WAIT_OBJECT_0)
|
||||
{
|
||||
::Sleep(250);
|
||||
gi_ShaderProgram = createProgram(createVertexShader(vsh), createFragmentShader(gs_ShaderFile));
|
||||
|
||||
((PFNGLUSEPROGRAMPROC)wglGetProcAddress("glUseProgram"))(gi_ShaderProgram);
|
||||
PrintErrors();
|
||||
}
|
||||
|
||||
MSG lr_Message;
|
||||
if (PeekMessage(&lr_Message, NULL, 0, 0, PM_REMOVE))
|
||||
{
|
||||
TranslateMessage(&lr_Message);
|
||||
DispatchMessage(&lr_Message);
|
||||
}
|
||||
|
||||
waveOutGetPosition(gh_WaveOut, &gr_MmTime, sizeof(MMTIME));
|
||||
glColor3f(0, 0, float(gr_MmTime.u.sample) / gi_SampleRate);
|
||||
glRects(-1, -1, 1, 1);
|
||||
SwapBuffers(hDC);
|
||||
if (gr_MmTime.u.sample < gi_SampleRate*150 && !GetAsyncKeyState(VK_ESCAPE)) goto loop;
|
||||
ExitProcess(0);
|
||||
}
|
||||
#endif
|
||||
373
ocean4k/src/ocean4k/mark.fs
Normal file
373
ocean4k/src/ocean4k/mark.fs
Normal file
@@ -0,0 +1,373 @@
|
||||
varying vec4 Y;
|
||||
|
||||
// All data of our world
|
||||
vec4 artifactPos;
|
||||
vec3 lightPos, lightDir, ro, rd;
|
||||
float FAR, EXPLOSIONTIME, pi, eps=0.0001;
|
||||
|
||||
float saturate(float x) { return clamp(x,0.0,1.0); }
|
||||
float time(float t, int s, int e) { return (t-s)/(e-s); }
|
||||
|
||||
vec3 rotateY(vec3 v, float x)
|
||||
{
|
||||
return vec3(
|
||||
cos(x)*v.x - sin(x)*v.z,
|
||||
v.y,
|
||||
sin(x)*v.x + cos(x)*v.z
|
||||
);
|
||||
}
|
||||
|
||||
vec3 rotateX(vec3 v, float x)
|
||||
{
|
||||
return vec3(
|
||||
v.x,
|
||||
v.y*cos(x) - v.z*sin(x),
|
||||
v.y*sin(x) + v.z*cos(x)
|
||||
);
|
||||
}
|
||||
|
||||
// Pseudo random number base generator (credits go to iq/rgba)
|
||||
float rnd(vec2 x)
|
||||
{
|
||||
int n = int(x.x * 40 + x.y * 6400);
|
||||
n = (n << 13) ^ n;
|
||||
return 1 - float( (n * (n * n * 15731 + 789221) + 1376312589) & 0x7fffffff) / 1073741824;
|
||||
}
|
||||
|
||||
// Convert the cipher range from [-1,1] to [0,1]
|
||||
float norm(float x)
|
||||
{
|
||||
return x * 0.5 + 0.5;
|
||||
}
|
||||
|
||||
// Generate animated (t) caustic values
|
||||
float caustic(float u, float v, float t)
|
||||
{
|
||||
return pow((
|
||||
norm(sin(pi * 2 * (u + v + Y.z*t))) +
|
||||
norm(sin(pi * (v - u - Y.z*t))) +
|
||||
norm(sin(pi * (v + Y.z*t))) +
|
||||
norm(sin(pi * 3 * (u - Y.z*t)))) * 0.3, 2.0);
|
||||
}
|
||||
|
||||
// Generate cubic interpolated random values
|
||||
float smoothrnd(vec2 x)
|
||||
{
|
||||
x = mod(x,1000.0);
|
||||
vec2 a = fract(x);
|
||||
x -= a;
|
||||
vec2 u = a*a*(3.0-2.0*a);
|
||||
return mix(
|
||||
mix(rnd(x+vec2(0)),rnd(x+vec2(1,0)), u.x),
|
||||
mix(rnd(x+vec2(0,1)),rnd(x+vec2(1)), u.x), u.y);
|
||||
}
|
||||
|
||||
float height(vec2 x)
|
||||
{
|
||||
float maxV = Y.z - EXPLOSIONTIME;
|
||||
float l = mix(1., max(0., artifactPos.w - artifactPos.y), 1.0 - ((maxV > 0 && length(x - artifactPos.xz) < maxV) ? 1.0 : 0.0)) /
|
||||
pow(1./max(0., 1.0-length(artifactPos.xz-x)*0.8), 2.0);
|
||||
x += length(x-ro.xy);
|
||||
x *= min(length(x-ro.xy)*5, 4.0);
|
||||
|
||||
return caustic(x.x+Y.z*0.75, x.y*0.5, 0.3) * 0.006 +
|
||||
caustic(x.x*0.1+Y.z*0.2, x.y*0.1, 0.02) * 0.125 -
|
||||
0.15 - l*2;
|
||||
}
|
||||
|
||||
// Calculates the water "waves". To reduce the bumpiness, increment the y-axis
|
||||
vec3 getWaterNormal(vec3 p)
|
||||
{
|
||||
return normalize(vec3(
|
||||
caustic(p.x * 160 - 12 * cos(10 * p.z), p.z * 140, 4.0),
|
||||
8,
|
||||
caustic(p.z * 160 - 12 * sin(10 * p.x), p.x * 140, 4.0)) * 2 - 1);
|
||||
}
|
||||
|
||||
// Raymarch the terrain function, returns the distance from the ray origin to the terrain voxel
|
||||
// This function was originally adopted from an implementation by iq/rgba
|
||||
int traceTerrain(vec3 ro, vec3 rd, float maxt, out float depth)
|
||||
{
|
||||
float lh, ly, delt=0;
|
||||
// advance our sample position from our nearplane to our farplane
|
||||
for (float t = 0.1; t < maxt; t += delt)
|
||||
{
|
||||
// advance our ray
|
||||
ro += rd * delt;
|
||||
|
||||
// get the height at the given sample 2d (!) position (we could enhance this by sampling a voxel and returning only the distance to the voxel)
|
||||
depth = height(ro.xz);
|
||||
|
||||
if (ro.y <= depth)
|
||||
{
|
||||
// we need to know our improved (more accuracy here) real terrainposition and the old sampleposition
|
||||
// also we precalculate the traveled ray distance (its not a ray anymore if we use stuff like refraction, eg but hey lets stick to this word)
|
||||
depth = t - delt + delt*(lh-ly)/(ro.y-depth+lh-ly);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// store our last height and last sampleposition on the y-axis
|
||||
// we need this to calculate the improved terrainposition which will give us a smoother transition between our samplesteps (rd*delt)
|
||||
lh = depth;
|
||||
ly = ro.y;
|
||||
|
||||
// advance our steplength the more we travel the bigger our stepsize should be
|
||||
// with this we are able to sample finer details near to our camera
|
||||
delt = 0.002 + (t/(40 * saturate(rd.y+1))); //detail level
|
||||
}
|
||||
|
||||
// we hit nothing
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
vec3 calculateSkySub(vec3 rd)
|
||||
{
|
||||
return norm(smoothrnd(abs(rd.xy*rd.z+rd.y*2))) * vec3(0.15) +
|
||||
norm(smoothrnd(1.5*abs(rd.xy*rd.z+rd.y+10)))* vec3(0.15) +
|
||||
norm(smoothrnd(2.5*abs(rd.xy*rd.z+rd.y+20)))* vec3(0.15);
|
||||
}
|
||||
|
||||
|
||||
vec4 calcPlanet(vec3 ro, vec3 rd)
|
||||
{
|
||||
vec4 color = vec4(0);
|
||||
|
||||
vec3 planetPos = vec3(70, 20, 100);
|
||||
float dist = dot(rd, normalize(planetPos-ro))-0.95;
|
||||
if (dist>0)
|
||||
{
|
||||
dist = length(planetPos-ro)-dist*800;
|
||||
vec3 p = ro+rd*dist;
|
||||
vec3 n = normalize(planetPos-p);
|
||||
vec2 uv = 0.5 + 0.5 * vec2(atan(n.z, n.x), acos(n.y)) / pi * vec2(5, 50);
|
||||
color.rgb = max(0., 0.2+dot(normalize(p-lightPos), n)) *
|
||||
(caustic(uv.x*0.5+Y.z*0.1, uv.y*0.5,0.)+0.5)*.15 * vec3(1,0,1);
|
||||
color.a = 1;
|
||||
}
|
||||
else dist = FAR*99;
|
||||
|
||||
// hit with plane
|
||||
vec3 pN = vec3(-0.96,0.96,-0.2);
|
||||
float t = dot(pN, planetPos-ro) / dot(pN, rd);
|
||||
if (t > 0 && t < dist)
|
||||
{
|
||||
float d = length(planetPos - (ro+rd*t));
|
||||
if (d > 52 && d < 80)
|
||||
color.rgb = mix(color.rgb, vec3(0.8, 0.64, 0.4), t / 200 * norm(sin((d-50)/30 * smoothrnd(vec2(d, 3)))));
|
||||
color.a = color.a < 1 ? 3 * length(color) : color.a;
|
||||
}
|
||||
|
||||
return vec4(max(vec3(0), color.xyz*0.3) * clamp(dot(rd, vec3(0,1,0))*8, 0., 1.0), color.a);
|
||||
}
|
||||
|
||||
vec3 calculateSky(vec3 ro, vec3 rd, int addPlanet)
|
||||
{
|
||||
// atmospheric scattering+sun
|
||||
vec3 color = max(vec3(0), (max(vec3(0), pow(dot(lightDir, rd), 6.0)) * .7 - rd.y) * mix(vec3(1,0.5,0), vec3(1), min(1.0, lightDir.y*1.5)) + lightDir.y * 3);
|
||||
|
||||
float phi = atan(rd.x, rd.z);
|
||||
float theta = acos(rd.y / length(rd));
|
||||
float coeff = smoothstep(0.0, 0.5, norm(0.5 * smoothrnd(300 * vec2(phi, theta))) + norm(0.75 * smoothrnd(500 * vec2(phi, theta))) - 1.25) * saturate(1.0-lightDir.y*5);
|
||||
if (addPlanet>0)
|
||||
{
|
||||
// a planet
|
||||
vec4 p = calcPlanet(ro, rd);
|
||||
color += coeff*saturate(1-p.a) + p.rgb;
|
||||
}
|
||||
|
||||
// the clouds
|
||||
rd.xy += ro.xy*eps;
|
||||
color += (calculateSkySub(normalize(rd + vec3(sin(Y.z*0.1),0,cos(Y.z*0.1)) * 0.1)*3) +
|
||||
calculateSkySub(normalize(rd + vec3(sin(Y.z*0.1),0,cos(Y.z*0.1)) * 0.2)*5)*0.1 +
|
||||
calculateSkySub(normalize(rd + vec3(sin(Y.z*0.1),0,cos(Y.z*0.1)) * 0.4)*7)*0.1 -
|
||||
calculateSkySub(normalize(rd + vec3(sin(Y.z*0.2),0,0) * 0.5))*1.5) * saturate(rd.y+0.5);
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
float isoSurface(vec3 p)
|
||||
{
|
||||
float b = Y.z>80&&Y.z<112?1:0;
|
||||
p = rotateX(rotateY(rotateX(rotateY(p - artifactPos.xyz, 3*Y.z), 3*Y.z), b*sin(3*Y.z+3*p.y)), b*sin(3*Y.z+3*p.x));
|
||||
p *= 4 + 10 * max(0., Y.z - EXPLOSIONTIME);
|
||||
|
||||
return -0.4 +
|
||||
p.x*p.x*p.x*p.x*p.x*p.x*p.x*p.x +
|
||||
p.y*p.y*p.y*p.y*p.y*p.y*p.y*p.y +
|
||||
p.z*p.z*p.z*p.z*p.z*p.z*p.z*p.z;
|
||||
|
||||
}
|
||||
|
||||
float traceIso(vec3 ro, vec3 rd, float mint, float maxt, float s)
|
||||
{
|
||||
float lt, liso, exact, delt = (maxt-mint)/s;
|
||||
|
||||
for (float t = mint; t < maxt; t += delt)
|
||||
{
|
||||
vec3 p = ro + t * rd;
|
||||
float iso = isoSurface(p);
|
||||
if (iso <= 0)
|
||||
{
|
||||
for(int i = 0; i < 9; i++)
|
||||
{
|
||||
exact = (lt + t) / 2;
|
||||
if (isoSurface(ro + exact * rd) < 0) t = exact;
|
||||
else lt = exact;
|
||||
}
|
||||
return exact;
|
||||
}
|
||||
|
||||
lt = t;
|
||||
liso = iso;
|
||||
}
|
||||
|
||||
return FAR;
|
||||
}
|
||||
|
||||
void calcBurn(vec2 x, vec3 normal, inout vec3 color)
|
||||
{
|
||||
float gd = length(x - artifactPos.xz);
|
||||
float maxV = Y.z - EXPLOSIONTIME;
|
||||
if (maxV > 0 && gd < maxV)
|
||||
{
|
||||
float minV = maxV*0.9;
|
||||
if (gd < maxV-(maxV-minV))
|
||||
{
|
||||
float strength = saturate((gd-minV) / ((maxV-(maxV-minV)*2)-minV));
|
||||
color *= (1-strength*1.5);
|
||||
color += (1-strength*0.8) *
|
||||
pow(norm(normal.x) + norm(normal.y),
|
||||
2*norm(smoothrnd(0.4*Y.z+x*20))*
|
||||
norm(smoothrnd(10 +x*5 ))+
|
||||
1.
|
||||
) * vec3(1.5, 0.75, 0.5);
|
||||
}
|
||||
if(gd > maxV-(maxV-minV)*2)
|
||||
color += cos( (gd-minV) / (maxV-minV) * pi*0.5 ) * vec3(1.5, 0.75, 0.5) ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
vec3 calcScene(vec3 ro, vec3 rd)
|
||||
{
|
||||
float upperPlane = (0.1-ro.y) / rd.y;
|
||||
float finalDepth = 200;
|
||||
vec3 color = calculateSky(ro, rd, 1);
|
||||
if (rd.y < -0.01 && traceTerrain(ro+rd*upperPlane, rd, finalDepth, finalDepth)>0) // prevent endless stuff and other funny shit
|
||||
{
|
||||
finalDepth += upperPlane;
|
||||
vec3 pos = ro+rd*finalDepth;
|
||||
vec3 normal = normalize(normalize(
|
||||
vec3(
|
||||
height(pos.xz - vec2(eps, 0)) - height(pos.xz + vec2(eps, 0)),
|
||||
eps*2,
|
||||
height(pos.xz - vec2(0, eps)) - height(pos.xz + vec2(0, eps))
|
||||
)
|
||||
) +
|
||||
(getWaterNormal(pos*0.2)*1.5+getWaterNormal(pos*0.1)) * max(0., 1-finalDepth/FAR*7)
|
||||
);
|
||||
|
||||
color = max(0., dot(normal, lightDir) // diffuse
|
||||
+ pow(max(0., dot(normal, normalize(lightDir-rd))), 2.0) // specular
|
||||
) *
|
||||
calculateSky(pos, reflect(rd, normal), 1);
|
||||
|
||||
// burn
|
||||
calcBurn(pos.xz, normal, color);
|
||||
|
||||
// depth fog
|
||||
color = mix( color,
|
||||
calculateSky(ro, rd, 0),
|
||||
saturate(finalDepth/FAR*1.6 + saturate(dot(normalize(normal+rd*.2), rd)))
|
||||
); // sky refl and fog
|
||||
}
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
FAR = 9;
|
||||
EXPLOSIONTIME = 127;
|
||||
pi = 3.1416;
|
||||
|
||||
rd = normalize(vec3(Y.xy - 0.5, 1));
|
||||
artifactPos = vec4(10.0, norm(sin(Y.z*1+4)), 13, 0.);
|
||||
|
||||
ro = vec3(.0, .25, 0.);
|
||||
float t = Y.z;
|
||||
if (t < 16) // 1 intro
|
||||
{
|
||||
t = time(t,0,16);
|
||||
t = 1-pow(1-t, 2.);
|
||||
lightPos = vec3(-400, 100 - t*450, 1000);
|
||||
|
||||
t=(t-1)*0.7;
|
||||
rd = rotateX(rd, -t);
|
||||
}
|
||||
else if (t < 32) // 1 intro
|
||||
{
|
||||
t=time(t,16,32);
|
||||
t = 1-pow(1-t, 2.);
|
||||
lightPos = vec3(-400, -350+t*600, 1000);
|
||||
ro.y -= t*0.1;
|
||||
}
|
||||
else if (t < 40) // 2. langatmiges bestaunen des szenarios
|
||||
{
|
||||
lightPos = vec3(-400, 250, 1000);
|
||||
ro.y -= 0.1;
|
||||
}
|
||||
else if (t < 64) //3. annäherung an das artefakt
|
||||
{
|
||||
// Determine the scene we're in
|
||||
int scene = int((t-40)/6.);
|
||||
if (scene >= 3) // 3. annäherung an das artefakt
|
||||
artifactPos.w = 1.;
|
||||
lightPos = vec3(-400, min(250., norm(rnd(vec2(scene, 2))) * 400), 1000);
|
||||
|
||||
// Get a random initial position for our camera
|
||||
ro.xz += vec2(0.1, 20) * vec2(rnd(vec2(scene, 5)), rnd(vec2(scene, 7)));
|
||||
|
||||
// Basing on the initial position, choose some "random" start and end points nearby
|
||||
ro = mix(
|
||||
ro+vec3(0.008)*abs(vec3(rnd(vec2(scene, 8)), 0, rnd(vec2(scene, 10)))),
|
||||
ro+vec3(.75) *abs(vec3(rnd(vec2(scene, 11)), 0, rnd(vec2(scene, 13)))),
|
||||
t-40-scene);
|
||||
ro.y = 0.2;
|
||||
rd = rotateY(rd, rnd(vec2(scene, 14))*pi);
|
||||
}
|
||||
else // 4. artefakt ist im mittelpunkt and 5. BOOM
|
||||
{
|
||||
artifactPos.w = 1.;
|
||||
lightPos = vec3(-400, norm(sin(t+10)) * 250, 1000);
|
||||
float i = smoothstep(118.,120.,t);
|
||||
ro.xz = artifactPos.xz +
|
||||
mix(vec2(sin(t*0.6), cos(t*0.6))*mix(sin(t*1.5+10)+2,2.,i),
|
||||
vec2(0,2+0.75*(t - EXPLOSIONTIME)),
|
||||
smoothstep(-1.0, 1.0, t - EXPLOSIONTIME)
|
||||
);
|
||||
ro.y = mix(norm(sin(t*3)*(1-i))*0.3,
|
||||
0.0,
|
||||
smoothstep(-1.0, 1.0, t - EXPLOSIONTIME)
|
||||
) + 0.2;
|
||||
vec2 dir = normalize(artifactPos.xz-ro.xz);
|
||||
rd = rotateY(rd, atan(dir.y, dir.x)-pi/2);
|
||||
}
|
||||
|
||||
lightDir = normalize(lightPos-ro);
|
||||
|
||||
float dist = length(ro-artifactPos.xyz)-1;
|
||||
float isoDistance = artifactPos.w==1?traceIso(ro, rd, dist, dist+2, 99.0):FAR;
|
||||
if (isoDistance < FAR)
|
||||
{
|
||||
ro += isoDistance * rd;
|
||||
vec3 n = normalize(vec3(
|
||||
isoSurface(vec3(ro.x-eps, ro.y, ro.z))-isoSurface(vec3(ro.x+eps, ro.y, ro.z)),
|
||||
isoSurface(vec3(ro.x, ro.y-eps, ro.z))-isoSurface(vec3(ro.x, ro.y+eps, ro.z)),
|
||||
isoSurface(vec3(ro.x, ro.y, ro.z-eps))-isoSurface(vec3(ro.x, ro.y, ro.z+eps))));
|
||||
rd = reflect(rd, n);
|
||||
}
|
||||
|
||||
gl_FragColor = vec4(calcScene(ro, rd) * clamp(sin((Y.z/150)*pi)*10, 0.0, 1.0),1);
|
||||
}
|
||||
351
ocean4k/src/ocean4k/ocean4k.vcproj
Normal file
351
ocean4k/src/ocean4k/ocean4k.vcproj
Normal file
@@ -0,0 +1,351 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9,00"
|
||||
Name="ocean4k"
|
||||
ProjectGUID="{213903DE-E40A-4D23-9310-E520AC2B412E}"
|
||||
RootNamespace="ocean4k"
|
||||
Keyword="Win32Proj"
|
||||
TargetFrameworkVersion="196613"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="$(SolutionDir)bin"
|
||||
IntermediateDirectory="$(SolutionDir)obj\$(ProjectName)_$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="0"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
DebugInformationFormat="4"
|
||||
CallingConvention="2"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="opengl32.lib winmm.lib glu32.lib"
|
||||
OutputFile="$(OutDir)\$(ProjectName)_$(ConfigurationName).exe"
|
||||
LinkIncremental="2"
|
||||
AdditionalLibraryDirectories=""$(ProjectDir)""
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="1"
|
||||
EntryPointSymbol="main"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="$(SolutionDir)bin"
|
||||
IntermediateDirectory="$(SolutionDir)obj\$(ProjectName)_$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="0"
|
||||
WholeProgramOptimization="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
CommandLine=""
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="1"
|
||||
EnableIntrinsicFunctions="true"
|
||||
FavorSizeOrSpeed="2"
|
||||
WholeProgramOptimization="false"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
|
||||
ExceptionHandling="0"
|
||||
RuntimeLibrary="0"
|
||||
BufferSecurityCheck="false"
|
||||
RuntimeTypeInfo="false"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="0"
|
||||
DebugInformationFormat="3"
|
||||
CallingConvention="2"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalOptions="/CRINKLER /COMPMODE:INSTANT"
|
||||
AdditionalDependencies="opengl32.lib winmm.lib libcmt.lib"
|
||||
OutputFile="$(OutDir)\$(ProjectName)_$(ConfigurationName).exe"
|
||||
AdditionalLibraryDirectories=""$(ProjectDir)""
|
||||
GenerateManifest="false"
|
||||
ManifestFile=""
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="2"
|
||||
LinkTimeCodeGeneration="0"
|
||||
EntryPointSymbol="main"
|
||||
RandomizedBaseAddress="0"
|
||||
DataExecutionPrevention="0"
|
||||
TargetMachine="1"
|
||||
ErrorReporting="0"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Compress (Slow)|Win32"
|
||||
OutputDirectory="$(SolutionDir)bin"
|
||||
IntermediateDirectory="$(SolutionDir)obj\$(ProjectName)_$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="0"
|
||||
WholeProgramOptimization="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
CommandLine=""
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="1"
|
||||
EnableIntrinsicFunctions="true"
|
||||
FavorSizeOrSpeed="2"
|
||||
WholeProgramOptimization="false"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
|
||||
ExceptionHandling="0"
|
||||
RuntimeLibrary="0"
|
||||
BufferSecurityCheck="false"
|
||||
EnableFunctionLevelLinking="false"
|
||||
RuntimeTypeInfo="false"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="0"
|
||||
DebugInformationFormat="0"
|
||||
CallingConvention="2"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalOptions="/CRINKLER /COMPMODE:SLOW /ORDERTRIES:5000 /HASHTRIES:200 /UNSAFEIMPORT /HASHSIZE:200 /REPORT:report.html /RANGE:opengl32 /PROGRESSGUI"
|
||||
AdditionalDependencies="opengl32.lib winmm.lib"
|
||||
OutputFile="$(OutDir)\$(ProjectName)_$(ConfigurationName).exe"
|
||||
AdditionalLibraryDirectories=""$(ProjectDir)""
|
||||
GenerateManifest="false"
|
||||
ManifestFile=""
|
||||
GenerateDebugInformation="false"
|
||||
SubSystem="2"
|
||||
LinkTimeCodeGeneration="0"
|
||||
EntryPointSymbol="main"
|
||||
RandomizedBaseAddress="0"
|
||||
DataExecutionPrevention="0"
|
||||
TargetMachine="1"
|
||||
ErrorReporting="0"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\main.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Shaders.cpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\glext.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\release.h"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
Description=""
|
||||
CommandLine=""
|
||||
AdditionalDependencies=""
|
||||
Outputs=""
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Compress (Slow)|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
Description=""
|
||||
CommandLine=""
|
||||
AdditionalDependencies=""
|
||||
Outputs=""
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Shaders.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\small.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Resource Files"
|
||||
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
|
||||
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
|
||||
>
|
||||
</Filter>
|
||||
<File
|
||||
RelativePath=".\4klang.obj"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\mark.fs"
|
||||
>
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
||||
93
ocean4k/src/ocean4k/ocean4k.vcproj.FIARA.Frank.user
Normal file
93
ocean4k/src/ocean4k/ocean4k.vcproj.FIARA.Frank.user
Normal file
@@ -0,0 +1,93 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioUserFile
|
||||
ProjectType="Visual C++"
|
||||
Version="9,00"
|
||||
ShowAllFiles="false"
|
||||
>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<DebugSettings
|
||||
Command="$(TargetPath)"
|
||||
WorkingDirectory=""
|
||||
CommandArguments=""
|
||||
Attach="false"
|
||||
DebuggerType="3"
|
||||
Remote="1"
|
||||
RemoteMachine="SHAIKUR"
|
||||
RemoteCommand=""
|
||||
HttpUrl=""
|
||||
PDBPath=""
|
||||
SQLDebugging=""
|
||||
Environment=""
|
||||
EnvironmentMerge="true"
|
||||
DebuggerFlavor=""
|
||||
MPIRunCommand=""
|
||||
MPIRunArguments=""
|
||||
MPIRunWorkingDirectory=""
|
||||
ApplicationCommand=""
|
||||
ApplicationArguments=""
|
||||
ShimCommand=""
|
||||
MPIAcceptMode=""
|
||||
MPIAcceptFilter=""
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<DebugSettings
|
||||
Command="$(TargetPath)"
|
||||
WorkingDirectory=""
|
||||
CommandArguments=""
|
||||
Attach="false"
|
||||
DebuggerType="3"
|
||||
Remote="1"
|
||||
RemoteMachine="SHAIKUR"
|
||||
RemoteCommand=""
|
||||
HttpUrl=""
|
||||
PDBPath=""
|
||||
SQLDebugging=""
|
||||
Environment=""
|
||||
EnvironmentMerge="true"
|
||||
DebuggerFlavor=""
|
||||
MPIRunCommand=""
|
||||
MPIRunArguments=""
|
||||
MPIRunWorkingDirectory=""
|
||||
ApplicationCommand=""
|
||||
ApplicationArguments=""
|
||||
ShimCommand=""
|
||||
MPIAcceptMode=""
|
||||
MPIAcceptFilter=""
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Compress (Slow)|Win32"
|
||||
>
|
||||
<DebugSettings
|
||||
Command="$(TargetPath)"
|
||||
WorkingDirectory=""
|
||||
CommandArguments=""
|
||||
Attach="false"
|
||||
DebuggerType="3"
|
||||
Remote="1"
|
||||
RemoteMachine="SHAIKUR"
|
||||
RemoteCommand=""
|
||||
HttpUrl=""
|
||||
PDBPath=""
|
||||
SQLDebugging=""
|
||||
Environment=""
|
||||
EnvironmentMerge="true"
|
||||
DebuggerFlavor=""
|
||||
MPIRunCommand=""
|
||||
MPIRunArguments=""
|
||||
MPIRunWorkingDirectory=""
|
||||
ApplicationCommand=""
|
||||
ApplicationArguments=""
|
||||
ShimCommand=""
|
||||
MPIAcceptMode=""
|
||||
MPIAcceptFilter=""
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
</VisualStudioUserFile>
|
||||
93
ocean4k/src/ocean4k/ocean4k.vcproj.Shaikur.Frank.user
Normal file
93
ocean4k/src/ocean4k/ocean4k.vcproj.Shaikur.Frank.user
Normal file
@@ -0,0 +1,93 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioUserFile
|
||||
ProjectType="Visual C++"
|
||||
Version="9,00"
|
||||
ShowAllFiles="true"
|
||||
>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<DebugSettings
|
||||
Command="$(TargetPath)"
|
||||
WorkingDirectory=""
|
||||
CommandArguments=""
|
||||
Attach="false"
|
||||
DebuggerType="3"
|
||||
Remote="1"
|
||||
RemoteMachine="SHAIKUR"
|
||||
RemoteCommand=""
|
||||
HttpUrl=""
|
||||
PDBPath=""
|
||||
SQLDebugging=""
|
||||
Environment=""
|
||||
EnvironmentMerge="true"
|
||||
DebuggerFlavor=""
|
||||
MPIRunCommand=""
|
||||
MPIRunArguments=""
|
||||
MPIRunWorkingDirectory=""
|
||||
ApplicationCommand=""
|
||||
ApplicationArguments=""
|
||||
ShimCommand=""
|
||||
MPIAcceptMode=""
|
||||
MPIAcceptFilter=""
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<DebugSettings
|
||||
Command="$(TargetPath)"
|
||||
WorkingDirectory=""
|
||||
CommandArguments=""
|
||||
Attach="false"
|
||||
DebuggerType="3"
|
||||
Remote="1"
|
||||
RemoteMachine="SHAIKUR"
|
||||
RemoteCommand=""
|
||||
HttpUrl=""
|
||||
PDBPath=""
|
||||
SQLDebugging=""
|
||||
Environment=""
|
||||
EnvironmentMerge="true"
|
||||
DebuggerFlavor=""
|
||||
MPIRunCommand=""
|
||||
MPIRunArguments=""
|
||||
MPIRunWorkingDirectory=""
|
||||
ApplicationCommand=""
|
||||
ApplicationArguments=""
|
||||
ShimCommand=""
|
||||
MPIAcceptMode=""
|
||||
MPIAcceptFilter=""
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Compress (Slow)|Win32"
|
||||
>
|
||||
<DebugSettings
|
||||
Command="$(TargetPath)"
|
||||
WorkingDirectory=""
|
||||
CommandArguments=""
|
||||
Attach="false"
|
||||
DebuggerType="3"
|
||||
Remote="1"
|
||||
RemoteMachine="SHAIKUR"
|
||||
RemoteCommand=""
|
||||
HttpUrl=""
|
||||
PDBPath=""
|
||||
SQLDebugging=""
|
||||
Environment=""
|
||||
EnvironmentMerge="true"
|
||||
DebuggerFlavor=""
|
||||
MPIRunCommand=""
|
||||
MPIRunArguments=""
|
||||
MPIRunWorkingDirectory=""
|
||||
ApplicationCommand=""
|
||||
ApplicationArguments=""
|
||||
ShimCommand=""
|
||||
MPIAcceptMode=""
|
||||
MPIAcceptFilter=""
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
</VisualStudioUserFile>
|
||||
192
ocean4k/src/ocean4k/ocean4k.vcxproj
Normal file
192
ocean4k/src/ocean4k/ocean4k.vcxproj
Normal file
@@ -0,0 +1,192 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Compress (Slow)|Win32">
|
||||
<Configuration>Compress (Slow)</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{213903DE-E40A-4D23-9310-E520AC2B412E}</ProjectGuid>
|
||||
<RootNamespace>ocean4k</RootNamespace>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Compress (Slow)|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<PlatformToolset>v110</PlatformToolset>
|
||||
<CharacterSet>NotSet</CharacterSet>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<PlatformToolset>v110</PlatformToolset>
|
||||
<CharacterSet>NotSet</CharacterSet>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<PlatformToolset>v110</PlatformToolset>
|
||||
<CharacterSet>NotSet</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Compress (Slow)|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<_ProjectFileVersion>11.0.60315.1</_ProjectFileVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<OutDir>$(SolutionDir)bin\</OutDir>
|
||||
<IntDir>$(SolutionDir)obj\$(ProjectName)_$(Configuration)\</IntDir>
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<OutDir>$(SolutionDir)bin\</OutDir>
|
||||
<IntDir>$(SolutionDir)obj\$(ProjectName)_$(Configuration)\</IntDir>
|
||||
<GenerateManifest>false</GenerateManifest>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Compress (Slow)|Win32'">
|
||||
<OutDir>$(SolutionDir)bin\</OutDir>
|
||||
<IntDir>$(SolutionDir)obj\$(ProjectName)_$(Configuration)\</IntDir>
|
||||
<GenerateManifest>false</GenerateManifest>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<MinimalRebuild>true</MinimalRebuild>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
<PrecompiledHeader />
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
|
||||
<CallingConvention>StdCall</CallingConvention>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>opengl32.lib;winmm.lib;glu32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<OutputFile>$(OutDir)$(ProjectName)_$(Configuration).exe</OutputFile>
|
||||
<AdditionalLibraryDirectories>$(ProjectDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EntryPointSymbol>main</EntryPointSymbol>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<PreBuildEvent>
|
||||
<Command />
|
||||
</PreBuildEvent>
|
||||
<ClCompile>
|
||||
<Optimization>MinSpace</Optimization>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
|
||||
<WholeProgramOptimization>false</WholeProgramOptimization>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ExceptionHandling />
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||
<RuntimeTypeInfo>false</RuntimeTypeInfo>
|
||||
<PrecompiledHeader />
|
||||
<WarningLevel>TurnOffAllWarnings</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<CallingConvention>StdCall</CallingConvention>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalOptions>/CRINKLER /COMPMODE:INSTANT %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalDependencies>opengl32.lib;winmm.lib;libcmt.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<OutputFile>$(OutDir)$(ProjectName)_$(Configuration).exe</OutputFile>
|
||||
<AdditionalLibraryDirectories>$(ProjectDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<ManifestFile />
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<LinkTimeCodeGeneration />
|
||||
<EntryPointSymbol>main</EntryPointSymbol>
|
||||
<RandomizedBaseAddress />
|
||||
<DataExecutionPrevention />
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
<LinkErrorReporting />
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Compress (Slow)|Win32'">
|
||||
<PreBuildEvent>
|
||||
<Command />
|
||||
</PreBuildEvent>
|
||||
<ClCompile>
|
||||
<Optimization>MinSpace</Optimization>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
|
||||
<WholeProgramOptimization>false</WholeProgramOptimization>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ExceptionHandling />
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||
<FunctionLevelLinking>false</FunctionLevelLinking>
|
||||
<RuntimeTypeInfo>false</RuntimeTypeInfo>
|
||||
<PrecompiledHeader />
|
||||
<WarningLevel>TurnOffAllWarnings</WarningLevel>
|
||||
<DebugInformationFormat />
|
||||
<CallingConvention>StdCall</CallingConvention>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalOptions>/CRINKLER /COMPMODE:SLOW /ORDERTRIES:5000 /HASHTRIES:200 /UNSAFEIMPORT /HASHSIZE:200 /REPORT:report.html /RANGE:opengl32 /PROGRESSGUI %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalDependencies>opengl32.lib;winmm.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<OutputFile>$(OutDir)$(ProjectName)_$(Configuration).exe</OutputFile>
|
||||
<AdditionalLibraryDirectories>$(ProjectDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<ManifestFile />
|
||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<LinkTimeCodeGeneration />
|
||||
<EntryPointSymbol>main</EntryPointSymbol>
|
||||
<RandomizedBaseAddress />
|
||||
<DataExecutionPrevention />
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
<LinkErrorReporting />
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="main.cpp" />
|
||||
<ClCompile Include="Shaders.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="glext.h" />
|
||||
<CustomBuild Include="release.h">
|
||||
<Message Condition="'$(Configuration)|$(Platform)'=='Compress (Slow)|Win32'">
|
||||
</Message>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Compress (Slow)|Win32'">
|
||||
</Command>
|
||||
<Message Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
</Message>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
</Command>
|
||||
</CustomBuild>
|
||||
<ClInclude Include="Shaders.h" />
|
||||
<ClInclude Include="small.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Object Include="4klang.obj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="mark.fs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
47
ocean4k/src/ocean4k/ocean4k.vcxproj.filters
Normal file
47
ocean4k/src/ocean4k/ocean4k.vcxproj.filters
Normal file
@@ -0,0 +1,47 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="main.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Shaders.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="glext.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Shaders.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="small.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Object Include="4klang.obj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="mark.fs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<CustomBuild Include="release.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</CustomBuild>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
232
ocean4k/src/ocean4k/release.h
Normal file
232
ocean4k/src/ocean4k/release.h
Normal file
@@ -0,0 +1,232 @@
|
||||
#pragma once
|
||||
|
||||
#pragma data_seg(".shaders")
|
||||
static char* fsh =
|
||||
"varying vec4 Y;" // Line 1
|
||||
"vec4 u;" // Line 4
|
||||
"vec3 x,w,A,z;" // Line 5
|
||||
"float t,s,y,v=.0001;float a(float B){" // Line 6
|
||||
"return clamp(B,.0,1.);}float b(float D,int C,int B){" // Line 8
|
||||
"return (D-C)/(B-C);}vec3 c(vec3 B,float C){" // Line 9
|
||||
"return vec3(" // Line 13
|
||||
"cos(C)*B.x-sin(C)*B.z," // Line 14
|
||||
"B.y," // Line 15
|
||||
"sin(C)*B.x+cos(C)*B." // Line 16
|
||||
"z" // Line 17
|
||||
");}vec3 d(vec3 B,float C){" // Line 18
|
||||
"return vec3(" // Line 23
|
||||
"B.x," // Line 24
|
||||
"B.y*cos(C)-B.z*sin(C)," // Line 25
|
||||
"B.y*sin(C)+B.z*cos(C)" // Line 26
|
||||
");}float e(vec2 C){" // Line 27
|
||||
"int B=int(C.x*40+C.y*6400);" // Line 33
|
||||
"B=(B<<13)^B;" // Line 34
|
||||
"return 1-float((B*(B*B*15731+789221)+1376312589)&0x7fffffff)/1073741824;}float f(float B){" // Line 35
|
||||
"return B*.5+.5;}float g(float C,float D,float B){" // Line 41
|
||||
"return pow((" // Line 47
|
||||
"f(sin(y*2*(C+D+Y.z*B)))+" // Line 48
|
||||
"f(sin(y*(D-C-Y.z*B)))+" // Line 49
|
||||
"f(sin(y*(D+Y.z*B)))+" // Line 50
|
||||
"f(sin(y*3*(C-Y.z*B))))*.3,2.);}float h(vec2 D){" // Line 51
|
||||
"D=mod(D,1000.);" // Line 57
|
||||
"vec2 B=fract(D);" // Line 58
|
||||
"D-=B;" // Line 59
|
||||
"vec2 C=B*B*(3.-2.*B);" // Line 60
|
||||
"return mix(" // Line 61
|
||||
"mix(e(D+vec2(0)),e(D+vec2(1,0)),C.x)," // Line 62
|
||||
"mix(e(D+vec2(0,1)),e(D+vec2(1)),C.x),C.y);}float i(vec2 D){" // Line 63
|
||||
"float C=Y.z-s;" // Line 68
|
||||
"float B=mix(1.,max(0.,u.w-u.y),1.-((C>0&&length(D-u.xz)<C)?1.:.0))/" // Line 69
|
||||
"pow(1./max(0.,1.-length(u.xz-D)*.8),2.);" // Line 70
|
||||
"D+=length(D-A.xy);" // Line 71
|
||||
"D*=min(length(D-A.xy)*5,4.);" // Line 72
|
||||
"return g(D.x+Y.z*.75,D.y*.5,.3)*.006+" // Line 74
|
||||
"g(D.x*.1+Y.z*.2,D.y*.1,.02)*.125-" // Line 75
|
||||
".15-B*2;}vec3 j(vec3 B){" // Line 76
|
||||
"return normalize(vec3(" // Line 82
|
||||
"g(B.x*160-12*cos(10*B.z),B.z*140,4.)," // Line 83
|
||||
"8," // Line 84
|
||||
"g(B.z*160-12*sin(10*B.x),B.x*140,4.))*2-1);}int k(vec3 H,vec3 G,float F,out float C){" // Line 85
|
||||
"float D,E,B=0;" // Line 92
|
||||
"for(float I=.1;I<F;I+=B)" // Line 94
|
||||
"{" // Line 95
|
||||
"H+=G*B;" // Line 97
|
||||
"C=i(H.xz);" // Line 100
|
||||
"if(H.y<=C)" // Line 102
|
||||
"{" // Line 103
|
||||
"C=I-B+B*(D-E)/(H.y-C+D-E);" // Line 106
|
||||
"return 1;}" // Line 107
|
||||
"D=C;" // Line 112
|
||||
"E=H.y;" // Line 113
|
||||
"B=.002+(I/(40*a(G.y+1)));}" // Line 117
|
||||
"return 0;}vec3 l(vec3 B){" // Line 121
|
||||
"return f(h(abs(B.xy*B.z+B.y*2)))*vec3(.15)+" // Line 127
|
||||
"f(h(1.5*abs(B.xy*B.z+B.y+10)))*vec3(.15)+" // Line 128
|
||||
"f(h(2.5*abs(B.xy*B.z+B.y+20)))*vec3(.15);}vec4 m(vec3 G,vec3 F){" // Line 129
|
||||
"vec4 B=vec4(0);" // Line 135
|
||||
"vec3 E=vec3(70,20,100);" // Line 137
|
||||
"float C=dot(F,normalize(E-G))-.95;" // Line 138
|
||||
"if(C>0)" // Line 139
|
||||
"{" // Line 140
|
||||
"C=length(E-G)-C*800;" // Line 141
|
||||
"vec3 J=G+F*C;" // Line 142
|
||||
"vec3 I=normalize(E-J);" // Line 143
|
||||
"vec2 K=.5+.5*vec2(atan(I.z,I.x),acos(I.y))/y*vec2(5,50);" // Line 144
|
||||
"B.rgb=max(0.,.2+dot(normalize(J-x),I))*" // Line 145
|
||||
"(g(K.x*.5+Y.z*.1,K.y*.5,0.)+.5)*.15*vec3(1,0,1);" // Line 146
|
||||
"B.a=1;}" // Line 147
|
||||
"else C=t*99;" // Line 149
|
||||
"vec3 D=vec3(-.96,.96,-.2);" // Line 152
|
||||
"float H=dot(D,E-G)/dot(D,F);" // Line 153
|
||||
"if(H>0&&H<C)" // Line 154
|
||||
"{" // Line 155
|
||||
"float I=length(E-(G+F*H));" // Line 156
|
||||
"if(I>52&&I<80)" // Line 157
|
||||
"B.rgb=mix(B.rgb,vec3(.8,.64,.4),H/200*f(sin((I-50)/30*h(vec2(I,3)))));" // Line 158
|
||||
"B.a=B.a<1?3*length(B):B.a;}" // Line 159
|
||||
"return vec4(max(vec3(0),B.xyz*.3)*clamp(dot(F,vec3(0,1,0))*8,0.,1.),B.a);}vec3 n(vec3 G,vec3 F,int B){" // Line 162
|
||||
"vec3 D=max(vec3(0),(max(vec3(0),pow(dot(w,F),6.))*.7-F.y)*mix(vec3(1,.5,0),vec3(1),min(1.,w.y*1.5))+w.y*3);" // Line 168
|
||||
"float E=atan(F.x,F.z);" // Line 170
|
||||
"float H=acos(F.y/length(F));" // Line 171
|
||||
"float C=smoothstep(.0,.5,f(.5*h(300*vec2(E,H)))+f(.75*h(500*vec2(E,H)))-1.25)*a(1.-w.y*5);" // Line 172
|
||||
"if(B>0)" // Line 173
|
||||
"{" // Line 174
|
||||
"vec4 I=m(G,F);" // Line 176
|
||||
"D+=C*a(1-I.a)+I.rgb;}" // Line 177
|
||||
"F.xy+=G.xy*v;" // Line 181
|
||||
"D+=(l(normalize(F+vec3(sin(Y.z*.1),0,cos(Y.z*.1))*.1)*3)+" // Line 182
|
||||
"l(normalize(F+vec3(sin(Y.z*.1),0,cos(Y.z*.1))*.2)*5)*.1+" // Line 183
|
||||
"l(normalize(F+vec3(sin(Y.z*.1),0,cos(Y.z*.1))*.4)*7)*.1-" // Line 184
|
||||
"l(normalize(F+vec3(sin(Y.z*.2),0,0)*.5))*1.5)*a(F.y+.5);" // Line 185
|
||||
"return D;}float o(vec3 C){" // Line 187
|
||||
"int B=Y.z>80&&Y.z<112?1:0;" // Line 192
|
||||
"C=d(c(d(c(C-u.xyz,3*Y.z),3*Y.z),B*sin(3*Y.z+3*C.y)),B*sin(3*Y.z+3*C.x));" // Line 193
|
||||
"C*=4+10*max(0.,Y.z-s);" // Line 194
|
||||
"return -.4+" // Line 196
|
||||
"C.x*C.x*C.x*C.x*C.x*C.x*C.x*C.x+" // Line 197
|
||||
"C.y*C.y*C.y*C.y*C.y*C.y*C.y*C.y+" // Line 198
|
||||
"C.z*C.z*C.z*C.z*C.z*C.z*C.z*C.z;}float p(vec3 I,vec3 H,float G,float F,float J){" // Line 199
|
||||
"float E,D,C,B=(F-G)/J;" // Line 205
|
||||
"for(float K=G;K<F;K+=B)" // Line 207
|
||||
"{" // Line 208
|
||||
"vec3 M=I+K*H;" // Line 209
|
||||
"float L=o(M);" // Line 210
|
||||
"if(L<=0)" // Line 211
|
||||
"{" // Line 212
|
||||
"for(int N=0;N<9;N++)" // Line 213
|
||||
"{" // Line 214
|
||||
"C=(E+K)/2;" // Line 215
|
||||
"if(o(I+C*H)<0)K=C;" // Line 216
|
||||
"else E=C;}" // Line 217
|
||||
"return C;}" // Line 219
|
||||
"E=K;" // Line 222
|
||||
"D=L;}" // Line 223
|
||||
"return t;}void q(vec2 F,vec3 E,inout vec3 B){" // Line 226
|
||||
"float C=length(F-u.xz);" // Line 231
|
||||
"float D=Y.z-s;" // Line 232
|
||||
"if(D>0&&C<D)" // Line 233
|
||||
"{" // Line 234
|
||||
"float G=D*.9;" // Line 235
|
||||
"if(C<D-(D-G))" // Line 236
|
||||
"{" // Line 237
|
||||
"float H=a((C-G)/((D-(D-G)*2)-G));" // Line 238
|
||||
"B*=(1-H*1.5);" // Line 239
|
||||
"B+=(1-H*.8)*" // Line 240
|
||||
"pow(f(E.x)+f(E.y)," // Line 241
|
||||
"2*f(h(.4*Y.z+F*20))*" // Line 242
|
||||
"f(h(10+F*5))+" // Line 243
|
||||
"1." // Line 244
|
||||
")*vec3(1.5,.75,.5);}" // Line 245
|
||||
"if(C>D-(D-G)*2)" // Line 247
|
||||
"B+=cos((C-G)/(D-G)*y*.5)*vec3(1.5,.75,.5);}}vec3 r(vec3 E,vec3 D){" // Line 248
|
||||
"float F=(.1-E.y)/D.y;" // Line 255
|
||||
"float C=200;" // Line 256
|
||||
"vec3 B=n(E,D,1);" // Line 257
|
||||
"if(D.y<-.01&&k(E+D*F,D,C,C)>0)" // Line 258
|
||||
"{" // Line 259
|
||||
"C+=F;" // Line 260
|
||||
"vec3 H=E+D*C;" // Line 261
|
||||
"vec3 G=normalize(normalize(" // Line 262
|
||||
"vec3(" // Line 263
|
||||
"i(H.xz-vec2(v,0))-i(H.xz+vec2(v,0))," // Line 264
|
||||
"v*2," // Line 265
|
||||
"i(H.xz-vec2(0,v))-i(H.xz+vec2(0,v))" // Line 266
|
||||
")" // Line 267
|
||||
")+" // Line 268
|
||||
"(j(H*.2)*1.5+j(H*.1))*max(0.,1-C/t*7)" // Line 269
|
||||
");" // Line 270
|
||||
"B=max(0.,dot(G,w)" // Line 272
|
||||
"+pow(max(0.,dot(G,normalize(w-D))),2.)" // Line 273
|
||||
")*" // Line 274
|
||||
"n(H,reflect(D,G),1);" // Line 275
|
||||
"q(H.xz,G,B);" // Line 278
|
||||
"B=mix(B," // Line 281
|
||||
"n(E,D,0)," // Line 282
|
||||
"a(C/t*1.6+a(dot(normalize(G+D*.2),D)))" // Line 283
|
||||
");}" // Line 284
|
||||
"return B;}void main(){" // Line 287
|
||||
"t=9;" // Line 292
|
||||
"s=127;" // Line 293
|
||||
"y=3.1416;" // Line 294
|
||||
"z=normalize(vec3(Y.xy-.5,1));" // Line 296
|
||||
"u=vec4(10.,f(sin(Y.z*1+4)),13,0.);" // Line 297
|
||||
"A=vec3(.0,.25,0.);" // Line 299
|
||||
"float D=Y.z;" // Line 300
|
||||
"if(D<16)" // Line 301
|
||||
"{" // Line 302
|
||||
"D=b(D,0,16);" // Line 303
|
||||
"D=1-pow(1-D,2.);" // Line 304
|
||||
"x=vec3(-400,100-D*450,1000);" // Line 305
|
||||
"D=(D-1)*.7;" // Line 307
|
||||
"z=d(z,-D);}" // Line 308
|
||||
"else if(D<32)" // Line 310
|
||||
"{" // Line 311
|
||||
"D=b(D,16,32);" // Line 312
|
||||
"D=1-pow(1-D,2.);" // Line 313
|
||||
"x=vec3(-400,-350+D*600,1000);" // Line 314
|
||||
"A.y-=D*.1;}" // Line 315
|
||||
"else if(D<40)" // Line 317
|
||||
"{" // Line 318
|
||||
"x=vec3(-400,250,1000);" // Line 319
|
||||
"A.y-=.1;}" // Line 320
|
||||
"else if(D<64)" // Line 322
|
||||
"{" // Line 323
|
||||
"int E=int((D-40)/6.);" // Line 325
|
||||
"if(E>=3)" // Line 326
|
||||
"u.w=1.;" // Line 327
|
||||
"x=vec3(-400,min(250.,f(e(vec2(E,2)))*400),1000);" // Line 328
|
||||
"A.xz+=vec2(.1,20)*vec2(e(vec2(E,5)),e(vec2(E,7)));" // Line 331
|
||||
"A=mix(" // Line 334
|
||||
"A+vec3(.008)*abs(vec3(e(vec2(E,8)),0,e(vec2(E,10))))," // Line 335
|
||||
"A+vec3(.75)*abs(vec3(e(vec2(E,11)),0,e(vec2(E,13))))," // Line 336
|
||||
"D-40-E);" // Line 337
|
||||
"A.y=.2;" // Line 338
|
||||
"z=c(z,e(vec2(E,14))*y);}" // Line 339
|
||||
"else " // Line 341
|
||||
"{" // Line 342
|
||||
"u.w=1.;" // Line 343
|
||||
"x=vec3(-400,f(sin(D+10))*250,1000);" // Line 344
|
||||
"float F=smoothstep(118.,120.,D);" // Line 345
|
||||
"A.xz=u.xz+" // Line 346
|
||||
"mix(vec2(sin(D*.6),cos(D*.6))*mix(sin(D*1.5+10)+2,2.,F)," // Line 347
|
||||
"vec2(0,2+.75*(D-s))," // Line 348
|
||||
"smoothstep(-1.,1.,D-s)" // Line 349
|
||||
");" // Line 350
|
||||
"A.y=mix(f(sin(D*3)*(1-F))*.3," // Line 351
|
||||
".0," // Line 352
|
||||
"smoothstep(-1.,1.,D-s)" // Line 353
|
||||
")+.2;" // Line 354
|
||||
"vec2 E=normalize(u.xz-A.xz);" // Line 355
|
||||
"z=c(z,atan(E.y,E.x)-y/2);}" // Line 356
|
||||
"w=normalize(x-A);" // Line 359
|
||||
"float B=length(A-u.xyz)-1;" // Line 361
|
||||
"float C=u.w==1?p(A,z,B,B+2,99.):t;" // Line 362
|
||||
"if(C<t)" // Line 363
|
||||
"{" // Line 364
|
||||
"A+=C*z;" // Line 365
|
||||
"vec3 E=normalize(vec3(" // Line 366
|
||||
"o(vec3(A.x-v,A.y,A.z))-o(vec3(A.x+v,A.y,A.z))," // Line 367
|
||||
"o(vec3(A.x,A.y-v,A.z))-o(vec3(A.x,A.y+v,A.z))," // Line 368
|
||||
"o(vec3(A.x,A.y,A.z-v))-o(vec3(A.x,A.y,A.z+v))));" // Line 369
|
||||
"z=reflect(z,E);}" // Line 370
|
||||
"gl_FragColor=vec4(r(A,z)*clamp(sin((Y.z/150)*y)*10,.0,1.),1);}";
|
||||
127
ocean4k/src/ocean4k/small.h
Normal file
127
ocean4k/src/ocean4k/small.h
Normal file
@@ -0,0 +1,127 @@
|
||||
#pragma once
|
||||
|
||||
#pragma code_seg("sm0")
|
||||
|
||||
DWORD x_Ftol(float af_Value)
|
||||
{
|
||||
DWORD ldw_RetVal;
|
||||
__asm fld af_Value
|
||||
__asm fistp ldw_RetVal
|
||||
return ldw_RetVal;
|
||||
}
|
||||
|
||||
#pragma code_seg("sm1")
|
||||
|
||||
__forceinline float x_Frac(float af_Value)
|
||||
{
|
||||
return af_Value - x_Ftol(af_Value);
|
||||
}
|
||||
|
||||
#pragma code_seg("sm2")
|
||||
|
||||
__forceinline float x_Abs(float af_Value)
|
||||
{
|
||||
__asm fld af_Value
|
||||
__asm fabs
|
||||
}
|
||||
|
||||
#pragma code_seg("sm3")
|
||||
|
||||
float x_Sin(float af_Value)
|
||||
{
|
||||
__asm fld af_Value
|
||||
__asm fsin
|
||||
}
|
||||
|
||||
#pragma code_seg("sm4")
|
||||
|
||||
float x_Sign(float af_Value)
|
||||
{
|
||||
if (af_Value != 0)
|
||||
return af_Value / x_Abs(af_Value);
|
||||
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
#pragma code_seg("sm5")
|
||||
|
||||
float x_Sqrt(float af_Value)
|
||||
{
|
||||
__asm fld af_Value
|
||||
__asm fsqrt
|
||||
}
|
||||
|
||||
#pragma code_seg("sm7")
|
||||
|
||||
void x_MemCopy(void* av_Dest_, const void* av_Src_, size_t ai_Size)
|
||||
{
|
||||
__asm mov esi, av_Src_
|
||||
__asm mov edi, av_Dest_
|
||||
__asm mov ecx, ai_Size
|
||||
__asm rep movsb
|
||||
}
|
||||
|
||||
#pragma code_seg("sm8")
|
||||
|
||||
float x_Fmod(float x, float y)
|
||||
{
|
||||
__asm fld y
|
||||
__asm fld x
|
||||
__asm fprem
|
||||
__asm fxch
|
||||
__asm fstp x
|
||||
}
|
||||
|
||||
#pragma data_seg("smA")
|
||||
|
||||
static unsigned long seed=0x12345678;
|
||||
|
||||
#pragma code_seg("sm9")
|
||||
|
||||
__forceinline void x_Randomize(unsigned long x)
|
||||
{
|
||||
seed = x;
|
||||
}
|
||||
|
||||
#pragma code_seg("smB")
|
||||
|
||||
float x_Rand()
|
||||
{
|
||||
seed = seed * 0x76364873 + 1234567;
|
||||
return (float)(seed & 0x7FFFFFFF) * (const float)(2.0f / (float)0x7FFFFFFF) - 1.0f;
|
||||
}
|
||||
|
||||
#pragma code_seg("smS")
|
||||
|
||||
__forceinline GLsizei x_Strlen(const char* as_String)
|
||||
{
|
||||
GLsizei li_Length = 0;
|
||||
while (*as_String++) ++li_Length;
|
||||
return li_Length;
|
||||
}
|
||||
|
||||
#pragma code_seg("smP")
|
||||
|
||||
float x_Pow(float x, float y){
|
||||
float r;
|
||||
__asm{
|
||||
fld y
|
||||
fld x
|
||||
fyl2x
|
||||
fld1
|
||||
fld st(1)
|
||||
fprem
|
||||
f2xm1
|
||||
faddp st(1),st
|
||||
fscale
|
||||
fxch st(1)
|
||||
fstp st(0)
|
||||
fstp r
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
extern "C"
|
||||
{
|
||||
int _fltused = 1;
|
||||
}
|
||||
91
ocean4k/src/ocean4k/synth.cpp
Normal file
91
ocean4k/src/ocean4k/synth.cpp
Normal file
@@ -0,0 +1,91 @@
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_EXTRA_LEAN
|
||||
#include "windows.h"
|
||||
#include "mmsystem.h"
|
||||
#include "mmreg.h"
|
||||
|
||||
// define this if you have a multicore cpu and can spare ~15 bytes for realtime playback
|
||||
// undef for sound precalc
|
||||
#define USE_SOUND_THREAD
|
||||
|
||||
////////////////////////////////////////////////
|
||||
// sound
|
||||
////////////////////////////////////////////////
|
||||
#define SAMPLE_RATE 44100
|
||||
#define MAX_SAMPLES SAMPLE_RATE*2*60*40
|
||||
|
||||
#pragma bss_seg(".synthnothing")
|
||||
static float lpSoundBuffer[MAX_SAMPLES];
|
||||
static HWAVEOUT hWaveOut;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
// initialized data
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma data_seg(".wavefmt")
|
||||
WAVEFORMATEX WaveFMT =
|
||||
{
|
||||
WAVE_FORMAT_IEEE_FLOAT,
|
||||
2, // channels
|
||||
SAMPLE_RATE, // samples per sec
|
||||
SAMPLE_RATE*4*2, // bytes per sec
|
||||
8, // block alignment;
|
||||
32, // bits per sample
|
||||
0 // extension not needed
|
||||
};
|
||||
|
||||
#pragma data_seg(".wavehdr")
|
||||
WAVEHDR WaveHDR =
|
||||
{
|
||||
(LPSTR)lpSoundBuffer,
|
||||
MAX_SAMPLES*4,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
};
|
||||
|
||||
#pragma data_seg(".mmtime")
|
||||
MMTIME MMTime =
|
||||
{
|
||||
TIME_SAMPLES,
|
||||
0
|
||||
};
|
||||
|
||||
// declaration of the external synth render function, you'll always need that
|
||||
extern "C" void _4klang_render(float*);
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
// Initialization
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef USE_SOUND_THREAD
|
||||
#pragma code_seg(".sndthrd")
|
||||
DWORD WINAPI SoundThread( LPVOID lpParam )
|
||||
{
|
||||
_4klang_render(lpSoundBuffer);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#pragma code_seg(".initsnd")
|
||||
extern "C" void InitSound()
|
||||
{
|
||||
#ifdef USE_SOUND_THREAD
|
||||
CreateThread(0, 0, SoundThread, 0, 0, 0);
|
||||
#else
|
||||
_4klang_render(lpSoundBuffer);
|
||||
#endif
|
||||
waveOutOpen ( &hWaveOut, WAVE_MAPPER, &WaveFMT, NULL, 0, CALLBACK_NULL );
|
||||
waveOutPrepareHeader( hWaveOut, &WaveHDR, sizeof(WaveHDR) );
|
||||
waveOutWrite ( hWaveOut, &WaveHDR, sizeof(WaveHDR) );
|
||||
}
|
||||
|
||||
#pragma code_seg(".time")
|
||||
extern "C" float get_Time()
|
||||
{
|
||||
waveOutGetPosition(hWaveOut, &MMTime, sizeof(MMTIME));
|
||||
return float(MMTime.u.sample) / SAMPLE_RATE;
|
||||
}
|
||||
8
ocean4k/src/ocean4k/synth.h
Normal file
8
ocean4k/src/ocean4k/synth.h
Normal file
@@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
extern "C"
|
||||
{
|
||||
__forceinline void InitSound();
|
||||
//float get_Envelope(int instrument);
|
||||
__forceinline float get_Time();
|
||||
}
|
||||
Reference in New Issue
Block a user