port from perforce
This commit is contained in:
BIN
bp4k/party_pack/bin/FlightSim/FlightSim.exe
Normal file
BIN
bp4k/party_pack/bin/FlightSim/FlightSim.exe
Normal file
Binary file not shown.
359
bp4k/party_pack/bin/FlightSim/FlightSimShader.fs
Normal file
359
bp4k/party_pack/bin/FlightSim/FlightSimShader.fs
Normal file
@@ -0,0 +1,359 @@
|
||||
// Time
|
||||
varying float T;
|
||||
|
||||
// Camera data
|
||||
varying vec3 cameraPos;
|
||||
|
||||
// Position of the fragment
|
||||
varying vec2 Z;
|
||||
|
||||
// Forward declarations
|
||||
vec4 traceRay(vec3, vec3, int);
|
||||
vec3 shade(vec4, vec3, vec3);
|
||||
|
||||
|
||||
// All data of our world
|
||||
vec3 lightDir, lightColor, waterColor, ro, rd, interlacing;
|
||||
float gf_DetailLevel, pi, eps, bigeps;
|
||||
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
||||
// 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,0)),rnd(x+vec2(1,0)), u.x),
|
||||
mix(rnd(x+vec2(0,1)),rnd(x+vec2(1,1)), u.x), u.y);
|
||||
}
|
||||
|
||||
|
||||
// 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)
|
||||
{
|
||||
float a = (
|
||||
norm(sin(pi * 2 * (u + v + T*t))) +
|
||||
norm(sin(pi * (v - u - T*t))) +
|
||||
norm(sin(pi * (v + T*t))) +
|
||||
norm(sin(pi * 3 * (u - T*t)))) * 0.3;
|
||||
return pow(a, 2.0);
|
||||
}
|
||||
|
||||
|
||||
// Calculate our TV effects (interlacing, RGB mask and film grain)
|
||||
vec3 pp(vec3 color)
|
||||
{
|
||||
int c = int(mod(gl_FragCoord.x, 3.0));
|
||||
if (c==0) color *= interlacing.xyz;
|
||||
if (c==1) color *= interlacing.yzx;
|
||||
if (c==2) color *= interlacing.zxy;
|
||||
return mix(color, vec3(norm(smoothrnd(Z * 333 + rnd(vec2(T)) * 33333))), 0.03);
|
||||
}
|
||||
|
||||
|
||||
// Our fake godray effect (bad if moving fast, but awesome any other time)
|
||||
vec3 godrays(vec3 color)
|
||||
{
|
||||
vec2 dpos = Z*2-1;
|
||||
float g = dpos.x * (dpos.y + 3);
|
||||
return color + lightColor *
|
||||
caustic(g + 50 * ro.x, g + 50 * ro.z, 1.5) *
|
||||
(norm(dpos.y)) * min(-ro.y * 30, 0.3);
|
||||
}
|
||||
|
||||
|
||||
// Our heightmap calculation function, we could use some perlin noise here if it wouldn't be so performance killing
|
||||
float height(vec2 x)
|
||||
{
|
||||
return (-0.035 + pow((caustic(x.x * 10, x.y * 10, 0.0) * 2 - 1), 2.0) * 0.05)
|
||||
- (x.x - 0.1) * 0.2; // This line creates one entire continent and a big ocean!
|
||||
}
|
||||
|
||||
|
||||
// Gets the terrain normal
|
||||
vec3 getTerrainNormal(vec3 p)
|
||||
{
|
||||
return normalize(vec3(
|
||||
height(p.xz - vec2(bigeps, 0)) - height(p.xz + vec2(bigeps, 0)),
|
||||
2 * bigeps,
|
||||
height(p.xz - vec2(0, bigeps)) - height(p.xz + vec2(0, bigeps))));
|
||||
}
|
||||
|
||||
|
||||
// Global diffuse lighting formula
|
||||
vec3 diffuseLight(vec3 incolor, vec3 normal)
|
||||
{
|
||||
return (0.3 + 0.7 * max(dot(normal, lightDir), 0.0)) * lightColor * incolor;
|
||||
}
|
||||
|
||||
|
||||
// Calculates the water "waves". To reduce the bumpiness, increment the y-axis
|
||||
vec3 getWaterNormal(vec3 p)
|
||||
{
|
||||
return normalize(vec3(
|
||||
caustic(p.x * 160 - cos(p.z * 10) * 12, p.z * 140, 4.0),
|
||||
8,
|
||||
caustic(p.z * 160 - sin(p.x * 10) * 12, p.x * 140, 4.0)) * 2 - 1);
|
||||
}
|
||||
|
||||
|
||||
// Calculate the terrain color for the given voxel
|
||||
vec3 shadeTerrain(vec3 p, vec3 rd)
|
||||
{
|
||||
vec3 n = getTerrainNormal(p);
|
||||
vec3 color = mix(
|
||||
// sandy color
|
||||
vec3(0.66, 0.55, 0.4)
|
||||
|
||||
// basic color (big random color spots)
|
||||
- 0.2 * smoothrnd(abs(p.xz * 150))
|
||||
|
||||
// texture (sediment lines)
|
||||
- 0.2 * smoothrnd(abs(p.yy + 0.002 * smoothrnd(abs(p.xz * 150))) * 3000),
|
||||
|
||||
// interleaved grass, hight dependant
|
||||
vec3(0.1, 0.3, 0) * (smoothrnd(p.xz * 7000.0) * 0.4 + 0.5),
|
||||
|
||||
// mixing for the sand/grass transition
|
||||
clamp(n.y * (caustic(p.x * 111, p.z * 111, 0.0) * 0.5 - p.y * 40), 0.0, 1.0));
|
||||
|
||||
// caustics, only underwater (no cloudshadows, though)
|
||||
if (p.y <= 0)
|
||||
color += 5 * getWaterNormal(0.8 * p).x * min(0.3, -p.y * 8);
|
||||
|
||||
// Light
|
||||
return diffuseLight(color, n);
|
||||
}
|
||||
|
||||
|
||||
// Create a blueish sky transition from navy blue to badass dark blue
|
||||
vec3 shadeSky(vec3 ro, vec3 rd)
|
||||
{
|
||||
return ro.y <= -eps*eps ?
|
||||
waterColor :
|
||||
mix(vec3(-0.5, -0.25, 0), vec3(2), 1 - (rd.y * 0.5 + 0.5));
|
||||
}
|
||||
|
||||
|
||||
// Calculates the refraction and reflection of the water surface.
|
||||
// Also mixes both values by the depth of the water and the fresnel term.
|
||||
// Possible improvements: fix fake underwater reflection and refraction
|
||||
vec3 shadeWaterRefl(vec3 p, vec3 newrd)
|
||||
{
|
||||
vec3 waterNormal = getWaterNormal(p);
|
||||
|
||||
// perform raytracing/raymarching for both reflection and refraction
|
||||
// calc the water refraction, the refraction index (0.9) will decrease with the distance to allow a better over/under water transition
|
||||
vec4 refracted = traceRay(p, refract(newrd, waterNormal, 0.9), 2);//mix(0.9, 1.0, smoothstep(0.01, 0.0, length(p-ro)))), 2);
|
||||
|
||||
// calculate the depth factor (water entry point to terrain voxel) (black magic involved here!)
|
||||
float depth = clamp(pow(1.03 * (1 - length(refracted.xyz - p)), 16.0), 0.0, 1.0);
|
||||
|
||||
// Finally stir the pot =)
|
||||
return mix(
|
||||
ro.y < 0 ? shadeSky(p, newrd) : waterColor, // Water color
|
||||
mix(
|
||||
shade(traceRay(p, reflect(newrd, waterNormal), 2), p, newrd), // Reflection color
|
||||
shade(refracted, p, newrd), // Refraction color
|
||||
clamp(-rd.y + depth, 0.0, 1.0)), // fresnel term
|
||||
refracted.w == 3.0 ? 0.5 : pow(depth, 0.5)); // water color contribution
|
||||
|
||||
}
|
||||
|
||||
|
||||
// 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
|
||||
float traceTerrain(vec3 ro, vec3 rd, float maxt)
|
||||
{
|
||||
float delt, lh, ly, samplePosY;
|
||||
delt = 0; // If the world would consist of only nVidia GPUs, this line wouldn't exist.
|
||||
vec3 samplePos = ro;
|
||||
|
||||
// advance our sample position from our nearplane to our farplane
|
||||
for (float t = 0; t < maxt; t += delt)
|
||||
{
|
||||
// advance our ray
|
||||
samplePos += rd * delt;
|
||||
samplePosY = samplePos.y;
|
||||
|
||||
// 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)
|
||||
float h = height(samplePos.xz);
|
||||
|
||||
if (samplePosY <= h)
|
||||
{
|
||||
// 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)
|
||||
return t - delt + delt*(lh-ly)/(samplePosY-h+lh-ly);
|
||||
}
|
||||
|
||||
// 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 = h;
|
||||
ly = samplePosY;
|
||||
|
||||
// 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/gf_DetailLevel);
|
||||
}
|
||||
|
||||
// we hit nothing
|
||||
return 9.0;
|
||||
}
|
||||
|
||||
|
||||
// Ray vs. plane intersection function
|
||||
float traceWater(vec3 ro, vec3 rd)
|
||||
{
|
||||
float tPlane = -ro.y / rd.y;
|
||||
return tPlane >= eps ? tPlane : 9.0;
|
||||
}
|
||||
|
||||
|
||||
// Raytracing entry point, returns voxel and object ID
|
||||
// IDs:
|
||||
// 0 = sky (not the armageddon, xTr1m!!)
|
||||
// 1 = terrain
|
||||
// 2 = water
|
||||
vec4 traceRay(vec3 ro, vec3 rd, int ignore)
|
||||
{
|
||||
float water, terrain, minDist;
|
||||
|
||||
// trace only the objects we need (only one could maximally be ignored)
|
||||
water = ignore != 2 ? traceWater(ro, rd) : 9.0;
|
||||
terrain = ignore != 1 ? traceTerrain(ro, rd, min(0.5, 0.002 + water)) : 9.0;
|
||||
|
||||
// auto detail level reducing (common dude, give the GPU some breathing room)
|
||||
gf_DetailLevel *= 0.75;
|
||||
|
||||
// find the nearest distance
|
||||
minDist = min(terrain, min(water, 9.0));
|
||||
|
||||
// we hit nothing or the hitpoint is too far
|
||||
if (minDist == 9)
|
||||
return vec4(0);
|
||||
|
||||
// calculate the hit/voxel position
|
||||
vec3 hitPos = ro + rd * minDist;
|
||||
|
||||
// check what we might have hit
|
||||
if (minDist == terrain)
|
||||
return vec4(hitPos, 1);
|
||||
if (minDist == water)
|
||||
return vec4(hitPos, 2);
|
||||
|
||||
// Panic, worry, die to death! Probably we'll land on the moon (this should never happen)
|
||||
//return vec4(0);
|
||||
}
|
||||
|
||||
|
||||
// Entrypoint for color calculation
|
||||
vec3 shadeRefl(vec4 hitPoint, vec3 newRo, vec3 rd)
|
||||
{
|
||||
// determine the fog color for this very precise point in the space time continuum
|
||||
vec3 myFog = newRo.y < eps ? waterColor : shadeSky(ro, rd);
|
||||
|
||||
// generate the distance value for the fog calculation
|
||||
float distance = clamp(length(hitPoint.xyz - newRo) * (ro.y <= 0 ? 4 : 2), 0.0, 1.0);
|
||||
|
||||
// get the color of the hit object and mix it with the fog
|
||||
// in most cases we allow further raytracing here (not for the terrain, its not shiny enough)
|
||||
if (hitPoint.w == 1)
|
||||
return mix(shadeTerrain(hitPoint.xyz, rd), myFog, distance);
|
||||
if (hitPoint.w == 2)
|
||||
return mix(shadeWaterRefl(hitPoint.xyz, rd), myFog, distance);
|
||||
|
||||
return shadeSky(newRo, rd);
|
||||
}
|
||||
|
||||
|
||||
// Get the color from the object we just hit (without further raytraces)
|
||||
// this is necessary because no recursion is allowed in GLSL (damn you!)
|
||||
vec3 shade(vec4 hitPoint, vec3 newRo, vec3 rd)
|
||||
{
|
||||
// determine the fog color for the very same point we discussed earlier
|
||||
vec3 myFog = newRo.y < eps ? waterColor : shadeSky(ro, rd);
|
||||
|
||||
// generate the other distance value. Paid attention? If you don't know what value I'm talking about, rtfm or gtfo.
|
||||
float distance = clamp(length(hitPoint.xyz - newRo) * (ro.y <= 0 ? 4 : 2), 0.0, 1.0);
|
||||
|
||||
// get the color of the hit object and mix it with the fog
|
||||
if (hitPoint.w == 1)
|
||||
return mix(shadeTerrain(hitPoint.xyz, rd), myFog, distance);
|
||||
if (hitPoint.w == 2)
|
||||
return mix(waterColor, myFog, distance);
|
||||
|
||||
return myFog;
|
||||
}
|
||||
|
||||
|
||||
// Now we're just being copycats. We're not creative enough to define own entry points
|
||||
// Sure, we could "#define MYENTRYPOINT main"! Or just void main(){MyEntryPoint();}
|
||||
// None of that would help us win the compo, would it?
|
||||
void main()
|
||||
{
|
||||
// Set the quality setting for the raymarcher, a higher value results in a longer processing time
|
||||
// try to find a good balance between these two, low values will result in a wobbling endresult
|
||||
// low quality = 50.0 (visual results are ok at 640x480)
|
||||
// mid quality = 100.0
|
||||
// high quality = 200.0
|
||||
gf_DetailLevel = 200;
|
||||
|
||||
// Give our saviour global variables some life!
|
||||
pi = 3.1416;
|
||||
interlacing = vec3(1.2, 0.9, 0.9);
|
||||
eps = 0.0001;
|
||||
bigeps = 0.01;
|
||||
|
||||
// Get the look direction for the current pixel (always look forwards)
|
||||
ro = cameraPos; //set ray origin
|
||||
if (ro.y < height(ro.xz) + 0.01f)
|
||||
{
|
||||
ro.y = height(ro.xz) + 0.01f;
|
||||
}
|
||||
|
||||
rd = vec3(gl_ModelViewMatrix * vec4((Z.xy - 0.5), 1, 1));
|
||||
|
||||
// Make our world pretty and worthy to live in (you can cultivate algae and eat them, they're surely enough for survival)
|
||||
lightDir = vec3(0.58, 0.58, -0.58);
|
||||
lightColor = vec3(1.2);
|
||||
waterColor = vec3(0.3, 0.33, 0.4);
|
||||
|
||||
// Our GPU feels good underwater, almost like a refreshing experience :) cool, eh?
|
||||
if (ro.y <= 0)
|
||||
{
|
||||
// Less work to do...
|
||||
gf_DetailLevel *= 0.75;
|
||||
|
||||
// ...and a cozy darker atmosphere
|
||||
lightColor *= 0.8;
|
||||
}
|
||||
|
||||
// Here we go, shoot'em rays and get the color of our fragment!
|
||||
vec3 color = shadeRefl(traceRay(ro, rd, 0), ro, rd);
|
||||
|
||||
// Underwater there are beams of light emanating from god (so called "god" rays...)
|
||||
// ...this prooves that god is nothing less than a water surface.
|
||||
if (ro.y <= 0)
|
||||
color = godrays(color);
|
||||
|
||||
// Apply post processing and fade effects to the color, and finally return it.
|
||||
gl_FragColor.xyz = pp(color);
|
||||
}
|
||||
11
bp4k/party_pack/bin/FlightSim/FlightSimShader.vs
Normal file
11
bp4k/party_pack/bin/FlightSim/FlightSimShader.vs
Normal file
@@ -0,0 +1,11 @@
|
||||
varying float T;
|
||||
varying vec2 Z;
|
||||
varying vec3 cameraPos;
|
||||
|
||||
void main()
|
||||
{
|
||||
T = gl_Color.x;
|
||||
Z = (gl_Vertex.xy*vec2(gl_Color.y,1.0))*0.5+0.5;
|
||||
cameraPos = gl_Normal.xyz;
|
||||
gl_Position = gl_Vertex;
|
||||
}
|
||||
BIN
bp4k/party_pack/bin/valleyball_1024x768.exe
Normal file
BIN
bp4k/party_pack/bin/valleyball_1024x768.exe
Normal file
Binary file not shown.
BIN
bp4k/party_pack/bin/valleyball_1280x1024.exe
Normal file
BIN
bp4k/party_pack/bin/valleyball_1280x1024.exe
Normal file
Binary file not shown.
BIN
bp4k/party_pack/bin/valleyball_1280x720.exe
Normal file
BIN
bp4k/party_pack/bin/valleyball_1280x720.exe
Normal file
Binary file not shown.
BIN
bp4k/party_pack/bin/valleyball_1280x800.exe
Normal file
BIN
bp4k/party_pack/bin/valleyball_1280x800.exe
Normal file
Binary file not shown.
BIN
bp4k/party_pack/bin/valleyball_1368x768.exe
Normal file
BIN
bp4k/party_pack/bin/valleyball_1368x768.exe
Normal file
Binary file not shown.
BIN
bp4k/party_pack/bin/valleyball_1440x900.exe
Normal file
BIN
bp4k/party_pack/bin/valleyball_1440x900.exe
Normal file
Binary file not shown.
BIN
bp4k/party_pack/bin/valleyball_1600x1200.exe
Normal file
BIN
bp4k/party_pack/bin/valleyball_1600x1200.exe
Normal file
Binary file not shown.
BIN
bp4k/party_pack/bin/valleyball_1680x1050.exe
Normal file
BIN
bp4k/party_pack/bin/valleyball_1680x1050.exe
Normal file
Binary file not shown.
BIN
bp4k/party_pack/bin/valleyball_1920x1080.exe
Normal file
BIN
bp4k/party_pack/bin/valleyball_1920x1080.exe
Normal file
Binary file not shown.
BIN
bp4k/party_pack/bin/valleyball_1920x1200.exe
Normal file
BIN
bp4k/party_pack/bin/valleyball_1920x1200.exe
Normal file
Binary file not shown.
BIN
bp4k/party_pack/bin/valleyball_640x480.exe
Normal file
BIN
bp4k/party_pack/bin/valleyball_640x480.exe
Normal file
Binary file not shown.
BIN
bp4k/party_pack/bin/valleyball_800x600.exe
Normal file
BIN
bp4k/party_pack/bin/valleyball_800x600.exe
Normal file
Binary file not shown.
BIN
bp4k/party_pack/music/valleyball.4kp
Normal file
BIN
bp4k/party_pack/music/valleyball.4kp
Normal file
Binary file not shown.
BIN
bp4k/party_pack/music/valleyball.xrns
Normal file
BIN
bp4k/party_pack/music/valleyball.xrns
Normal file
Binary file not shown.
BIN
bp4k/party_pack/src/4klang.obj
Normal file
BIN
bp4k/party_pack/src/4klang.obj
Normal file
Binary file not shown.
255
bp4k/party_pack/src/Shaders.cpp
Normal file
255
bp4k/party_pack/src/Shaders.cpp
Normal file
@@ -0,0 +1,255 @@
|
||||
// Useful functions for the DEBUG configuration
|
||||
#include "Shaders.h"
|
||||
#ifdef _DEBUG
|
||||
|
||||
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_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_VERTEX_SHADER);
|
||||
|
||||
glShaderSource(lh_Shader, 1, (const char**)&ls_ShaderSource, NULL);
|
||||
glCompileShader(lh_Shader);
|
||||
|
||||
free(ls_ShaderSource);
|
||||
|
||||
int li_Status = 0;
|
||||
glGetShaderiv(lh_Shader, GL_COMPILE_STATUS, &li_Status);
|
||||
|
||||
if (li_Status == GL_FALSE)
|
||||
{
|
||||
std::cerr << "Error compiling vertex shader: " << as_FileName << 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
|
||||
20
bp4k/party_pack/src/Shaders.h
Normal file
20
bp4k/party_pack/src/Shaders.h
Normal file
@@ -0,0 +1,20 @@
|
||||
// Useful functions for the DEBUG configuration
|
||||
#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();
|
||||
365
bp4k/party_pack/src/bp4k.vcproj
Normal file
365
bp4k/party_pack/src/bp4k.vcproj
Normal file
@@ -0,0 +1,365 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9,00"
|
||||
Name="bp4k"
|
||||
ProjectGUID="{213903DE-E40A-4D23-9310-E520AC2B412E}"
|
||||
RootNamespace="bp4k"
|
||||
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"
|
||||
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"
|
||||
AdditionalOptions="/QIfist"
|
||||
Optimization="1"
|
||||
EnableIntrinsicFunctions="true"
|
||||
FavorSizeOrSpeed="2"
|
||||
WholeProgramOptimization="false"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
|
||||
ExceptionHandling="0"
|
||||
RuntimeLibrary="0"
|
||||
BufferSecurityCheck="false"
|
||||
EnableFunctionLevelLinking="false"
|
||||
FloatingPointModel="2"
|
||||
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:4000 /HASHTRIES:300 /UNSAFEIMPORT /TRUNCATEFLOATS:24 /HASHSIZE:200 /REPORT:report.html /RANGE:opengl32 /PROGRESSGUI /TRANSFORM:CALLS"
|
||||
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>
|
||||
<File
|
||||
RelativePath=".\synth.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>
|
||||
<File
|
||||
RelativePath=".\synth.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=".\generic.vs"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\mark.fs"
|
||||
>
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
||||
9
bp4k/party_pack/src/generic.vs
Normal file
9
bp4k/party_pack/src/generic.vs
Normal file
@@ -0,0 +1,9 @@
|
||||
varying vec4 Y;
|
||||
varying vec2 Z;
|
||||
|
||||
void main()
|
||||
{
|
||||
Y = gl_Color;
|
||||
Z = (gl_Vertex.xy*vec2(Y.w,1.0))*0.5+0.5;
|
||||
gl_Position = gl_Vertex;
|
||||
}
|
||||
7271
bp4k/party_pack/src/glext.h
Normal file
7271
bp4k/party_pack/src/glext.h
Normal file
File diff suppressed because it is too large
Load Diff
162
bp4k/party_pack/src/main.cpp
Normal file
162
bp4k/party_pack/src/main.cpp
Normal file
@@ -0,0 +1,162 @@
|
||||
#ifdef _DEBUG
|
||||
#include <time.h>
|
||||
#include <io.h>
|
||||
#include <process.h>
|
||||
#include "Shaders.h"
|
||||
#include "small.h"
|
||||
#include "synth.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"
|
||||
#include "synth.h"
|
||||
#include "release.h"
|
||||
#endif
|
||||
|
||||
#pragma data_seg(".vertexshader")
|
||||
static char* vsh = "varying vec4 Y;varying vec2 Z;void main(){Y=gl_Color;Z=(gl_Vertex.xy*vec2(Y.w,1))*.5+.5;gl_Position=gl_Vertex;}";
|
||||
|
||||
#pragma data_seg(".resolutionX")
|
||||
static const int gi_ScreenWidth = 1368;
|
||||
|
||||
#pragma data_seg(".resolutionY")
|
||||
static const int gi_ScreenHeight = 768;
|
||||
|
||||
#pragma data_seg(".aspectratio")
|
||||
//static const float gf_AspectRatio = 1.3281250000f; // smaller version for 4:3
|
||||
static const float gf_AspectRatio = 1.7734375000f; // smaller version for 16:9
|
||||
//static const float gf_AspectRatio = 1.25f; // smaller version for 5:4
|
||||
//static const float gf_AspectRatio = 1.6015625000f; // smaller version for 16:10
|
||||
|
||||
#ifdef _DEBUG
|
||||
#pragma bss_seg(".debugnothing")
|
||||
HANDLE gh_ShaderCompileEvent;
|
||||
static char** gs_LastShader_;
|
||||
static __time64_t gi_ShaderChangedDate;
|
||||
static unsigned int gi_ShaderProgram;
|
||||
static unsigned int gi_LastShaderProgram;
|
||||
#pragma data_seg(".debuginfo")
|
||||
static const char* gs_VertexShader = "generic.vs";
|
||||
static const char* gs_ShaderFile = "mark.fs";
|
||||
#endif
|
||||
|
||||
#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(".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,gi_ScreenWidth,gi_ScreenHeight
|
||||
};
|
||||
|
||||
#pragma code_seg(".compile")
|
||||
__forceinline unsigned int compileShader(const char* vsh, const char* fsh)
|
||||
{
|
||||
GLuint s,p;
|
||||
p = ((PFNGLCREATEPROGRAMPROC)wglGetProcAddress("glCreateProgram"))();
|
||||
s = ((PFNGLCREATESHADERPROC)(wglGetProcAddress("glCreateShader")))(GL_VERTEX_SHADER);
|
||||
((PFNGLSHADERSOURCEPROC)wglGetProcAddress("glShaderSource")) (s, 1, &vsh, NULL);
|
||||
((PFNGLCOMPILESHADERPROC)wglGetProcAddress("glCompileShader"))(s);
|
||||
((PFNGLATTACHSHADERPROC)wglGetProcAddress("glAttachShader")) (p,s);
|
||||
s = ((PFNGLCREATESHADERPROC)wglGetProcAddress("glCreateShader"))(GL_FRAGMENT_SHADER);
|
||||
((PFNGLSHADERSOURCEPROC)wglGetProcAddress("glShaderSource")) (s, 1, &fsh, NULL);
|
||||
((PFNGLCOMPILESHADERPROC)wglGetProcAddress("glCompileShader"))(s);
|
||||
((PFNGLATTACHSHADERPROC)wglGetProcAddress("glAttachShader")) (p,s);
|
||||
((PFNGLLINKPROGRAMPROC)wglGetProcAddress("glLinkProgram"))(p);
|
||||
((PFNGLUSEPROGRAMPROC)wglGetProcAddress("glUseProgram"))(p);
|
||||
return p;
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
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;
|
||||
}
|
||||
#endif
|
||||
|
||||
#pragma code_seg(".main")
|
||||
void _cdecl main()
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
//ChangeDisplaySettings (&dmScreenSettings,CDS_FULLSCREEN);
|
||||
//HDC hDC = GetDC(CreateWindow("edit", 0, WS_POPUP | WS_VISIBLE | WS_MAXIMIZE, 0, 0, 0, 0, 0, 0, 0, 0));
|
||||
HDC hDC = GetDC(CreateWindow("static", "Test", WS_EX_APPWINDOW | WS_VISIBLE | WS_SYSMENU, 0, 0, gi_ScreenWidth, gi_ScreenHeight, 0, 0, 0, 0));
|
||||
SetPixelFormat(hDC, ChoosePixelFormat(hDC, &pfd), &pfd);
|
||||
wglMakeCurrent(hDC, wglCreateContext(hDC));
|
||||
initShaders();
|
||||
gh_ShaderCompileEvent = ::CreateEvent(NULL, FALSE, FALSE, TEXT("WriteEvent"));
|
||||
SetThreadPriority((HANDLE)CreateThread(0, 0, &filemon, 0, 0, 0), THREAD_PRIORITY_BELOW_NORMAL);
|
||||
::Sleep(1000);
|
||||
|
||||
#else
|
||||
ChangeDisplaySettings (&dmScreenSettings,CDS_FULLSCREEN);
|
||||
HDC hDC = GetDC(CreateWindow("edit", 0, WS_POPUP | WS_VISIBLE | WS_MAXIMIZE, 0, 0, 0, 0, 0, 0, 0, 0));
|
||||
//HDC hDC = GetDC(CreateWindow("static", "Test", WS_EX_APPWINDOW | WS_VISIBLE | WS_SYSMENU, 0, 0, gi_ScreenWidth, gi_ScreenHeight, 0, 0, 0, 0));
|
||||
SetPixelFormat(hDC, ChoosePixelFormat(hDC, &pfd), &pfd);
|
||||
wglMakeCurrent(hDC, wglCreateContext(hDC));
|
||||
compileShader(vsh, fsh);
|
||||
#endif
|
||||
|
||||
#ifdef _DEBUG
|
||||
if (::WaitForSingleObject(gh_ShaderCompileEvent, 0) == WAIT_OBJECT_0)
|
||||
{
|
||||
::Sleep(250);
|
||||
gi_ShaderProgram = createProgram(createVertexShader(gs_VertexShader), createFragmentShader(gs_ShaderFile));
|
||||
|
||||
((PFNGLUSEPROGRAMPROC)wglGetProcAddress("glUseProgram"))(gi_ShaderProgram);
|
||||
PrintErrors();
|
||||
}
|
||||
glColor4f(0,0,0, float(gi_ScreenWidth)/gi_ScreenHeight);
|
||||
glRectf(-1, -1, 1, 1);
|
||||
SwapBuffers(hDC);
|
||||
#endif
|
||||
|
||||
InitSound();
|
||||
ShowCursor(FALSE);
|
||||
|
||||
loop:
|
||||
|
||||
#ifdef _DEBUG
|
||||
if (::WaitForSingleObject(gh_ShaderCompileEvent, 0) == WAIT_OBJECT_0)
|
||||
{
|
||||
::Sleep(250);
|
||||
gi_ShaderProgram = createProgram(createVertexShader(gs_VertexShader), createFragmentShader(gs_ShaderFile));
|
||||
|
||||
((PFNGLUSEPROGRAMPROC)wglGetProcAddress("glUseProgram"))(gi_ShaderProgram);
|
||||
PrintErrors();
|
||||
}
|
||||
#endif
|
||||
|
||||
float lf_Time = get_Time() * 71.0f / 240.0f;
|
||||
glLoadIdentity();
|
||||
glRotatef(-90.0f * lf_Time - 90.0f, 0, 1, 0);
|
||||
glColor4f(get_Envelope(7), lf_Time, get_Envelope(2), gf_AspectRatio);
|
||||
glRects(-1, -1, 1, 1);
|
||||
SwapBuffers(hDC);
|
||||
if (!GetAsyncKeyState(VK_ESCAPE) && lf_Time < 30.0f) goto loop;
|
||||
ExitProcess(0);
|
||||
}
|
||||
462
bp4k/party_pack/src/mark.fs
Normal file
462
bp4k/party_pack/src/mark.fs
Normal file
@@ -0,0 +1,462 @@
|
||||
// Parameters from our host
|
||||
// x: Noise intensity
|
||||
// y: #sceneid.#scenetime (float)
|
||||
// z: Snare drum intensity (amiga ball radius gain)
|
||||
// w: Aspect ratio
|
||||
varying vec4 Y;
|
||||
|
||||
// Position of the fragment
|
||||
varying vec2 Z;
|
||||
|
||||
// Forward declarations
|
||||
vec4 traceRay(vec3, vec3, int);
|
||||
vec3 shade(vec4, vec3, vec3);
|
||||
|
||||
|
||||
// All data of our world
|
||||
vec3 spherePos, lightDir, lightColor, waterColor, ro, rd, interlacing;
|
||||
float sphereRadius, gf_DetailLevel, pi, eps, bigeps;
|
||||
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
||||
// 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,0)),rnd(x+vec2(1,0)), u.x),
|
||||
mix(rnd(x+vec2(0,1)),rnd(x+vec2(1,1)), u.x), u.y);
|
||||
}
|
||||
|
||||
|
||||
// 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)
|
||||
{
|
||||
float a = (
|
||||
norm(sin(pi * 2 * (u + v + Y.y*t))) +
|
||||
norm(sin(pi * (v - u - Y.y*t))) +
|
||||
norm(sin(pi * (v + Y.y*t))) +
|
||||
norm(sin(pi * 3 * (u - Y.y*t)))) * 0.3;
|
||||
return pow(a, 2.0);
|
||||
}
|
||||
|
||||
|
||||
// Calculate our TV effects (interlacing, RGB mask and film grain)
|
||||
vec3 pp(vec3 color)
|
||||
{
|
||||
int c = int(mod(gl_FragCoord.x, 3.0));
|
||||
if (c==0) color *= interlacing.xyz;
|
||||
if (c==1) color *= interlacing.yzx;
|
||||
if (c==2) color *= interlacing.zxy;
|
||||
return mix(color, vec3(norm(smoothrnd(Z * 333 + rnd(vec2(Y.y)) * 33333))), Y.x * 0.3 + 0.03);
|
||||
}
|
||||
|
||||
|
||||
// Our fake godray effect (bad if moving fast, but awesome any other time)
|
||||
vec3 godrays(vec3 color)
|
||||
{
|
||||
vec2 dpos = Z*2-1;
|
||||
float g = dpos.x * (dpos.y + 3);
|
||||
return color + lightColor *
|
||||
caustic(g + 50 * ro.x, g + 50 * ro.z, 1.5) *
|
||||
(norm(dpos.y)) * min(-ro.y * 30, 0.3);
|
||||
}
|
||||
|
||||
|
||||
// Our heightmap calculation function, we could use some perlin noise here if it wouldn't be so performance killing
|
||||
float height(vec2 x)
|
||||
{
|
||||
return (-0.035 + pow((caustic(x.x * 10, x.y * 10, 0.0) * 2 - 1), 2.0) * 0.05)
|
||||
- (x.x - 0.1) * 0.2; // This line creates one entire continent and a big ocean!
|
||||
}
|
||||
|
||||
|
||||
// Gets the terrain normal
|
||||
vec3 getTerrainNormal(vec3 p)
|
||||
{
|
||||
return normalize(vec3(
|
||||
height(p.xz - vec2(bigeps, 0)) - height(p.xz + vec2(bigeps, 0)),
|
||||
2 * bigeps,
|
||||
height(p.xz - vec2(0, bigeps)) - height(p.xz + vec2(0, bigeps))));
|
||||
}
|
||||
|
||||
|
||||
// Global diffuse lighting formula
|
||||
vec3 diffuseLight(vec3 incolor, vec3 normal)
|
||||
{
|
||||
return (0.3 + 0.7 * max(dot(normal, lightDir), 0.0)) * lightColor * incolor;
|
||||
}
|
||||
|
||||
|
||||
// Calculates the water "waves". To reduce the bumpiness, increment the y-axis
|
||||
vec3 getWaterNormal(vec3 p)
|
||||
{
|
||||
return normalize(vec3(
|
||||
caustic(p.x * 160 - cos(p.z * 10) * 12, p.z * 140, 4.0),
|
||||
8,
|
||||
caustic(p.z * 160 - sin(p.x * 10) * 12, p.x * 140, 4.0)) * 2 - 1);
|
||||
}
|
||||
|
||||
|
||||
// Calculate the terrain color for the given voxel
|
||||
vec3 shadeTerrain(vec3 p, vec3 rd)
|
||||
{
|
||||
vec3 n = getTerrainNormal(p);
|
||||
vec3 color = mix(
|
||||
// sandy color
|
||||
vec3(0.66, 0.55, 0.4)
|
||||
|
||||
// basic color (big random color spots)
|
||||
- 0.2 * smoothrnd(abs(p.xz * 150))
|
||||
|
||||
// texture (sediment lines)
|
||||
- 0.2 * smoothrnd(abs(p.yy + 0.002 * smoothrnd(abs(p.xz * 150))) * 3000),
|
||||
|
||||
// interleaved grass, hight dependant
|
||||
vec3(0.1, 0.3, 0) * (smoothrnd(p.xz * 7000.0) * 0.4 + 0.5),
|
||||
|
||||
// mixing for the sand/grass transition
|
||||
clamp(n.y * (caustic(p.x * 111, p.z * 111, 0.0) * 0.5 - p.y * 40), 0.0, 1.0));
|
||||
|
||||
// caustics, only underwater (no cloudshadows, though)
|
||||
if (p.y <= 0)
|
||||
color += 5 * getWaterNormal(0.8 * p).x * min(0.3, -p.y * 8);
|
||||
|
||||
// Light
|
||||
return diffuseLight(color, n);
|
||||
}
|
||||
|
||||
|
||||
// Create a blueish sky transition from navy blue to badass dark blue
|
||||
vec3 shadeSky(vec3 ro, vec3 rd)
|
||||
{
|
||||
return ro.y <= -eps*eps ?
|
||||
waterColor :
|
||||
mix(vec3(-0.5, -0.25, 0), vec3(2), 1 - (rd.y * 0.5 + 0.5));
|
||||
}
|
||||
|
||||
|
||||
// Calculates the refraction and reflection of the water surface.
|
||||
// Also mixes both values by the depth of the water and the fresnel term.
|
||||
// Possible improvements: fix fake underwater reflection and refraction
|
||||
vec3 shadeWaterRefl(vec3 p, vec3 newrd)
|
||||
{
|
||||
vec3 waterNormal = getWaterNormal(p);
|
||||
|
||||
// perform raytracing/raymarching for both reflection and refraction
|
||||
// calc the water refraction, the refraction index (0.9) will decrease with the distance to allow a better over/under water transition
|
||||
vec4 refracted = traceRay(p, refract(newrd, waterNormal, 0.9), 2);//mix(0.9, 1.0, smoothstep(0.01, 0.0, length(p-ro)))), 2);
|
||||
|
||||
// calculate the depth factor (water entry point to terrain voxel) (black magic involved here!)
|
||||
float depth = clamp(pow(1.03 * (1 - length(refracted.xyz - p)), 16.0), 0.0, 1.0);
|
||||
|
||||
// Finally stir the pot =)
|
||||
return mix(
|
||||
ro.y < 0 ? shadeSky(p, newrd) : waterColor, // Water color
|
||||
mix(
|
||||
shade(traceRay(p, reflect(newrd, waterNormal), 2), p, newrd), // Reflection color
|
||||
shade(refracted, p, newrd), // Refraction color
|
||||
clamp(-rd.y + depth, 0.0, 1.0)), // fresnel term
|
||||
refracted.w == 3.0 ? 0.5 : pow(depth, 0.5)); // water color contribution
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Texture our "AMIGAAAAAAA!!" ball
|
||||
vec3 shadeAttractor(vec3 p, vec3 rd)
|
||||
{
|
||||
vec3 n,color;
|
||||
|
||||
// get the sphere normal, first
|
||||
n = normalize(p - spherePos);
|
||||
|
||||
// now calculate the texture coordinates
|
||||
vec2 uv = 0.5 + 0.5 * vec2(atan(n.z, n.x), acos(n.y)) / pi;
|
||||
|
||||
// We'll animate our x-texture coordinate with the time, this gives the impression of a rotating ball
|
||||
uv.x -= Y.y;
|
||||
|
||||
// This spell will convert any dull ball into an amiga ball, caution is advised.
|
||||
color = mix(vec3(1), vec3(1, 0, 0), mod(step(fract(uv.x * 6), 0.5) + step(fract(uv.y * 6), 0.5), 2.0));
|
||||
|
||||
return diffuseLight(color, n)
|
||||
+ pow(max(dot(n, normalize(lightDir - rd)), 0.0), 33.0) * lightColor; // specular light spot
|
||||
}
|
||||
|
||||
|
||||
// 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
|
||||
float traceTerrain(vec3 ro, vec3 rd, float maxt)
|
||||
{
|
||||
float delt, lh, ly, samplePosY;
|
||||
delt = 0; // If the world would consist of only nVidia GPUs, this line wouldn't exist.
|
||||
vec3 samplePos = ro;
|
||||
|
||||
// advance our sample position from our nearplane to our farplane
|
||||
for (float t = 0; t < maxt; t += delt)
|
||||
{
|
||||
// advance our ray
|
||||
samplePos += rd * delt;
|
||||
samplePosY = samplePos.y;
|
||||
|
||||
// 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)
|
||||
float h = height(samplePos.xz);
|
||||
|
||||
if (samplePosY <= h)
|
||||
{
|
||||
// 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)
|
||||
return t - delt + delt*(lh-ly)/(samplePosY-h+lh-ly);
|
||||
}
|
||||
|
||||
// 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 = h;
|
||||
ly = samplePosY;
|
||||
|
||||
// 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/gf_DetailLevel);
|
||||
}
|
||||
|
||||
// we hit nothing
|
||||
return 9.0;
|
||||
}
|
||||
|
||||
|
||||
// Ray vs. sphere intersection function
|
||||
float traceAttractor(vec3 ro, vec3 rd)
|
||||
{
|
||||
vec3 dst = ro - spherePos;
|
||||
float B,D;
|
||||
B = dot(dst, rd);
|
||||
if (B > 0)
|
||||
return 9.0;
|
||||
D = B*B - dot(dst, dst) + sphereRadius*sphereRadius;
|
||||
if (D > 0)
|
||||
{
|
||||
return -B - sqrt(D);
|
||||
}
|
||||
return 9.0;
|
||||
}
|
||||
|
||||
|
||||
// Ray vs. plane intersection function
|
||||
float traceWater(vec3 ro, vec3 rd)
|
||||
{
|
||||
float tPlane = -ro.y / rd.y;
|
||||
return tPlane >= eps ? tPlane : 9.0;
|
||||
}
|
||||
|
||||
|
||||
// Raytracing entry point, returns voxel and object ID
|
||||
// IDs:
|
||||
// 0 = sky (not the armageddon, xTr1m!!)
|
||||
// 1 = terrain
|
||||
// 2 = water
|
||||
// 3 = attractive amiga ball (you have never seen such a sexy amiga ball before, admit it!)
|
||||
vec4 traceRay(vec3 ro, vec3 rd, int ignore)
|
||||
{
|
||||
float water, attractor, terrain, minDist;
|
||||
|
||||
// trace only the objects we need (only one could maximally be ignored)
|
||||
water = ignore != 2 ? traceWater(ro, rd) : 9.0;
|
||||
attractor = ignore != 3 ? traceAttractor(ro, rd) : 9.0;
|
||||
terrain = ignore != 1 ? traceTerrain(ro, rd, min(0.5, 0.002+min(water, attractor))) : 9.0;
|
||||
|
||||
// auto detail level reducing (common dude, give the GPU some breathing room)
|
||||
gf_DetailLevel /= 20;
|
||||
|
||||
// find the nearest distance
|
||||
minDist = min(terrain, min(water, min(attractor, 9.0)));
|
||||
|
||||
// we hit nothing or the hitpoint is too far
|
||||
if (minDist == 9)
|
||||
return vec4(0);
|
||||
|
||||
// calculate the hit/voxel position
|
||||
vec3 hitPos = ro + rd * minDist;
|
||||
|
||||
// check what we might have hit
|
||||
if (minDist == terrain)
|
||||
return vec4(hitPos, 1);
|
||||
if (minDist == water)
|
||||
return vec4(hitPos, 2);
|
||||
if (minDist == attractor)
|
||||
return vec4(hitPos, 3);
|
||||
|
||||
// Panic, worry, die to death! Probably we'll land on the moon (this should never happen)
|
||||
//return vec4(0);
|
||||
}
|
||||
|
||||
|
||||
// Entrypoint for color calculation
|
||||
vec3 shadeRefl(vec4 hitPoint, vec3 newRo, vec3 rd)
|
||||
{
|
||||
// determine the fog color for this very precise point in the space time continuum
|
||||
vec3 myFog = newRo.y < eps ? waterColor : shadeSky(ro, rd);
|
||||
|
||||
// generate the distance value for the fog calculation
|
||||
float distance = clamp(length(hitPoint.xyz - newRo) * (ro.y <= 0 ? 4 : 2), 0.0, 1.0);
|
||||
|
||||
// get the color of the hit object and mix it with the fog
|
||||
// in most cases we allow further raytracing here (not for the terrain, its not shiny enough)
|
||||
if (hitPoint.w == 1)
|
||||
return mix(shadeTerrain(hitPoint.xyz, rd), myFog, distance);
|
||||
if (hitPoint.w == 2)
|
||||
return mix(shadeWaterRefl(hitPoint.xyz, rd), myFog, distance);
|
||||
if (hitPoint.w == 3)
|
||||
return mix(
|
||||
// Our amiga ball is shiny so reflect the scene!
|
||||
mix(shadeAttractor(hitPoint.xyz, rd), shade(traceRay(hitPoint.xyz, reflect(rd, normalize(hitPoint.xyz - spherePos)), 3), hitPoint.xyz, rd), 0.5)
|
||||
, myFog, distance);
|
||||
|
||||
return shadeSky(newRo, rd);
|
||||
}
|
||||
|
||||
|
||||
// Get the color from the object we just hit (without further raytraces)
|
||||
// this is necessary because no recursion is allowed in GLSL (damn you!)
|
||||
vec3 shade(vec4 hitPoint, vec3 newRo, vec3 rd)
|
||||
{
|
||||
// determine the fog color for the very same point we discussed earlier
|
||||
vec3 myFog = newRo.y < eps ? waterColor : shadeSky(ro, rd);
|
||||
|
||||
// generate the other distance value. Paid attention? If you don't know what value I'm talking about, rtfm or gtfo.
|
||||
float distance = clamp(length(hitPoint.xyz - newRo) * (ro.y <= 0 ? 4 : 2), 0.0, 1.0);
|
||||
|
||||
// get the color of the hit object and mix it with the fog
|
||||
if (hitPoint.w == 1)
|
||||
return mix(shadeTerrain(hitPoint.xyz, rd), myFog, distance);
|
||||
if (hitPoint.w == 2)
|
||||
return mix(waterColor, myFog, distance);
|
||||
if (hitPoint.w == 3)
|
||||
return mix(shadeAttractor(hitPoint.xyz, rd), myFog, distance);
|
||||
|
||||
return myFog;
|
||||
}
|
||||
|
||||
|
||||
// Now we're just being copycats. We're not creative enough to define own entry points
|
||||
// Sure, we could "#define MYENTRYPOINT main"! Or just void main(){MyEntryPoint();}
|
||||
// None of that would help us win the compo, would it?
|
||||
void main()
|
||||
{
|
||||
// Set the quality setting for the raymarcher, a higher value results in a longer processing time
|
||||
// try to find a good balance between these two, low values will result in a wobbling endresult
|
||||
// low quality = 50.0 (visual results are ok at 640x480)
|
||||
// mid quality = 100.0
|
||||
// high quality = 200.0
|
||||
gf_DetailLevel = 100;
|
||||
|
||||
// Give our saviour global variables some life!
|
||||
pi = 3.1416;
|
||||
interlacing = vec3(1.2, 0.9, 0.9);
|
||||
eps = 0.0001;
|
||||
bigeps = 0.01;
|
||||
|
||||
// Nifty random number generator gets initialized
|
||||
float seed = 10;
|
||||
|
||||
// Determine the scene we're in
|
||||
int scene = int(Y.y);
|
||||
|
||||
// Get the look direction for the current pixel (always look forwards)
|
||||
rd = vec3((Z.xy - 0.5), 1);
|
||||
|
||||
// Merry-go-round on a boat (yeah, this makes no sense. Go watch the intro and see for yourself)
|
||||
if (scene > 22 && scene < 27)
|
||||
{
|
||||
seed = min(1.0, sin((Y.y-23)*pi*0.25)*12);
|
||||
ro = vec3(0.12, 0.005, Y.y*0.08);
|
||||
rd = vec3(gl_ModelViewMatrix * vec4(rd, 1));
|
||||
rd.y += 0.1*cos(Y.y*4);
|
||||
}
|
||||
// Intermezzo: Dolphin like animation inside and outside the water, chasing that amiga ball!
|
||||
else if (scene > 14 && scene < 23)
|
||||
{
|
||||
seed = min(1.0, sin((Y.y-15)*pi*0.125)*24);
|
||||
rd += vec3(0,0.1*cos(Y.y*4), 0);
|
||||
ro = vec3(0.08, 0.01*sin(Y.y*4)+0.002, Y.y*0.11);
|
||||
}
|
||||
// Intro and Outro: Show still scenes
|
||||
else
|
||||
{
|
||||
// Get a random initial position for our camera
|
||||
ro = vec3(0.1,0.004,0.0) + vec3(0.1,0.005,20)
|
||||
*vec3(rnd(vec2(scene, seed++)), rnd(vec2(scene, seed++)), rnd(vec2(scene, seed++)));
|
||||
|
||||
// Basing on the initial position, choose some "random" start and end points nearby
|
||||
ro = mix(
|
||||
ro+vec3(0.008)*vec3(rnd(vec2(scene, seed++)), rnd(vec2(scene, seed++)), rnd(vec2(scene, seed++))),
|
||||
ro+vec3(0.008)*vec3(rnd(vec2(scene, seed++)), rnd(vec2(scene, seed++)), rnd(vec2(scene, seed++))),
|
||||
// and move the camera!
|
||||
Y.y-scene);
|
||||
|
||||
// We adjust the height of the camera to the terrain height
|
||||
ro.y += height(ro.xz)+0.02;
|
||||
|
||||
// Deviate the camera position in the direction of the normal of the underlying terrain
|
||||
ro += 0.02*getTerrainNormal(ro);
|
||||
|
||||
// Reusing a float variable here, this controls the scene fade in / fade out animation
|
||||
seed = min(1.0, step(-28.0, -Y.y) * sin((Y.y-scene)*pi)*3);
|
||||
}
|
||||
|
||||
rd = normalize(rd);
|
||||
|
||||
// Now boot the amiga workbench (erm, no...)
|
||||
// mantain a relative distance to the camera
|
||||
if (scene > 22 && scene < 27)
|
||||
spherePos = ro + 0.1 * vec3(gl_ModelViewMatrix * vec4(0, 0, 1, 1));
|
||||
else
|
||||
spherePos = ro + 0.02 * vec3(sin(Y.y), 0, 5+cos(Y.y));
|
||||
|
||||
spherePos.y += 0.01 + height(spherePos.xz); // mantain a relative height to the underlying terrain
|
||||
sphereRadius = scene < 14 ? 0.0 : bigeps * 0.5 + bigeps * Y.z; // The amiga ball is bigger when the snare drum is hit!
|
||||
spherePos += 2*sphereRadius * getTerrainNormal(spherePos); // deviate according to the underlying terrain's normal
|
||||
|
||||
// Make our world pretty and worthy to live in (you can cultivate algae and eat them, they're surely enough for survival)
|
||||
lightDir = vec3(0.58, 0.58, -0.58);
|
||||
lightColor = vec3(1.2);
|
||||
waterColor = vec3(0.3, 0.33, 0.4);
|
||||
|
||||
// Our GPU feels good underwater, almost like a refreshing experience :) cool, eh?
|
||||
if (ro.y <= 0)
|
||||
{
|
||||
// Less work to do...
|
||||
gf_DetailLevel *= 0.75;
|
||||
|
||||
// ...and a cozy darker atmosphere
|
||||
lightColor *= 0.8;
|
||||
}
|
||||
|
||||
// Here we go, shoot'em rays and get the color of our fragment!
|
||||
vec3 color = shadeRefl(traceRay(ro, rd, 0), ro, rd);
|
||||
|
||||
// Underwater there are beams of light emanating from god (so called "god" rays...)
|
||||
// ...this prooves that god is nothing less than a water surface.
|
||||
if (ro.y <= 0)
|
||||
color = godrays(color);
|
||||
|
||||
// Apply post processing and fade effects to the color, and finally return it.
|
||||
gl_FragColor.xyz = pp(step(2.0, Y.y) * seed * color);
|
||||
}
|
||||
194
bp4k/party_pack/src/release.h
Normal file
194
bp4k/party_pack/src/release.h
Normal file
@@ -0,0 +1,194 @@
|
||||
// 4slang v0.1 by Blu-Flame
|
||||
// This always generated file is a compressed version of:
|
||||
// mark.fs
|
||||
#pragma once
|
||||
|
||||
#pragma data_seg(".shaders")
|
||||
static char* fsh =
|
||||
"#define ve return\n" // Line 1
|
||||
"#define ec float\n" // Line 1
|
||||
"varying vec4 Y;" // Line 6
|
||||
"varying vec2 Z;" // Line 9
|
||||
"vec4 R(vec3 n,vec3 m,int k);" // Line 12
|
||||
"vec3 T(vec4 j,vec3 l,vec3 m);" // Line 13
|
||||
"vec3 f,b,a,h,e,d,X;" // Line 17
|
||||
"ec g,W,c,V,U;ec A(vec2 j){" // Line 18
|
||||
"int i=int(j.x*40+j.y*6400);" // Line 24
|
||||
"i=(i<<13)^i;" // Line 25
|
||||
"ve 1-ec((i*(i*i*15731+789221)+1376312589)&0x7fffffff)/1073741824;}ec B(vec2 k){" // Line 26
|
||||
"k=mod(k,1000.);" // Line 33
|
||||
"vec2 i=fract(k);" // Line 34
|
||||
"k-=i;" // Line 35
|
||||
"vec2 j=i*i*(3.-2.*i);" // Line 36
|
||||
"ve mix(" // Line 37
|
||||
"mix(A(k+vec2(0,0)),A(k+vec2(1,0)),j.x)," // Line 38
|
||||
"mix(A(k+vec2(0,1)),A(k+vec2(1,1)),j.x),j.y);}ec C(ec i){" // Line 39
|
||||
"ve i*.5+.5;}ec D(ec k,ec l,ec j){" // Line 46
|
||||
"ec i=(" // Line 53
|
||||
"C(sin(c*2*(k+l+Y.y*j)))+" // Line 54
|
||||
"C(sin(c*(l-k-Y.y*j)))+" // Line 55
|
||||
"C(sin(c*(l+Y.y*j)))+" // Line 56
|
||||
"C(sin(c*3*(k-Y.y*j))))*.3;" // Line 57
|
||||
"ve pow(i,2.);}vec3 E(vec3 j){" // Line 58
|
||||
"int i=int(mod(gl_FragCoord.x,3.));" // Line 65
|
||||
"if(i==0)j*=X.xyz;" // Line 66
|
||||
"if(i==1)j*=X.yzx;" // Line 67
|
||||
"if(i==2)j*=X.zxy;" // Line 68
|
||||
"ve mix(j,vec3(C(B(Z*333+A(vec2(Y.y))*33333))),Y.x*.3+.03);}vec3 F(vec3 i){" // Line 69
|
||||
"vec2 j=Z*2-1;" // Line 76
|
||||
"ec k=j.x*(j.y+3);" // Line 77
|
||||
"ve i+a*" // Line 78
|
||||
"D(k+50*e.x,k+50*e.z,1.5)*" // Line 79
|
||||
"(C(j.y))*min(-e.y*30,.3);}ec G(vec2 i){" // Line 80
|
||||
"ve (-.035+pow((D(i.x*10,i.y*10,.0)*2-1),2.)*.05)" // Line 87
|
||||
"-(i.x-.1)*.2;}vec3 H(vec3 i){" // Line 88
|
||||
"ve normalize(vec3(" // Line 95
|
||||
"G(i.xz-vec2(U,0))-G(i.xz+vec2(U,0))," // Line 96
|
||||
"2*U," // Line 97
|
||||
"G(i.xz-vec2(0,U))-G(i.xz+vec2(0,U))));}vec3 I(vec3 i,vec3 j){" // Line 98
|
||||
"ve (.3+.7*max(dot(j,b),.0))*a*i;}vec3 J(vec3 i){" // Line 105
|
||||
"ve normalize(vec3(" // Line 112
|
||||
"D(i.x*160-cos(i.z*10)*12,i.z*140,4.)," // Line 113
|
||||
"8," // Line 114
|
||||
"D(i.z*160-sin(i.x*10)*12,i.x*140,4.))*2-1);}vec3 K(vec3 k,vec3 l){" // Line 115
|
||||
"vec3 j=H(k);" // Line 122
|
||||
"vec3 i=mix(" // Line 123
|
||||
"vec3(.66,.55,.4)" // Line 125
|
||||
"-.2*B(abs(k.xz*150))" // Line 128
|
||||
"-.2*B(abs(k.yy+.002*B(abs(k.xz*150)))*3000)," // Line 131
|
||||
"vec3(.1,.3,0)*(B(k.xz*7000.)*.4+.5)," // Line 134
|
||||
"clamp(j.y*(D(k.x*111,k.z*111,.0)*.5-k.y*40),.0,1.));" // Line 137
|
||||
"if(k.y<=0)" // Line 140
|
||||
"i+=5*J(.8*k).x*min(.3,-k.y*8);" // Line 141
|
||||
"ve I(i,j);}vec3 L(vec3 j,vec3 i){" // Line 144
|
||||
"ve j.y<=-V*V?" // Line 151
|
||||
"h:" // Line 152
|
||||
"mix(vec3(-.5,-.25,0),vec3(2),1-(i.y*.5+.5));}vec3 M(vec3 k,vec3 j){" // Line 153
|
||||
"vec3 m=J(k);" // Line 162
|
||||
"vec4 l=R(k,refract(j,m,.9),2);" // Line 166
|
||||
"ec i=clamp(pow(1.03*(1-length(l.xyz-k)),16.),.0,1.);" // Line 169
|
||||
"ve mix(" // Line 172
|
||||
"e.y<0?L(k,j):h," // Line 173
|
||||
"mix(" // Line 174
|
||||
"T(R(k,reflect(j,m),2),k,j)," // Line 175
|
||||
"T(l,k,j)," // Line 176
|
||||
"clamp(-d.y+i,.0,1.))," // Line 177
|
||||
"l.w==3.?.5:pow(i,.5));}vec3 N(vec3 k,vec3 l){" // Line 178
|
||||
"vec3 j,i;" // Line 186
|
||||
"j=normalize(k-f);" // Line 189
|
||||
"vec2 m=.5+.5*vec2(atan(j.z,j.x),acos(j.y))/c;" // Line 192
|
||||
"m.x-=Y.y;" // Line 195
|
||||
"i=mix(vec3(1),vec3(1,0,0),mod(step(fract(m.x*6),.5)+step(fract(m.y*6),.5),2.));" // Line 198
|
||||
"ve I(i,j)" // Line 200
|
||||
"+pow(max(dot(j,normalize(b-l)),.0),33.)*a;}ec O(vec3 n,vec3 m,ec l){" // Line 201
|
||||
"ec i,j,k,p;" // Line 209
|
||||
"i=0;" // Line 210
|
||||
"vec3 o=n;" // Line 211
|
||||
"for(ec q=0;q<l;q+=i)" // Line 214
|
||||
"{" // Line 215
|
||||
"o+=m*i;" // Line 217
|
||||
"p=o.y;" // Line 218
|
||||
"ec r=G(o.xz);" // Line 221
|
||||
"if(p<=r)" // Line 223
|
||||
"{" // Line 224
|
||||
"ve q-i+i*(j-k)/(p-r+j-k);}" // Line 227
|
||||
"j=r;" // Line 232
|
||||
"k=p;" // Line 233
|
||||
"i=.002+(q/W);}" // Line 237
|
||||
"ve 9.;}ec P(vec3 m,vec3 l){" // Line 241
|
||||
"vec3 k=m-f;" // Line 248
|
||||
"ec i,j;" // Line 249
|
||||
"i=dot(k,l);" // Line 250
|
||||
"if(i>0)" // Line 251
|
||||
"ve 9.;" // Line 252
|
||||
"j=i*i-dot(k,k)+g*g;" // Line 253
|
||||
"if(j>0)" // Line 254
|
||||
"{" // Line 255
|
||||
"ve -i-sqrt(j);}" // Line 256
|
||||
"ve 9.;}ec Q(vec3 j,vec3 i){" // Line 258
|
||||
"ec k=-j.y/i.y;" // Line 265
|
||||
"ve k>=V?k:9.;}vec4 R(vec3 n,vec3 m,int k){" // Line 266
|
||||
"ec p,i,o,l;" // Line 278
|
||||
"p=k!=2?Q(n,m):9.;" // Line 281
|
||||
"i=k!=3?P(n,m):9.;" // Line 282
|
||||
"o=k!=1?O(n,m,min(.5,.002+min(p,i))):9.;" // Line 283
|
||||
"W/=20;" // Line 286
|
||||
"l=min(o,min(p,min(i,9.)));" // Line 289
|
||||
"if(l==9)" // Line 292
|
||||
"ve vec4(0);" // Line 293
|
||||
"vec3 j=n+m*l;" // Line 296
|
||||
"if(l==o)" // Line 299
|
||||
"ve vec4(j,1);" // Line 300
|
||||
"if(l==p)" // Line 301
|
||||
"ve vec4(j,2);" // Line 302
|
||||
"if(l==i)" // Line 303
|
||||
"ve vec4(j,3);}vec3 S(vec4 j,vec3 l,vec3 m){" // Line 304
|
||||
"vec3 k=l.y<V?h:L(e,m);" // Line 315
|
||||
"ec i=clamp(length(j.xyz-l)*(e.y<=0?4:2),.0,1.);" // Line 318
|
||||
"if(j.w==1)" // Line 322
|
||||
"ve mix(K(j.xyz,m),k,i);" // Line 323
|
||||
"if(j.w==2)" // Line 324
|
||||
"ve mix(M(j.xyz,m),k,i);" // Line 325
|
||||
"if(j.w==3)" // Line 326
|
||||
"ve mix(" // Line 327
|
||||
"mix(N(j.xyz,m),T(R(j.xyz,reflect(m,normalize(j.xyz-f)),3),j.xyz,m),.5)" // Line 329
|
||||
",k,i);" // Line 330
|
||||
"ve L(l,m);}vec3 T(vec4 j,vec3 l,vec3 m){" // Line 332
|
||||
"vec3 k=l.y<V?h:L(e,m);" // Line 341
|
||||
"ec i=clamp(length(j.xyz-l)*(e.y<=0?4:2),.0,1.);" // Line 344
|
||||
"if(j.w==1)" // Line 347
|
||||
"ve mix(K(j.xyz,m),k,i);" // Line 348
|
||||
"if(j.w==2)" // Line 349
|
||||
"ve mix(h,k,i);" // Line 350
|
||||
"if(j.w==3)" // Line 351
|
||||
"ve mix(N(j.xyz,m),k,i);" // Line 352
|
||||
"ve k;}void main(){" // Line 354
|
||||
"W=100;" // Line 368
|
||||
"c=3.1416;" // Line 371
|
||||
"X=vec3(1.2,.9,.9);" // Line 372
|
||||
"V=.0001;" // Line 373
|
||||
"U=.01;" // Line 374
|
||||
"ec k=10;" // Line 377
|
||||
"int j=int(Y.y);" // Line 380
|
||||
"d=vec3((Z.xy-.5),1);" // Line 383
|
||||
"if(j>22&&j<27)" // Line 386
|
||||
"{" // Line 387
|
||||
"k=min(1.,sin((Y.y-23)*c*.25)*12);" // Line 388
|
||||
"e=vec3(.12,.005,Y.y*.08);" // Line 389
|
||||
"d=vec3(gl_ModelViewMatrix*vec4(d,1));" // Line 390
|
||||
"d.y+=.1*cos(Y.y*4);}" // Line 391
|
||||
"else if(j>14&&j<23)" // Line 394
|
||||
"{" // Line 395
|
||||
"k=min(1.,sin((Y.y-15)*c*.125)*24);" // Line 396
|
||||
"d+=vec3(0,.1*cos(Y.y*4),0);" // Line 397
|
||||
"e=vec3(.08,.01*sin(Y.y*4)+.002,Y.y*.11);}" // Line 398
|
||||
"else " // Line 402
|
||||
"{" // Line 403
|
||||
"e=vec3(.1,.004,.0)+vec3(.1,.005,20)" // Line 405
|
||||
"*vec3(A(vec2(j,k++)),A(vec2(j,k++)),A(vec2(j,k++)));" // Line 406
|
||||
"e=mix(" // Line 409
|
||||
"e+vec3(.008)*vec3(A(vec2(j,k++)),A(vec2(j,k++)),A(vec2(j,k++)))," // Line 410
|
||||
"e+vec3(.008)*vec3(A(vec2(j,k++)),A(vec2(j,k++)),A(vec2(j,k++)))," // Line 411
|
||||
"Y.y-j);" // Line 413
|
||||
"e.y+=G(e.xz)+.02;" // Line 416
|
||||
"e+=.02*H(e);" // Line 419
|
||||
"k=min(1.,step(-28.,-Y.y)*sin((Y.y-j)*c)*3);}" // Line 422
|
||||
"d=normalize(d);" // Line 425
|
||||
"if(j>22&&j<27)" // Line 429
|
||||
"f=e+.1*vec3(gl_ModelViewMatrix*vec4(0,0,1,1));" // Line 430
|
||||
"else " // Line 432
|
||||
"f=e+.02*vec3(sin(Y.y),0,5+cos(Y.y));" // Line 433
|
||||
"f.y+=.01+G(f.xz);" // Line 435
|
||||
"g=j<14?.0:U*.5+U*Y.z;" // Line 436
|
||||
"f+=2*g*H(f);" // Line 437
|
||||
"b=vec3(.58,.58,-.58);" // Line 440
|
||||
"a=vec3(1.2);" // Line 441
|
||||
"h=vec3(.3,.33,.4);" // Line 442
|
||||
"if(e.y<=0)" // Line 445
|
||||
"{" // Line 446
|
||||
"W*=.75;" // Line 448
|
||||
"a*=.8;}" // Line 451
|
||||
"vec3 i=S(R(e,d,0),e,d);" // Line 455
|
||||
"if(e.y<=0)" // Line 459
|
||||
"i=F(i);" // Line 460
|
||||
"gl_FragColor.xyz=E(step(2.,Y.y)*k*i);}";
|
||||
127
bp4k/party_pack/src/small.h
Normal file
127
bp4k/party_pack/src/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")
|
||||
|
||||
__forceinline 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 size_t x_Strlen(const char* as_String)
|
||||
{
|
||||
size_t 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;
|
||||
}
|
||||
87
bp4k/party_pack/src/synth.cpp
Normal file
87
bp4k/party_pack/src/synth.cpp
Normal file
@@ -0,0 +1,87 @@
|
||||
// Using 4klang by gopher/alcatraz
|
||||
// The very best synth for 4ks!
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_EXTRA_LEAN
|
||||
#include "windows.h"
|
||||
#include "mmsystem.h"
|
||||
#include "mmreg.h"
|
||||
|
||||
#define USE_SOUND_THREAD
|
||||
#define SAMPLE_RATE 44100
|
||||
#define MAX_SAMPLES SAMPLE_RATE*2*60*20
|
||||
|
||||
#pragma bss_seg(".synthnothing")
|
||||
static float lpSoundBuffer[MAX_SAMPLES];
|
||||
static HWAVEOUT hWaveOut;
|
||||
|
||||
#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
|
||||
};
|
||||
|
||||
|
||||
extern "C" void _4klang_render(float*);
|
||||
extern "C" float _4klang_envelope_buffer;
|
||||
|
||||
#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(".envelope")
|
||||
extern "C" float get_Envelope(int instrument)
|
||||
{
|
||||
return (&_4klang_envelope_buffer)[((MMTime.u.sample >> 8) << 5) + 2*instrument];
|
||||
}
|
||||
|
||||
#pragma code_seg(".time")
|
||||
extern "C" float get_Time()
|
||||
{
|
||||
waveOutGetPosition(hWaveOut, &MMTime, sizeof(MMTIME));
|
||||
return float(MMTime.u.sample) / SAMPLE_RATE;
|
||||
}
|
||||
8
bp4k/party_pack/src/synth.h
Normal file
8
bp4k/party_pack/src/synth.h
Normal file
@@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
extern "C"
|
||||
{
|
||||
void InitSound();
|
||||
float get_Envelope(int instrument);
|
||||
float get_Time();
|
||||
}
|
||||
47
bp4k/party_pack/valleyball.nfo
Normal file
47
bp4k/party_pack/valleyball.nfo
Normal file
@@ -0,0 +1,47 @@
|
||||
____ __ _____ __ ________
|
||||
/ _ \ / / / ___/ / / / ______/
|
||||
/ /_\ _\ / / __ __ / /__ / / _______ ________ / /_____
|
||||
/ ___ \ / / / / / / / ___/ / / / ___ / / __ __ | /_ ____/
|
||||
/ /___\ \ / / / /_/ / / / / / / /_ / / / / / / / / / /___
|
||||
/__________| /_/ /_____/ |_| /_/ /___//_/ /_/ /_/ /_/ /_____/
|
||||
|
||||
|========================== http://www.blu-flame.org =========================|
|
||||
.
|
||||
·:
|
||||
. ·:·
|
||||
·:· ·:·
|
||||
:·: :·: ==---=<<( blu-flame.org )>>==---==
|
||||
:·: ·:·: \ P R E S E N T S /
|
||||
:·:· ·:·:· <|=<(||||||||||||||||||||||)>=|>
|
||||
:·:· :·:· |/| |/|
|
||||
:·:· ·:·:· / / Valleyball / /
|
||||
·:·:· ·:·:· |/| a 4k PC-Intro for |/|
|
||||
:·:· · ·:·:· / / Breakpoint 09 / /
|
||||
:·:·: : :·:·:· |/| |/|
|
||||
:·:·: :·: :·:·: / / Setting new benchmark / /
|
||||
:·:·: :·:· ·:·:· |/| standards for today's |/|
|
||||
:·:· ·:·: :·:· / / GPUs! This intro only / /
|
||||
·:· ·:· ·:· |/| renders 2 triangles, |/|
|
||||
·:·:·:·:· / / everything is done in / /
|
||||
|\\·:·:·:·//| |/| a shader. Requires a |/|
|
||||
|\\-------//| / / Shader Model 4.0 capa- / /
|
||||
| _ _ _ | |/| ble GPU of the latest |/|
|
||||
| |_||_||_| | / / generation. Mid/Lowend / /
|
||||
| _ _ _ | |/| GPUs should run the lo |/|
|
||||
| |_||_||_| | / / res version (640x480). / /
|
||||
| _ _ _ | |/| Techniques used: ray- |/|
|
||||
| |_||_||_| | / / marching and raytra- / /
|
||||
| . | |/| cing. Enjoy! |/|
|
||||
:.:.://____|||____\\:.:/ /:.:.:.:.:.:.:.:.:.:.:.:./ /:.:.:.
|
||||
xTr1m / Hel / raYn / PC-4k Compo / Breakpoint 2009 / Bingen
|
||||
|
||||
__
|
||||
__ / \
|
||||
/ \___________________________________| |
|
||||
| : greets: 3ye, ace, bero, chaos, | |
|
||||
| : cyraxx, iq, jco, kb, las, m0d, | |
|
||||
| : manx, ryg, scamp, SoDa7, starly, | _ |
|
||||
| _: tomb, wayfinder, xxx. |_/\|
|
||||
| /\\_____________________________________/
|
||||
\_/ xTr1m
|
||||
|
||||
Reference in New Issue
Block a user