pientä fixailua
This commit is contained in:
64
src/main.cpp
64
src/main.cpp
@ -270,8 +270,8 @@ int __cdecl main(int argc, char* argv[])
|
|||||||
for (int i = 0; i < (FFT_SIZE / 4); i++)
|
for (int i = 0; i < (FFT_SIZE / 4); i++)
|
||||||
{
|
{
|
||||||
float gain = 50.0f;
|
float gain = 50.0f;
|
||||||
float alpha = 0.10f; // "Hidastaa" FFT:n piikkej<65>
|
float alpha = 0.10f; // "Hidastaa" FFT:n piikkej<65>
|
||||||
float threshhold = 0.05f; // Alin arvo mik<69> p<><70>stet<65><74>n shaderille (v<>hent<6E><74> "noisea")
|
float threshhold = 0.05f; // Alin arvo mik<69> p<><70>stet<65><74>n shaderille (v<>hent<6E><74> "noisea")
|
||||||
float x_t = fft_output[i] * gain;
|
float x_t = fft_output[i] * gain;
|
||||||
// Exponential smoothing kaava
|
// Exponential smoothing kaava
|
||||||
// s(t) = alpha*x(t)+(1-alpha)*s(t-1)
|
// s(t) = alpha*x(t)+(1-alpha)*s(t-1)
|
||||||
@ -301,12 +301,12 @@ int __cdecl main(int argc, char* argv[])
|
|||||||
bool shapeJustStarted = false;
|
bool shapeJustStarted = false;
|
||||||
|
|
||||||
// Detect note change to start a new shape
|
// Detect note change to start a new shape
|
||||||
bool noteChanged = (captureSync - lastNote) * (captureSync - lastNote) > 0.0001f;
|
bool noteChanged = (captureSync != lastNote) ? TRUE : FALSE;
|
||||||
lastNote = captureSync;
|
lastNote = captureSync;
|
||||||
|
|
||||||
|
|
||||||
// If note changed and value is significant, start new shape
|
// If note changed and value is significant, start new shape
|
||||||
if (captureSync > 0.001f && noteChanged) {
|
if (noteChanged) {
|
||||||
int index = currentShape * 4;
|
int index = currentShape * 4;
|
||||||
|
|
||||||
// Reset and activate current shape
|
// Reset and activate current shape
|
||||||
@ -345,10 +345,10 @@ int __cdecl main(int argc, char* argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Bind and update u_ShapesTex
|
// Bind and update u_ShapesTex
|
||||||
glActiveTexture(GL_TEXTURE0 + 2);
|
glUniform1i(glGetUniformLocation(pidMain, "u_ShapesTex"), 0);
|
||||||
|
glActiveTexture(GL_TEXTURE0 + 0);
|
||||||
glBindTexture(GL_TEXTURE_2D, ShapesTex);
|
glBindTexture(GL_TEXTURE_2D, ShapesTex);
|
||||||
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, SHAPES, SHAPES, GL_RGBA, GL_FLOAT, shapesData);
|
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, SHAPES, SHAPES, GL_RGBA, GL_FLOAT, shapesData);
|
||||||
glUniform1i(glGetUniformLocation(pidMain, "u_ShapesTex"), 2);
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -371,58 +371,6 @@ int __cdecl main(int argc, char* argv[])
|
|||||||
glUniform1fvProc(0, SU_NUMSYNCS + 1, syncs);
|
glUniform1fvProc(0, SU_NUMSYNCS + 1, syncs);
|
||||||
glUniform1fvProc(20, FFT_SIZE / 4, fft_uniform);
|
glUniform1fvProc(20, FFT_SIZE / 4, fft_uniform);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////
|
|
||||||
// Hex Grid Builder
|
|
||||||
//////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
static float hexGridData[HEX_TEX_SIZE];
|
|
||||||
|
|
||||||
|
|
||||||
float gap = 0.3f;
|
|
||||||
|
|
||||||
float cellW = 1.6f + 0.2f; // flat-to-flat width
|
|
||||||
float cellH = (sqrtf(3.0f) / 2.0f) * cellW; // height based on regular hex geometry
|
|
||||||
|
|
||||||
float horizontalSpacing = 0.75f * cellW * (1.0f + gap); // 3/4 of width per column
|
|
||||||
float verticalSpacing = cellH * (1.0f + gap); // full height per row
|
|
||||||
|
|
||||||
float rippleCenterX = 7.0f;
|
|
||||||
float rippleCenterY = 7.0f;
|
|
||||||
|
|
||||||
Vec3 gridOffset = { horizontalSpacing * (GRID - 1) * 0.24f, -5.0f, verticalSpacing * (GRID - 1) * 0.24f };
|
|
||||||
|
|
||||||
for (int j = 0; j < GRID; ++j) {
|
|
||||||
for (int i = 0; i < GRID; ++i) {
|
|
||||||
// Offset every other column vertically
|
|
||||||
float offsetZ = (i % 2 == 0) ? 0.0f : 0.5f * verticalSpacing;
|
|
||||||
|
|
||||||
float x = i * horizontalSpacing;
|
|
||||||
float z = j * verticalSpacing + offsetZ;
|
|
||||||
float y = 0.0f;
|
|
||||||
|
|
||||||
Vec3 hexPos = { x - gridOffset.x, y - gridOffset.y, z - gridOffset.z };
|
|
||||||
|
|
||||||
float dx = (float)i - rippleCenterX;
|
|
||||||
float dy = (float)j - rippleCenterY;
|
|
||||||
float hexDist = sqrtf(dx * dx + dy * dy);
|
|
||||||
|
|
||||||
int idx = (j * GRID + i) * 4;
|
|
||||||
hexGridData[idx + 0] = hexPos.x;
|
|
||||||
hexGridData[idx + 1] = hexPos.y;
|
|
||||||
hexGridData[idx + 2] = hexPos.z;
|
|
||||||
hexGridData[idx + 3] = hexDist;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Bind and update u_hexGridTex
|
|
||||||
glActiveTexture(GL_TEXTURE0 + 1);
|
|
||||||
glBindTexture(GL_TEXTURE_2D, hexGridTex);
|
|
||||||
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, GRID, GRID, GL_RGBA, GL_FLOAT, hexGridData);
|
|
||||||
glUniform1i(glGetUniformLocation(pidMain, "u_hexGridTex"), 1);
|
|
||||||
|
|
||||||
glRects(-1, -1, 1, 1);
|
glRects(-1, -1, 1, 1);
|
||||||
|
|
||||||
// render "post process" using the opengl backbuffer
|
// render "post process" using the opengl backbuffer
|
||||||
|
|||||||
@ -8,7 +8,7 @@ layout(location = 0) uniform float syncs[12];
|
|||||||
layout(location = 20) uniform float fft_output[512]; // FFT_SIZE / 4
|
layout(location = 20) uniform float fft_output[512]; // FFT_SIZE / 4
|
||||||
layout(location = 600) uniform vec3 shapes[15]; // shapes - x = horizontal position, y = vertical position, z = length
|
layout(location = 600) uniform vec3 shapes[15]; // shapes - x = horizontal position, y = vertical position, z = length
|
||||||
layout(location = 700) uniform vec3 test; // shapes test
|
layout(location = 700) uniform vec3 test; // shapes test
|
||||||
layout(binding = 1) uniform sampler2D u_hexGridTex; //uniform sampler2D u_fft_texture;
|
//layout(binding = 1) uniform sampler2D u_hexGridTex; //uniform sampler2D u_fft_texture;
|
||||||
layout(binding = 0) uniform sampler2D u_ShapesTex; // uniform sampler2D shapes texture
|
layout(binding = 0) uniform sampler2D u_ShapesTex; // uniform sampler2D shapes texture
|
||||||
float u_time = syncs[0];
|
float u_time = syncs[0];
|
||||||
|
|
||||||
@ -183,7 +183,8 @@ vec2 mapScene(in vec3 p) {
|
|||||||
float gridSize2 = 16.;
|
float gridSize2 = 16.;
|
||||||
for(float j = 0.; j < gridSize2; j++) {
|
for(float j = 0.; j < gridSize2; j++) {
|
||||||
for(float i = 0.; i < gridSize2; i++) {
|
for(float i = 0.; i < gridSize2; i++) {
|
||||||
vec2 texCoord = (vec2(i, j) + 0.5) / float(gridSize2);
|
ivec2 texSize = textureSize(u_ShapesTex, 0);
|
||||||
|
vec2 texCoord = (vec2(i, j)) / vec2(texSize);
|
||||||
vec4 shapeData = texture(u_ShapesTex, texCoord); // RGBA: x, y, length, active
|
vec4 shapeData = texture(u_ShapesTex, texCoord); // RGBA: x, y, length, active
|
||||||
|
|
||||||
float shapeActive = shapeData.a;
|
float shapeActive = shapeData.a;
|
||||||
@ -213,55 +214,55 @@ vec3 castRay(vec3 ro, vec3 rd, inout vec3 pos) {
|
|||||||
const float Z_REPEAT_DIST = 1.;
|
const float Z_REPEAT_DIST = 1.;
|
||||||
vec2 res;
|
vec2 res;
|
||||||
|
|
||||||
// Raymarching
|
// // Raymarching
|
||||||
for (int i = 0; i < 50; i++) {
|
// for (int i = 0; i < 50; i++) {
|
||||||
pos = ro + rd * t;
|
// pos = ro + rd * t;
|
||||||
res = mapScene(pos); // Get distance to objects
|
// res = mapScene(pos); // Get distance to objects
|
||||||
ad = abs(res.x);
|
// ad = abs(res.x);
|
||||||
mat = res.y;
|
// mat = res.y;
|
||||||
if (t > tmax) break;
|
// if (t > tmax) break;
|
||||||
if (ad < tolerance*(t*0.125 + 1.0)) {
|
// if (ad < tolerance*(t*0.125 + 1.0)) {
|
||||||
hit = 1.0;
|
// hit = 1.0;
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
t += res.x; // "march" the ray
|
// t += res.x; // "march" the ray
|
||||||
}
|
// }
|
||||||
t -= Z_REPEAT_DIST*1.;
|
// t -= Z_REPEAT_DIST*1.;
|
||||||
|
//
|
||||||
for( int i=0; i<30; i++ )
|
// for( int i=0; i<30; i++ )
|
||||||
{
|
// {
|
||||||
vec3 pos2 = ro + rd * t;
|
// vec3 pos2 = ro + rd * t;
|
||||||
res = mapScene(pos2); // get distance to objects
|
// res = mapScene(pos2); // get distance to objects
|
||||||
ad = abs(res.x);
|
// ad = abs(res.x);
|
||||||
mat = res.y;
|
// mat = res.y;
|
||||||
if (ad < (tolerance))
|
// if (ad < (tolerance))
|
||||||
{
|
// {
|
||||||
hit = 1.0;
|
// hit = 1.0;
|
||||||
pos = pos2;
|
// pos = pos2;
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
if (t > tmax) break;
|
// if (t > tmax) break;
|
||||||
t += min(d.x, Z_REPEAT_DIST/2.0); // "march" the ray
|
// t += min(d.x, Z_REPEAT_DIST/2.0); // "march" the ray
|
||||||
}
|
// }
|
||||||
//if (t >= tmax) {
|
//if (t >= tmax) {
|
||||||
// t= - 1.0;
|
// t= - 1.0;
|
||||||
// hit = 0.;
|
// hit = 0.;
|
||||||
//}
|
//}
|
||||||
//Reduced from 40 to 24 steps
|
//Reduced from 40 to 24 steps
|
||||||
// for(int i = 0; i < 30; i++) {
|
for(int i = 0; i < 30; i++) {
|
||||||
// pos = ro + rd * t;
|
pos = ro + rd * t;
|
||||||
// vec2 res = mapScene(pos);
|
vec2 res = mapScene(pos);
|
||||||
// // Increase step size multiplier for faster marching
|
// Increase step size multiplier for faster marching
|
||||||
// t += res.x;
|
t += res.x;
|
||||||
// mat = res.y;
|
mat = res.y;
|
||||||
// if(t > 400.) { // Reduced max distance
|
if(t > 400.) { // Reduced max distance
|
||||||
// break;
|
break;
|
||||||
// }
|
}
|
||||||
// if(res.x < 0.00001 * (t*0.00125 + 1.0)) { // Less precise hit detection
|
if(res.x < 0.00001 * (t*0.00125 + 1.0)) { // Less precise hit detection
|
||||||
// hit = 1.;
|
hit = 1.;
|
||||||
// break;
|
break;
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// This will break fog effect
|
// This will break fog effect
|
||||||
//if (t > 100.)
|
//if (t > 100.)
|
||||||
// t = 0.;
|
// t = 0.;
|
||||||
|
|||||||
@ -1,193 +1,175 @@
|
|||||||
// Generated with Shader Minifier 1.5.1 (https://github.com/laurentlb/Shader_Minifier/)
|
// Generated with Shader Minifier 1.5.1 (https://github.com/laurentlb/Shader_Minifier/)
|
||||||
#ifndef FRAGMENT_INL_
|
#ifndef FRAGMENT_INL_
|
||||||
# define FRAGMENT_INL_
|
# define FRAGMENT_INL_
|
||||||
# define VAR_fft_output "H"
|
# define VAR_fft_output "f"
|
||||||
# define VAR_o "f"
|
# define VAR_o "v"
|
||||||
# define VAR_shapes "a"
|
# define VAR_shapes "H"
|
||||||
# define VAR_syncs "m"
|
# define VAR_syncs "m"
|
||||||
# define VAR_test "l"
|
# define VAR_test "l"
|
||||||
# define VAR_u_ShapesTex "x"
|
# define VAR_u_ShapesTex "a"
|
||||||
# define VAR_u_hexGridTex "k"
|
|
||||||
|
|
||||||
const char *fragment_frag =
|
const char *fragment_frag =
|
||||||
"#version 460\n"
|
"#version 460\n"
|
||||||
"precision mediump float;"
|
"precision mediump float;"
|
||||||
"out vec4 f;"
|
"out vec4 v;"
|
||||||
"const float i=2.*acos(-1.),v=sqrt(5.)*.5+.5;"
|
"const float i=2.*acos(-1.),n=sqrt(5.)*.5+.5;"
|
||||||
"layout(location=0)uniform float m[12];"
|
"layout(location=0)uniform float m[12];"
|
||||||
"layout(location=20)uniform float H[512];"
|
"layout(location=20)uniform float f[512];"
|
||||||
"layout(location=600)uniform vec3 a[15];"
|
"layout(location=600)uniform vec3 H[15];"
|
||||||
"layout(location=700)uniform vec3 l;"
|
"layout(location=700)uniform vec3 l;"
|
||||||
"layout(binding=1)uniform sampler2D k;"
|
"layout(binding=0)uniform sampler2D a;"
|
||||||
"layout(binding=0)uniform sampler2D x;"
|
"float g=m[0];"
|
||||||
"float n=m[0];"
|
"mat2 t()"
|
||||||
"mat2 s()"
|
|
||||||
"{"
|
"{"
|
||||||
"float v=sin(.5),x=cos(.5);"
|
"float v=sin(.5),a=cos(.5);"
|
||||||
"return mat2(x,-v,v,x);"
|
"return mat2(a,-v,v,a);"
|
||||||
"}"
|
"}"
|
||||||
"float s(vec3 v,vec2 x)"
|
"float t(vec3 v,vec2 i)"
|
||||||
"{"
|
"{"
|
||||||
"v=abs(v);"
|
"v=abs(v);"
|
||||||
"return max(v.y-x.y,max(v.x*sqrt(3.)*.5+v.z*.5,v.z)-x.x);"
|
"return max(v.y-i.y,max(v.x*sqrt(3.)*.5+v.z*.5,v.z)-i.x);"
|
||||||
"}\n"
|
"}\n"
|
||||||
"#define zclamp(a)max(a,0.0)\n"
|
"#define zclamp(a)max(a,0.0)\n"
|
||||||
"struct HexData{vec3 local;vec2 axial;};"
|
"struct HexData{vec3 local;vec2 axial;};"
|
||||||
"HexData s(vec3 v)"
|
"HexData t(vec3 v)"
|
||||||
"{"
|
"{"
|
||||||
"float x=sqrt(3.)/3.*v.x-1./3.*v.z,f=2./3.*v.z,m=round(x),l=round(f),k=round(-x-f),n=abs(m-x),a=abs(l-f);"
|
"float i=sqrt(3.)/3.*v.x-1./3.*v.z,f=2./3.*v.z,a=round(i),x=round(f),l=round(-i-f),m=abs(a-i),n=abs(x-f);"
|
||||||
"x=abs(k+x+f);"
|
"i=abs(l+i+f);"
|
||||||
"if(n>a&&n>x)"
|
"if(m>n&&m>i)"
|
||||||
"m=-l-k;"
|
"a=-x-l;"
|
||||||
"else if(a>x)"
|
"else if(n>i)"
|
||||||
"l=-m-k;"
|
"x=-a-l;"
|
||||||
"x=sqrt(3.)*(m+l*.5);"
|
"i=sqrt(3.)*(a+x*.5);"
|
||||||
"f=1.5*l;"
|
"f=1.5*x;"
|
||||||
"HexData i;"
|
"HexData r;"
|
||||||
"i.local=v-vec3(x,0,f);"
|
"r.local=v-vec3(i,0,f);"
|
||||||
"i.axial=vec2(m,l);"
|
"r.axial=vec2(a,x);"
|
||||||
"return i;"
|
"return r;"
|
||||||
"}"
|
"}"
|
||||||
"struct HexData{vec3 local;vec2 axial;};"
|
"struct HexData{vec3 local;vec2 axial;};"
|
||||||
"float s(vec2 v)"
|
"float t(vec2 v)"
|
||||||
"{"
|
"{"
|
||||||
"float x=v.x,f=v.y;"
|
"float i=v.x,a=v.y;"
|
||||||
"return max(abs(x),max(abs(f),abs(-x-f)));"
|
"return max(abs(i),max(abs(a),abs(-i-a)));"
|
||||||
"}"
|
"}"
|
||||||
"vec2 t(vec3 v)"
|
"vec2 s(vec3 v)"
|
||||||
"{"
|
"{"
|
||||||
"vec2 f=vec2(v.y,0);"
|
"vec2 i=vec2(v.y,0);"
|
||||||
"HexData m=s(vec3(v.x,v.y-2.5,v.z));"
|
"HexData m=t(vec3(v.x,v.y-2.5,v.z));"
|
||||||
"float i=1.+H[int(clamp(s(m.axial)+1.,0.,511.))]*3.;"
|
"float l=1.+f[int(clamp(t(m.axial)+1.,0.,511.))]*3.;"
|
||||||
"vec3 l=m.local;"
|
"vec3 r=m.local;"
|
||||||
"l.xz*=s();"
|
"r.xz*=t();"
|
||||||
"i=s(vec3(l.x,l.y-i/2,l.z),vec2(.83,i/2));"
|
"l=t(vec3(r.x,r.y-l/2,r.z),vec2(.83,l/2));"
|
||||||
"f=min(f,vec2(i,0));"
|
"i=min(i,vec2(l,0));"
|
||||||
"for(float i=0.;i<16.;i++)"
|
"for(float f=0.;f<16.;f++)"
|
||||||
"for(float l=0.;l<16.;l++)"
|
"for(float l=0.;l<16.;l++)"
|
||||||
"{"
|
"{"
|
||||||
"vec2 m=(vec2(l,i)+.5)/float(16.);"
|
"ivec2 m=textureSize(a,0);"
|
||||||
"vec4 n=texture(x,m);"
|
"vec2 n=vec2(l,f)/vec2(m);"
|
||||||
"if(n.w<.5)"
|
"vec4 r=texture(a,n);"
|
||||||
|
"if(r.w<.5)"
|
||||||
"continue;"
|
"continue;"
|
||||||
"f=min(f,vec2(length(v-vec3(-70.+n.x*2.,12.+n.y*80.,0))-.8,1));"
|
"i=min(i,vec2(length(v-vec3(-70.+r.x*2.,12.+r.y*80.,0))-.8,1));"
|
||||||
"}"
|
"}"
|
||||||
"return f;"
|
"return i;"
|
||||||
"}"
|
"}"
|
||||||
"vec3 s(vec3 v,vec3 x,inout vec3 f)"
|
"vec3 s(vec3 v,vec3 i,inout vec3 f)"
|
||||||
"{"
|
"{"
|
||||||
"float i=0.,l=0.;"
|
"float l=0.,a=0.,x=0.;"
|
||||||
"vec3 m;"
|
|
||||||
"float n=0.,k;"
|
|
||||||
"vec2 a;"
|
|
||||||
"for(int m=0;m<50;m++)"
|
|
||||||
"{"
|
|
||||||
"f=v+x*n;"
|
|
||||||
"a=t(f);"
|
|
||||||
"k=abs(a.x);"
|
|
||||||
"i=a.y;"
|
|
||||||
"if(n>4e2)"
|
|
||||||
"break;"
|
|
||||||
"if(k<.001*(n*.125+1.))"
|
|
||||||
"{"
|
|
||||||
"l=1.;"
|
|
||||||
"break;"
|
|
||||||
"}"
|
|
||||||
"n+=a.x;"
|
|
||||||
"}"
|
|
||||||
"n-=1.;"
|
|
||||||
"for(int r=0;r<30;r++)"
|
"for(int r=0;r<30;r++)"
|
||||||
"{"
|
"{"
|
||||||
"vec3 s=v+x*n;"
|
"f=v+i*x;"
|
||||||
"a=t(s);"
|
"vec2 m=s(f);"
|
||||||
"k=abs(a.x);"
|
"x+=m.x;"
|
||||||
"i=a.y;"
|
"l=m.y;"
|
||||||
"if(k<.001)"
|
"if(x>4e2)"
|
||||||
|
"break;"
|
||||||
|
"if(m.x<1e-5*(x*.00125+1.))"
|
||||||
"{"
|
"{"
|
||||||
"l=1.;"
|
"a=1.;"
|
||||||
"f=s;"
|
|
||||||
"break;"
|
"break;"
|
||||||
"}"
|
"}"
|
||||||
"if(n>4e2)"
|
|
||||||
"break;"
|
|
||||||
"n+=min(m.x,.5);"
|
|
||||||
"}"
|
"}"
|
||||||
"return vec3(n,i,l);"
|
"return vec3(x,l,a);"
|
||||||
"}"
|
"}"
|
||||||
"float s(vec3 v,vec3 x,float f)"
|
"float s(vec3 v,vec3 i,float f)"
|
||||||
"{"
|
"{"
|
||||||
"float i=1.,l=.02;"
|
"float l=1.,a=.02;"
|
||||||
"for(int m=0;m<6;m++)"
|
"for(int r=0;r<6;r++)"
|
||||||
"{"
|
"{"
|
||||||
"if(l>f)"
|
"if(a>f)"
|
||||||
"break;"
|
"break;"
|
||||||
"float n=t(v+l*x).x;"
|
"float m=s(v+a*i).x;"
|
||||||
"i=min(i,n/(4.*l));"
|
"l=min(l,m/(4.*a));"
|
||||||
"l+=clamp(n,.1,.8);"
|
"a+=clamp(m,.1,.8);"
|
||||||
"if(i<-1.)"
|
"if(l<-1.)"
|
||||||
"break;"
|
"break;"
|
||||||
"}"
|
"}"
|
||||||
"i=max(i,-1.);"
|
"l=max(l,-1.);"
|
||||||
"return.25*(1.+i)*(1.+i)*(2.-i);"
|
"return.25*(1.+l)*(1.+l)*(2.-l);"
|
||||||
"}"
|
"}"
|
||||||
"vec3 p(vec3 v)"
|
"vec3 x(vec3 v)"
|
||||||
"{"
|
"{"
|
||||||
"vec2 i=vec2(.01,0);"
|
"vec2 i=vec2(.01,0);"
|
||||||
"return normalize(vec3(t(v+i.xyy).x-t(v-i.xyy).x,t(v+i.yxy).x-t(v-i.yxy).x,t(v+i.yyx).x-t(v-i.yyx).x));"
|
"v=vec3(s(v+i.xyy).x-s(v-i.xyy).x,s(v+i.yxy).x-s(v-i.yxy).x,s(v+i.yyx).x-s(v-i.yyx).x);"
|
||||||
|
"return normalize(v);"
|
||||||
"}"
|
"}"
|
||||||
"vec3 p(vec3 v,vec3 m,vec3 i,vec3 x,float f)"
|
"vec3 s(vec3 v,vec3 l,vec3 i,vec3 a,float f)"
|
||||||
"{"
|
"{"
|
||||||
"vec3 l=vec3(.77,.26,.73);"
|
"vec3 m=vec3(.77,.26,.73);"
|
||||||
"v-=m;"
|
"v-=l;"
|
||||||
"float n=length(v);"
|
"float r=length(v);"
|
||||||
"v=normalize(v);"
|
"v=normalize(v);"
|
||||||
"float a=30./(1.+.09*n+.032*n*n),k=max(dot(x,v),0.);"
|
"float x=30./(1.+.09*r+.032*r*r),n=max(dot(a,v),0.);"
|
||||||
"i=normalize(v-i);"
|
"i=normalize(v-i);"
|
||||||
"vec3 r=vec3(.04);"
|
"vec3 e=vec3(.04);"
|
||||||
"r+=(1.-r)*pow(clamp(1.-max(dot(i,v),0.),0.,1.),5.);"
|
"e+=(1.-e)*pow(clamp(1.-max(dot(i,v),0.),0.,1.),5.);"
|
||||||
"n=s(m+x*.01,v,n);"
|
"r=s(l+a*.01,v,r);"
|
||||||
"return(l*k*a+l*pow(max(dot(x,i),0.),mix(128.,8.,f))*a*r)*n;"
|
"return(m*n*x+m*pow(max(dot(a,i),0.),mix(128.,8.,f))*x*e)*r;"
|
||||||
"}"
|
"}"
|
||||||
"vec3 p(vec3 v,vec3 i,vec3 x,float f)"
|
"vec3 s(vec3 v,vec3 a,vec3 i,float l)"
|
||||||
"{"
|
"{"
|
||||||
"float l=.01;"
|
"float f=.01;"
|
||||||
"vec3 m=vec3(0);"
|
"vec3 m=vec3(0);"
|
||||||
"if(f==0.)"
|
"if(l==0.)"
|
||||||
"m=vec3(.8314,.2941,.2941),l=.1;"
|
"m=vec3(.8314,.2941,.2941),f=.1;"
|
||||||
"else if(f==1.)"
|
"else if(l==1.)"
|
||||||
"m=vec3(.6196,.6118,.6118),l=.7;"
|
"m=vec3(.6196,.6118,.6118),f=.7;"
|
||||||
"else if(f==2.)"
|
"else if(l==2.)"
|
||||||
"m=vec3(.3255,.4784,.3255),l=.2;"
|
"m=vec3(.3255,.4784,.3255),f=.2;"
|
||||||
"else if(f==3.)"
|
"else if(l==3.)"
|
||||||
"m=vec3(.2471,.3059,.6314),l=1.;"
|
"m=vec3(.2471,.3059,.6314),f=1.;"
|
||||||
"else if(f==4.)"
|
"else if(l==4.)"
|
||||||
"m=vec3(.9961,1,.9922),l=.1;"
|
"m=vec3(.9961,1,.9922),f=.1;"
|
||||||
"else if(f==5.)"
|
"else if(l==5.)"
|
||||||
"m=vec3(.9961,1,.9922),l=.3;"
|
"m=vec3(.9961,1,.9922),f=.3;"
|
||||||
"v=vec3(0)+p(vec3(0,40,-10),v,x,i,l)+p(vec3(0,20,15),v,x,i,l)+vec3(.08,.62,.75)*clamp(dot(i,normalize(vec3(0,1,-3)*vec3(0,-1,-2))),0.,1.)*.8;"
|
"vec3 r=vec3(0);"
|
||||||
"return m*max(vec3(0),v);"
|
"r+=s(vec3(0,40,-10),v,i,a,f);"
|
||||||
|
"r+=s(vec3(0,20,15),v,i,a,f);"
|
||||||
|
"r+=vec3(.08,.62,.75)*clamp(dot(a,normalize(vec3(0,1,-3)*vec3(0,-1,-2))),0.,1.)*.8;"
|
||||||
|
"return m*max(vec3(0),r);"
|
||||||
"}"
|
"}"
|
||||||
"vec3 p(vec2 v,vec3 f)"
|
"vec3 s(vec2 i,vec3 v)"
|
||||||
"{"
|
"{"
|
||||||
"f=normalize(vec3(0,10,0)-f);"
|
"v=normalize(vec3(0,10,0)-v);"
|
||||||
"vec3 l=normalize(cross(vec3(0,1,0),f));"
|
"vec3 f=normalize(cross(vec3(0,1,0),v));"
|
||||||
"return normalize(f+v.x*l+v.y*cross(f,l));"
|
"return normalize(v+i.x*f+i.y*cross(v,f));"
|
||||||
"}"
|
"}"
|
||||||
"vec3 p(vec2 v)"
|
"vec3 s(vec2 v)"
|
||||||
"{"
|
"{"
|
||||||
"vec3 f=vec3(-20,20,-20),l=p(v,f),i=vec3(0),x=vec3(0);"
|
"vec3 i=vec3(-20,20,-20),a=s(v,i),l=vec3(0),f=vec3(0);"
|
||||||
"f=s(f,l,x);"
|
"i=s(i,a,f);"
|
||||||
"if(f.x>0.)"
|
"if(i.x>0.)"
|
||||||
"{"
|
"{"
|
||||||
"vec3 v=p(x);"
|
"vec3 v=x(f);"
|
||||||
"i=p(x,v,l,f.y);"
|
"l=s(f,v,a,i.y);"
|
||||||
"}"
|
"}"
|
||||||
"return i*exp(-f.x*.01)+mix(i,mix(vec3(.2667,.2941,.3451),vec3(.302,.3176,.3725),pow(max(dot(l,vec3(0,-.5,1.8)),0.),clamp(m[1]+m[2]+m[3],0.,1.)*5.)),1.-exp(-f.x*.01))*(1.-exp(-f.x*.01));"
|
"return l*exp(-i.x*.01)+mix(l,mix(vec3(.2667,.2941,.3451),vec3(.302,.3176,.3725),pow(max(dot(a,vec3(0,-.5,1.8)),0.),clamp(m[1]+m[2]+m[3],0.,1.)*5.)),1.-exp(-i.x*.01))*(1.-exp(-i.x*.01));"
|
||||||
"}"
|
"}"
|
||||||
"void main()"
|
"void main()"
|
||||||
"{"
|
"{"
|
||||||
"vec3 v=p(gl_FragCoord.xy*vec2(.00104166667,.00185185185)-1.);"
|
"vec3 l=s(gl_FragCoord.xy*vec2(.00104166667,.00185185185)-1.);"
|
||||||
"f=vec4(v,1);"
|
"v=vec4(l,1);"
|
||||||
"}";
|
"}";
|
||||||
|
|
||||||
#endif // FRAGMENT_INL_
|
#endif // FRAGMENT_INL_
|
||||||
|
|||||||
Reference in New Issue
Block a user