@korial29/tiny-fps 0.126.0 → 0.126.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +7 -6
- package/dist/types/client/render.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -19,7 +19,7 @@ c=min(c,.6)+.4*(1.-exp(-max(c-.6,0.)/.4));
|
|
|
19
19
|
float a=atan(q.y,q.x)*24.,h=fract(sin(floor(a)*12.9898)*43758.5453);
|
|
20
20
|
c+=L*step(.85-.5*L,h)*sin(fract(a)*3.1416)*smoothstep(.2,.6,length(q))*fract(length(q)*3.-Y.w*.002+h*9.)*.22;
|
|
21
21
|
c*=1.-(.7+.3*L)*dot(q,q);
|
|
22
|
-
c=pow(c*vec3(.97,1.,1.03),vec3(.92))+(fract(sin(dot(gl_FragCoord.xy+Y.w,vec2(12.9898,78.233)))*43758.5453)-.5)*.03;}
|
|
22
|
+
c=pow(max(c*vec3(.97,1.,1.03),0.),vec3(.92))+(fract(sin(dot(gl_FragCoord.xy+Y.w,vec2(12.9898,78.233)))*43758.5453)-.5)*.03;}
|
|
23
23
|
o=vec4(c,1);}`,FA=[[.04,8],[.25,30],[0,1],[.08,10],[.8,48],[.06,12],[.3,20],[.7,40],[.06,14],[1.5,110],[.9,60],[.25,30],[.12,16],[.1,24],[1.4,90],[1.1,34]],IA=`#version 300 es
|
|
24
24
|
precision highp float;precision highp sampler2DArray;precision highp sampler2DArrayShadow;
|
|
25
25
|
in vec3 P,N;in vec4 C;uniform vec3 E;uniform float T,Z,Y;uniform int Q;
|
|
@@ -27,6 +27,7 @@ uniform vec4 A[16],B[16],K[16],F;uniform float U;uniform vec3 G[16],H[5],O,X;uni
|
|
|
27
27
|
uniform sampler2DArray S;uniform sampler2DArrayShadow D;out vec4 o;
|
|
28
28
|
const vec2 SP[${FA.length}]=vec2[](${FA.map(([e,t])=>`vec2(${e},${t})`)});
|
|
29
29
|
vec3 e(vec3 x){return 2.*(1.-exp(-.5*x));}
|
|
30
|
+
vec3 nz(vec3 v){return v*inversesqrt(max(dot(v,v),1e-12));}
|
|
30
31
|
vec3 K0(vec3 d){
|
|
31
32
|
float h=d.y,k=max(dot(d,O),0.);
|
|
32
33
|
vec3 c=mix(H[4],H[3],pow(clamp(h,0.,1.),.5));
|
|
@@ -54,18 +55,18 @@ float h=t.a*s*0.06,det=dot(dx,a);
|
|
|
54
55
|
float f=1.-smoothstep(.6,2.5,${128/vA}.*max(length(dFdx(C.xy)),length(dFdy(C.xy))));
|
|
55
56
|
vec3 m=normalize(abs(det)*n-sign(det)*f*(dFdx(h)*a+dFdy(h)*b)+n*1e-9);
|
|
56
57
|
vec2 R=SP[int(s>0.?L+.5:L<-1.2?${nw+1}.:L<-1.1?${nw+2}.:${nw}.)];
|
|
57
|
-
vec3 y=mix(vec3(1),G[int(min(I,15.))]*(C.w-2.*I),s),V=normalize(E-P),w=
|
|
58
|
+
vec3 y=mix(vec3(1),G[int(min(I,15.))]*(C.w-2.*I),s),V=normalize(E-P),w=nz(n+m);
|
|
58
59
|
float sd=max(dot(m,O),0.)*smoothstep(0.,.1,dot(n,O)),sv=1.;
|
|
59
60
|
if(sd>0.&&g<1.){
|
|
60
61
|
vec4 q=W*vec4(P+n*.08,1);q.xyz=q.xyz*.5+.5;
|
|
61
62
|
float v=0.;
|
|
62
63
|
for(int j=0;j<4;j++)v+=texture(D,vec4(q.xy+(vec2(j&1,j>>1)*2.-1.)*${.75/yA},0,q.z-.0004));
|
|
63
64
|
sv=mix(v/4.,1.,smoothstep(.8,1.,max(abs(q.x-.5),abs(q.y-.5))*2.));}
|
|
64
|
-
vec3 l=y*(mix(mix(H[1],H[0],max(w.y,0.)),H[2],max(-w.y,0.))+X*sd*sv),sp=X*sv*sd*pow(max(dot(m,
|
|
65
|
+
vec3 l=y*(mix(mix(H[1],H[0],max(w.y,0.)),H[2],max(-w.y,0.))+X*sd*sv),sp=X*sv*sd*pow(max(dot(m,nz(O+V)),0.),R.y);
|
|
65
66
|
for(int i=0;i<16;i++){
|
|
66
67
|
if(i>=Q||g>0.)break;
|
|
67
68
|
vec3 d=A[i].xyz-P;float r=length(d),k=K[i].w,u=B[i].w;
|
|
68
|
-
d/=r;
|
|
69
|
+
d/=max(r,1e-4);
|
|
69
70
|
float w=max(1.-r*r/(A[i].w*A[i].w),0.);
|
|
70
71
|
w*=w*smoothstep(u,u+(1.-u)*.4,-dot(d,B[i].xyz))*max(dot(m,d),0.);
|
|
71
72
|
if(w>0.&&k>=0.){
|
|
@@ -74,9 +75,9 @@ float v=0.;
|
|
|
74
75
|
for(int j=0;j<4;j++)v+=texture(D,vec4(q.xy+(vec2(j&1,j>>1)*2.-1.)*${.75/yA},k+1.,q.z-.0005));
|
|
75
76
|
w*=v/4.;}
|
|
76
77
|
l+=K[i].rgb*w;
|
|
77
|
-
sp+=K[i].rgb*w*pow(max(dot(m,
|
|
78
|
+
sp+=K[i].rgb*w*pow(max(dot(m,nz(d+V)),0.),R.y);}
|
|
78
79
|
c=c*mix(e(l),vec3(1.4),g)+e(sp*R.x*(.4+.6*mix(1.,t.a,s)));
|
|
79
|
-
vec3 r=reflect(-V,m),k=K0(r);float fr=pow(1.-
|
|
80
|
+
vec3 r=reflect(-V,m),k=K0(r);float fr=pow(clamp(1.-dot(m,V),0.,1.),4.);
|
|
80
81
|
c+=step(abs(L-${L.GLASS}.),.5)*k*(.1+.9*fr);
|
|
81
82
|
c=mix(c,k*(.4+c)*(.2+.8*smoothstep(-.1,.25,r.y)+1.6*exp(-abs(r.y-.12)*18.)),step(abs(L-(${ho})),.1)*(.35+.4*fr));
|
|
82
83
|
c+=step(abs(L-(${go})),.02)*(.3*fr+.1*smoothstep(.2,.9,r.y))*(.3+.7*sv);
|
|
@@ -38,6 +38,7 @@ export declare const FOV: number;
|
|
|
38
38
|
export declare const ROVER_NEAR: number, ROVER_MID: number;
|
|
39
39
|
/** A ship's, 14 m long: its cockpit and its struts within 45 m, its plain shape past 160 m. */
|
|
40
40
|
export declare const SHIP_NEAR: number, SHIP_MID: number;
|
|
41
|
+
export declare const POST_FRAG = "#version 300 es\nprecision highp float;uniform sampler2D S[4];uniform vec4 Y;uniform float L;in vec2 U;out vec4 o;\nvec3 b(vec2 x){vec3 c=texture(S[0],x).rgb;return c*smoothstep(.9,2.,max(c.r,max(c.g,c.b)));}\n#define T(k)texture(S[0],U+Y.xy*(k)).rgb\nvoid main(){\nvec3 c;\nif(Y.z<1.)c=(b(U+Y.xy)+b(U-Y.xy)+b(U+Y.xy*vec2(1,-1))+b(U-Y.xy*vec2(1,-1)))/4.;\nelse if(Y.z<2.)c=T(0.)*.227+(T(1.3846)+T(-1.3846))*.3162+(T(3.2308)+T(-3.2308))*.0703;\nelse{\nc=texture(S[0],U).rgb+texture(S[1],U).rgb*1.3+texture(S[2],U).rgb*1.+texture(S[3],U).rgb*.7;\nvec2 q=U-.5;\nc=min(c,.6)+.4*(1.-exp(-max(c-.6,0.)/.4));\nfloat a=atan(q.y,q.x)*24.,h=fract(sin(floor(a)*12.9898)*43758.5453);\nc+=L*step(.85-.5*L,h)*sin(fract(a)*3.1416)*smoothstep(.2,.6,length(q))*fract(length(q)*3.-Y.w*.002+h*9.)*.22;\nc*=1.-(.7+.3*L)*dot(q,q);\nc=pow(max(c*vec3(.97,1.,1.03),0.),vec3(.92))+(fract(sin(dot(gl_FragCoord.xy+Y.w,vec2(12.9898,78.233)))*43758.5453)-.5)*.03;}\no=vec4(c,1);}";
|
|
41
42
|
/**
|
|
42
43
|
* Blinn-Phong strength and exponent: a row per TEX id in order (brick, tile, lava, stone, metal, wood,
|
|
43
44
|
* moss, grate, concrete, glass, steel, paint, rock), then the flat bodies, then polished metal (SHINE),
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@korial29/tiny-fps",
|
|
3
3
|
"description": "Tiny multiplayer first-person rooftop game for the browser: raw WebGL, zero runtime dependencies, WebSocket or same-browser multi-tab play.",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
|
-
"version": "0.126.
|
|
5
|
+
"version": "0.126.1",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"files": [
|
|
8
8
|
"dist"
|