fixes
This commit is contained in:
0
4k_test.zip
Normal file
0
4k_test.zip
Normal file
BIN
4k_test2.zip
Normal file
BIN
4k_test2.zip
Normal file
Binary file not shown.
@ -59,7 +59,7 @@ EXE_LINKER_PROGRAM=Crinkler
|
||||
|
||||
QUOTE=\"
|
||||
|
||||
CRINKLER_ORDERTRIES=4000
|
||||
CRINKLER_ORDERTRIES=400
|
||||
|
||||
AUDIO_BUFFER_ALLOCATED_LENGTH=5257472
|
||||
AUDIO_SAMPLING_RATE=44100
|
||||
|
||||
@ -8,7 +8,7 @@ include $(PARENT_CONFIG)
|
||||
|
||||
# Visuals
|
||||
EXE_LINKER_PROGRAM=Crinkler
|
||||
CRINKLER_ORDERTRIES=4000
|
||||
CRINKLER_ORDERTRIES=400
|
||||
SHADER_FILE=shader_minified.h
|
||||
TIME_UNIFORM_NAME='v'
|
||||
RESOLUTION_UNIFORM_NAME='m'
|
||||
|
||||
39
shader.glsl
39
shader.glsl
@ -3,16 +3,6 @@ uniform vec2 resolution;
|
||||
uniform sampler2D texture_sampler;
|
||||
uniform sampler2D texts;
|
||||
|
||||
#define MAX_STEPS 100
|
||||
#define MAX_DIST 20.
|
||||
#define SURF_DIST .001
|
||||
#define TAU 6.283185
|
||||
#define PI 3.141592
|
||||
|
||||
#define FOG_DENSITY 0.01
|
||||
|
||||
|
||||
|
||||
struct Obj {
|
||||
float distance; // distance map
|
||||
int material; // material Id
|
||||
@ -25,8 +15,7 @@ mat2 Rot(float a) {
|
||||
}
|
||||
|
||||
vec3 applyFog(in vec3 color, in float distance) {
|
||||
|
||||
float fogAmount = 1.0 - exp(-distance*FOG_DENSITY);
|
||||
float fogAmount = 1.0 - exp(-distance *0.01);
|
||||
vec3 fogColor = vec3(0.17, 0.16, 0.24);
|
||||
return mix( color, fogColor, fogAmount );
|
||||
}
|
||||
@ -95,13 +84,13 @@ Obj castRay(vec3 ro, vec3 rd) {
|
||||
float t = 0.0;
|
||||
|
||||
Obj res = Obj(-1., -1);
|
||||
for(int i=0; i<MAX_STEPS; i++) {
|
||||
for(int i=0; i<100; i++) {
|
||||
vec3 p = ro + rd * t;
|
||||
res = mapScene(p);
|
||||
t += res.distance;
|
||||
if (t > MAX_DIST || res.distance < abs(SURF_DIST*t) ) break;
|
||||
if (t > 20.0 || res.distance < abs(0.001*t) ) break;
|
||||
}
|
||||
if (t > MAX_DIST) t = -1.0;
|
||||
if (t > 20.0) t = -1.0;
|
||||
res.distance = t;
|
||||
return res;
|
||||
}
|
||||
@ -109,7 +98,7 @@ Obj castRay(vec3 ro, vec3 rd) {
|
||||
float castShadow(vec3 ro, vec3 rd) {
|
||||
float res = 1.0;
|
||||
float t = 0.001;
|
||||
for(int i = 0; i < MAX_STEPS; i++) {
|
||||
for(int i = 0; i < 100; i++) {
|
||||
vec3 pos = ro + t* rd;
|
||||
float h = mapScene(pos).distance;
|
||||
res = min(res, 10.0*h/t);
|
||||
@ -191,23 +180,16 @@ vec3 shading(vec3 v, vec3 n, vec3 dir, int material) {
|
||||
float sun_dif = clamp(dot(n, SUN_DIR), 0., 1.);
|
||||
final += outMaterial * vec3(0.0353, 0.2667, 0.4784) * sun_dif;
|
||||
}
|
||||
// final += texture( iChannel0, ref ).rgb * fresnel( Ks, n, -dir );
|
||||
// vec3 col = vec3(0.4)* ref.x;
|
||||
//vec3 col = vec3(0.0588, 0.0588, 0.1216);// - vec3(0.149, 0.0863, 0.2314) * v.x;
|
||||
//final += col * fresnel( vec3(.5), ref, -dir );
|
||||
|
||||
return final;
|
||||
return final;
|
||||
}
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 p = (2.0 * gl_FragCoord.xy - resolution.xy) / resolution.y;
|
||||
vec2 p = (gl_FragCoord.xy * 2. - resolution.xy) / min(resolution.x, resolution.y);
|
||||
// vec2 p = (2.0 * gl_FragCoord.xy - resolution.xy) / resolution.y;
|
||||
float angle = time*0.4;
|
||||
// angle = 2.0; // comment to rotate
|
||||
// gl_FragColor = vec4(vec3(sdCog2d(p)), 1.);
|
||||
// return;
|
||||
// camera
|
||||
vec3 ta = vec3(0.0, 0., 0.0);
|
||||
vec3 ro = ta + vec3(4.*sin(angle), cos(angle), 4.*cos(angle)); // *cos(angle))
|
||||
|
||||
@ -227,7 +209,6 @@ void main()
|
||||
col = shading(pos, nor, rd , t.material);
|
||||
// apply fog
|
||||
col = applyFog(col, t.distance);
|
||||
}
|
||||
|
||||
gl_FragColor = vec4( pow( col, vec3(1.0/1.3) ), 1.0 );
|
||||
}
|
||||
gl_FragColor = vec4( pow(col, vec3(1.0/1.3) ), 1.0 );
|
||||
}
|
||||
@ -9,152 +9,141 @@
|
||||
const char *__temp_cleaned_shader_glsl =
|
||||
"uniform float v;"
|
||||
"uniform vec2 m;"
|
||||
"uniform sampler2D e,d;\n"
|
||||
"#define MAX_STEPS 100\n"
|
||||
"#define MAX_DIST 20.\n"
|
||||
"#define SURF_DIST.001\n"
|
||||
"#define TAU 6.283185\n"
|
||||
"#define PI 3.141592\n"
|
||||
"#define FOG_DENSITY 0.01\nstruct Obj{float distance;int material;};"
|
||||
"uniform sampler2D e,d;struct Obj{float distance;int material;};"
|
||||
"mat2 n(float v)"
|
||||
"{"
|
||||
"float m=sin(v),d=cos(v);"
|
||||
"return mat2(d,-m,m,d);"
|
||||
"float f=sin(v),y=cos(v);"
|
||||
"return mat2(y,-f,f,y);"
|
||||
"}"
|
||||
"vec3 n(vec3 v,float m)"
|
||||
"float n(vec3 v,float m)"
|
||||
"{"
|
||||
"float d=1.-exp(-m*FOG_DENSITY);"
|
||||
"return mix(v,vec3(.17,.16,.24),d);"
|
||||
"}"
|
||||
"float s(vec3 v,float m)"
|
||||
"{"
|
||||
"vec2 d=vec2(m,abs(v.z)-.15);"
|
||||
"return min(max(d.x,d.y),0.)+length(max(d,0.));"
|
||||
"vec2 f=vec2(m,abs(v.z)-.15);"
|
||||
"return min(max(f.x,f.y),0.)+length(max(f,0.));"
|
||||
"}"
|
||||
"float s(vec2 v)"
|
||||
"{"
|
||||
"float d=1.-smoothstep(-.2,.8,sin(atan(v.y,v.x)*12.))*.14;"
|
||||
"return smoothstep(d,d+2.,length(v)*2.);"
|
||||
"float f=1.-smoothstep(-.2,.8,sin(atan(v.y,v.x)*12.))*.14;"
|
||||
"return smoothstep(f,f+2.,length(v)*2.);"
|
||||
"}"
|
||||
"float x(float m,float v)"
|
||||
"float s(float f,float v)"
|
||||
"{"
|
||||
"float d=max(.02-abs(-m-v),0.);"
|
||||
"return max(-m,v)+d*d*.25/.02;"
|
||||
"float m=max(.02-abs(-f-v),0.);"
|
||||
"return max(-f,v)+m*m*.25/.02;"
|
||||
"}"
|
||||
"float x(vec3 v)"
|
||||
"{"
|
||||
"vec3 m=vec3(0),d=v-m,y=vec3(0,0,1)-m;"
|
||||
"return length(d-y*clamp(dot(d,y)/dot(y,y),0.,1.))-.2;"
|
||||
"vec3 f=vec3(0),m=v-f,y=vec3(0,0,1)-f;"
|
||||
"return length(m-y*clamp(dot(m,y)/dot(y,y),0.,1.))-.2;"
|
||||
"}"
|
||||
"float p(vec3 v,float m)"
|
||||
"float x(vec3 v,float m)"
|
||||
"{"
|
||||
"v.xy*=n(m);"
|
||||
"float d=s(v,s(v.xy)),y=x(v-vec3(0,0,-.5));"
|
||||
"return.8*x(y,d)-.001;"
|
||||
"float f=n(v,s(v.xy)),y=x(v-vec3(0,0,-.5));"
|
||||
"return.8*s(y,f)-.001;"
|
||||
"}"
|
||||
"Obj p(vec3 m)"
|
||||
"Obj f(vec3 m)"
|
||||
"{"
|
||||
"float d=1e10;"
|
||||
"float f=1e10;"
|
||||
"Obj e=Obj(m.y+1.5+sin(m.z*.6)*.2+sin(m.x*1.3)*.1,0);"
|
||||
"{"
|
||||
"float y=p(m+vec3(1,0,0),v);"
|
||||
"d=min(d,y);"
|
||||
"float y=x(m+vec3(1,0,0),v);"
|
||||
"f=min(f,y);"
|
||||
"}"
|
||||
"{"
|
||||
"float y=p(m+vec3(.5,-.87,0),-v);"
|
||||
"d=min(d,y);"
|
||||
"float y=x(m+vec3(.5,-.87,0),-v);"
|
||||
"f=min(f,y);"
|
||||
"}"
|
||||
"{"
|
||||
"float y=p(m+vec3(.5,.87,0),-v);"
|
||||
"d=min(d,y);"
|
||||
"float y=x(m+vec3(.5,.87,0),-v);"
|
||||
"f=min(f,y);"
|
||||
"}"
|
||||
"Obj y=Obj(d,1);"
|
||||
"Obj y=Obj(f,1);"
|
||||
"return e.distance>y.distance?"
|
||||
"y:"
|
||||
"e;"
|
||||
"}"
|
||||
"Obj t(vec3 v,vec3 m)"
|
||||
"Obj f(vec3 v,vec3 y)"
|
||||
"{"
|
||||
"float d=0.;"
|
||||
"float m=0.;"
|
||||
"Obj r=Obj(-1.,-1);"
|
||||
"for(int y=0;y<MAX_STEPS;y++)"
|
||||
"for(int e=0;e<100;e++)"
|
||||
"{"
|
||||
"vec3 e=v+m*d;"
|
||||
"r=p(e);"
|
||||
"d+=r.distance;"
|
||||
"if(d>MAX_DIST||r.distance<abs(SURF_DIST*d))"
|
||||
"vec3 c=v+y*m;"
|
||||
"r=f(c);"
|
||||
"m+=r.distance;"
|
||||
"if(m>20.||r.distance<abs(.001*m))"
|
||||
"break;"
|
||||
"}"
|
||||
"if(d>MAX_DIST)"
|
||||
"d=-1.;"
|
||||
"r.distance=d;"
|
||||
"if(m>20.)"
|
||||
"m=-1.;"
|
||||
"r.distance=m;"
|
||||
"return r;"
|
||||
"}"
|
||||
"float f(vec3 v,vec3 m)"
|
||||
"float p(vec3 v,vec3 m)"
|
||||
"{"
|
||||
"float d=1.,y=.001;"
|
||||
"for(int r=0;r<MAX_STEPS;r++)"
|
||||
"float y=1.,r=.001;"
|
||||
"for(int e=0;e<100;e++)"
|
||||
"{"
|
||||
"vec3 e=v+y*m;"
|
||||
"float c=p(e).distance;"
|
||||
"d=min(d,10.*c/y);"
|
||||
"if(abs(c)<.001*y)"
|
||||
"vec3 c=v+r*m;"
|
||||
"float n=f(c).distance;"
|
||||
"y=min(y,10.*n/r);"
|
||||
"if(abs(n)<.001*r)"
|
||||
"break;"
|
||||
"y+=c;"
|
||||
"if(y>20.)"
|
||||
"r+=n;"
|
||||
"if(r>20.)"
|
||||
"break;"
|
||||
"}"
|
||||
"return clamp(d,0.,1.);"
|
||||
"return clamp(y,0.,1.);"
|
||||
"}"
|
||||
"vec3 f(vec3 v)"
|
||||
"vec3 p(vec3 v)"
|
||||
"{"
|
||||
"vec2 m=vec2(.001,0);"
|
||||
"vec3 d=vec3(p(v+m.xyy).distance-p(v-m.xyy).distance,p(v+m.yxy).distance-p(v-m.yxy).distance,p(v+m.yyx).distance-p(v-m.yyx).distance);"
|
||||
"return normalize(d);"
|
||||
"vec3 y=vec3(f(v+m.xyy).distance-f(v-m.xyy).distance,f(v+m.yxy).distance-f(v-m.yxy).distance,f(v+m.yyx).distance-f(v-m.yyx).distance);"
|
||||
"return normalize(y);"
|
||||
"}"
|
||||
"vec3 f(vec3 m,vec3 v,vec3 d)"
|
||||
"vec3 f(vec3 v,vec3 m,vec3 y)"
|
||||
"{"
|
||||
"return m+(1.-m)*pow(clamp(1.-dot(v,d),0.,1.),5.);"
|
||||
"return v+(1.-v)*pow(clamp(1.-dot(m,y),0.,1.),5.);"
|
||||
"}"
|
||||
"vec3 f(vec3 v,vec3 d,vec3 m,int y)"
|
||||
"vec3 f(vec3 v,vec3 y,vec3 m,int c)"
|
||||
"{"
|
||||
"float e=1.;"
|
||||
"vec3 r=vec3(0),c=reflect(m,d),a=vec3(.5),i=vec3(1),n=vec3(.1255);"
|
||||
"if(y==0)"
|
||||
"n=vec3(.1412),e=3.1;"
|
||||
"else if(y==1)"
|
||||
"n=vec3(.1765,.1961,.2275),e=21.;"
|
||||
"vec3 r=vec3(0),d=reflect(m,y),n=vec3(.5),a=vec3(1),O=vec3(.1255);"
|
||||
"if(c==0)"
|
||||
"O=vec3(.1412),e=3.1;"
|
||||
"else if(c==1)"
|
||||
"O=vec3(.1765,.1961,.2275),e=21.;"
|
||||
"{"
|
||||
"vec3 x=normalize(vec3(-2,.3,10)-v),O=vec3(max(0.,dot(x,c))),l=f(a,normalize(x-m),x);"
|
||||
"O=pow(O,vec3(e));"
|
||||
"r+=n*O*(vec3(.71,.51,.72)*5.)*mix(i*vec3(max(0.,dot(x,d))),O,l);"
|
||||
"vec3 x=normalize(vec3(-2,.3,10)-v),i=vec3(max(0.,dot(x,d))),l=f(n,normalize(x-m),x);"
|
||||
"i=pow(i,vec3(e));"
|
||||
"r+=O*i*(vec3(.71,.51,.72)*5.)*mix(a*vec3(max(0.,dot(x,y))),i,l);"
|
||||
"}"
|
||||
"{"
|
||||
"vec3 x=normalize(vec3(5,5,-20)-v),O=vec3(max(0.,dot(x,c))),l=f(a,normalize(x-m),x);"
|
||||
"O=pow(O,vec3(e));"
|
||||
"r+=n*O*(vec3(.14,.36,.83)*7.)*mix(i*vec3(max(0.,dot(x,d))),O,l);"
|
||||
"vec3 x=normalize(vec3(5,5,-20)-v),i=vec3(max(0.,dot(x,d))),l=f(n,normalize(x-m),x);"
|
||||
"i=pow(i,vec3(e));"
|
||||
"r+=O*i*(vec3(.14,.36,.83)*7.)*mix(a*vec3(max(0.,dot(x,y))),i,l);"
|
||||
"}"
|
||||
"{"
|
||||
"vec3 x=vec3(0,.4,1);"
|
||||
"float O=clamp(dot(d,x),0.,1.),l=f(v+d*.02,x);"
|
||||
"r+=n*vec3(1.1,1.2,1.5)*O*O*l;"
|
||||
"float i=clamp(dot(y,x),0.,1.),l=p(v+y*.02,x);"
|
||||
"r+=O*vec3(1.1,1.2,1.5)*i*i*l;"
|
||||
"}"
|
||||
"r+=n*vec3(.0353,.2667,.4784)*clamp(dot(d,vec3(0,.6,-1)),0.,1.);"
|
||||
"r+=O*vec3(.0353,.2667,.4784)*clamp(dot(y,vec3(0,.6,-1)),0.,1.);"
|
||||
"return r;"
|
||||
"}"
|
||||
"void main()"
|
||||
"{"
|
||||
"vec2 d=(2.*gl_FragCoord.xy-m.xy)/m.y;"
|
||||
"float y=v*.4;"
|
||||
"vec3 e=vec3(0),x=e+vec3(4.*sin(y),cos(y),4.*cos(y)),O=normalize(e-x),c=normalize(cross(O,vec3(0,1,0))),l=normalize(d.x*c+d.y*normalize(cross(c,O))+1.4*O),r=vec3(.1451,.1098,.1608)-vec3(.9725,.5176,0)*l.y;"
|
||||
"Obj i=t(x,l);"
|
||||
"if(i.distance>0.)"
|
||||
"vec2 y=(gl_FragCoord.xy*2.-m.xy)/min(m.x,m.y);"
|
||||
"float x=v*.4;"
|
||||
"vec3 e=vec3(0),i=e+vec3(4.*sin(x),cos(x),4.*cos(x)),c=normalize(e-i),r=normalize(cross(c,vec3(0,1,0))),l=normalize(y.x*r+y.y*normalize(cross(r,c))+1.4*c),d=vec3(.1451,.1098,.1608)-vec3(.9725,.5176,0)*l.y;"
|
||||
"Obj n=f(i,l);"
|
||||
"if(n.distance>0.)"
|
||||
"{"
|
||||
"vec3 a=x+l*i.distance,s=f(a);"
|
||||
"r=f(a,s,l,i.material);"
|
||||
"r=n(r,i.distance);"
|
||||
"vec3 a=i+l*n.distance,O=p(a);"
|
||||
"d=f(a,O,l,n.material);"
|
||||
"d=mix(d,vec3(.17,.16,.24),1.-exp(-n.distance*.01));"
|
||||
"}"
|
||||
"gl_FragColor=vec4(pow(r,vec3(1./1.3)),1);"
|
||||
"gl_FragColor=vec4(pow(d,vec3(1./1.3)),1);"
|
||||
"}";
|
||||
|
||||
#endif // SHADER_MINIFIED_H_
|
||||
|
||||
Reference in New Issue
Block a user