logo
logo
EXPERIENCE THE NEW TREATMENT
EVEREST MAGMA
TAMBURI NERI
EVEREST MAGMA TAMBURI NERI
MUTE MUSIC
EVEREST MAGMA TAMBURI NERI
EVEREST MAGMA
TAMBURI NERI
TAMBURI NERI TAMBURI NERI
X CLOSE
STAY UP TO DATE WITH GUIDI
subscribe to our newsletter for the latest news and product updates straight to your inbox
SUBSCRIBE NEWSLETTER
*REQUIRED FIELD
/images/onetime.png
menu
CLOSE

WORLDWIDE STOCKLISTS INFORMATION UPON REQUEST

NAME*
SUBJECT
PHONE
EMAIL*
CONFIRM EMAIL*
COMMENTS
tik
accept terms and conditions*
Privacy Policy
learn more
tik
Keep in Touch
"I want to subscribe to the newsletter", in accordance with point 1.3 of the privacy policy .
learn more
SEND MESSAGE
MESSAGE.SENTINVALID.MAIL
* REQUIRED FIELDS

WORLDWIDE STOCKISTS INFORMATION UPON REQUEST

NAME*
SUBJECT
PHONE
EMAIL*
COMMENTS
SEND MESSAGE

ABOUT

Roots

Tannery

Shoes

ABOUT
. Since 1896 Guido Guidi, Giovanni Rosellini and Gino Ulivo established "conceria Guidi Rosellini" in Pescia, Tuscany. Here, the art of leather tanning can be traced back to the middle age, where a guild of tanners and shoemakers existed since the XIV century.
. Today Ruggero Guidi is running the tannery and has spent his time and energy looking for the perfect balance between advanced technologies and respect for his heritage of traditions and skills. The "conceria Guidi Rosellini" is well known all over the world: the most demanding designers ask Guidi for special leathers and treatments and he always delivers exactly what they want.
. Passion for leather and respect for its tradition are the core of Guidi's shoe collection project. He refuses the mass production logic being instead focused on his own independent research beyond all the trends. Shoes for all of those who really want something unique with a twist of tradition; shoes that only a craftsman would be able to make. Guidi is the tie existing between the object and its possessor.

GUIDI1896 srl


Address:
VIA STIGNANESE, 76
51019 PONTE BUGGIANESE (PT)
ITALY

CONTACTS:


EMAIL*
COMMENTS
SEND MESSAGE

GUIDI 1896 srl


billing address:
VIA STIGNANESE, 76
51019 PONTE BUGGIANESE (PT) ITALY

MAILTO:

CONTACTS:


GUIDI@GUIDI.IT

CUSTOMER SERVICE
PHONE: +39 0572 930211
CUSTOMERSERVICE@GUIDI.IT

EMAIL*
COMMENTS
SEND MESSAGE
MESSAGE.SENTINVALID.MAIL
glit glit
//https://dominium.maksw.com/articles/physically-based-rendering-pbr/pbr-part-one/ //https://threejs.org/examples/webgl_materials_envmaps_parallax.html precision highp float; precision highp int; varying vec3 vViewModelPosition; varying vec3 vvLocalSurfaceNormal ; varying vec3 vvLocalSurfaceToLightDirection; varying vec3 vvLocalReflectedSurfaceToViewerDirection; varying vec3 vvLocalSurfaceToViewerDirection; //varying vec2 vuvCoord0 ; varying vec2 vUv ; uniform mat3 uvTransform; uniform vec3 glLightPosition; void main(){ //vuvCoord0 = gl_MultiTexCoord0.st ; vUv = ( uvTransform * vec3( uv, 1 ) ).xy; vec3 objectNormal = vec3( normal ); vec3 transformedNormal = objectNormal; transformedNormal = normalMatrix * transformedNormal; vvLocalSurfaceNormal = normalize( transformedNormal ); vec3 transformed = vec3( position ); vec4 mvPosition = vec4( transformed, 1.0 ); mvPosition = modelViewMatrix * mvPosition; vViewModelPosition = - mvPosition.xyz; // vec3 vViewModelPosition = vec3(gl_ModelViewMatrixInverse * vec4(0, 0, 0, 1.0)); // vec3 vLightModelPosition = (gl_ModelViewMatrixInverse * gl_LightSource[0].position).xyz; //vec3 vViewModelPosition = vec4(gl_ModelViewMatrixInverse * vec4(0., 0., 0., 1.0)).xyz; vvLocalSurfaceToViewerDirection = normalize(vViewModelPosition - transformed) ; //glLightPosition=vec3(0.,10.,-700.); vec3 vLightModelPosition = (glLightPosition).xyz; vvLocalSurfaceToLightDirection = normalize(vLightModelPosition - transformed) ; //vvLocalSurfaceNormal = normalize(normal) ; vec3 vLocalSurfaceToViewerDirection = normalize(vViewModelPosition - transformed) ; vvLocalReflectedSurfaceToViewerDirection = normalize(reflect(vLocalSurfaceToViewerDirection, vvLocalSurfaceNormal)) ; gl_Position = projectionMatrix * mvPosition; // gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; }
//https://dominium.maksw.com/articles/physically-based-rendering-pbr/pbr-part-one/ //https://threejs.org/examples/webgl_materials_envmaps_parallax.html precision highp float; precision highp int; //uniform samplerCube cubeMap ; uniform sampler2D emissiveMap ; uniform sampler2D metalnessMap ; uniform sampler2D roughnessMap; uniform sampler2D lightMap; uniform sampler2D albedoMap ; uniform vec3 emissive ; uniform vec2 uvm ; uniform vec2 uvt ; uniform vec2 uvk ; uniform float reflect ; varying vec3 vViewModelPosition; varying vec3 vvLocalSurfaceNormal ; varying vec3 vvLocalSurfaceToLightDirection; varying vec3 vvLocalReflectedSurfaceToViewerDirection; //varying vec2 vuvCoord0 ; varying vec2 vUv ; uniform mat3 uvTransform; varying vec3 vvLocalSurfaceToViewerDirection; const float cpi = 3.141592653589793238462643383279502884 ; float computeFresnelTerm(float fZero, vec3 vSurfaceToViewerDirection, vec3 vSurfaceNormal) { float baseValue = 1.0 - dot(vSurfaceToViewerDirection, vSurfaceNormal); float exponential = pow(baseValue, 5.0) ; float fresnel = exponential + fZero * (1.0 - exponential) ; return fresnel ; } float chiGGX(float f) { return f > 0.0 ? 1.0 : 0.0 ; } float computeGGXDistribution(vec3 vSurfaceNormal, vec3 vSurfaceToLightDirection, float fRoughness) { float fNormalDotLight = clamp(dot(vSurfaceNormal, vSurfaceToLightDirection), 0.0, 1.0) ; float fNormalDotLightSquared = fNormalDotLight * fNormalDotLight ; float fRoughnessSquared = fRoughness * fRoughness ; float fDen = fNormalDotLightSquared * fRoughnessSquared + (1. - fNormalDotLightSquared); return clamp((chiGGX(fNormalDotLight) * fRoughnessSquared) / (cpi * fDen * fDen), 0.0, 1.0); } float computeGGXPartialGeometryTerm(vec3 vSurfaceToViewerDirection, vec3 vSurfaceNormal, vec3 vLightViewHalfVector, float fRoughness) { float fViewerDotLightViewHalf = clamp(dot(vSurfaceToViewerDirection, vLightViewHalfVector), 0.0, 1.0) ; float fChi = chiGGX(fViewerDotLightViewHalf / clamp(dot(vSurfaceToViewerDirection, vSurfaceNormal), 0.0, 1.0)); fViewerDotLightViewHalf *= fViewerDotLightViewHalf; float fTan2 = (1.0 - fViewerDotLightViewHalf) / fViewerDotLightViewHalf; return clamp((fChi * 2.0) / (1.0 + sqrt(1. + fRoughness * fRoughness * fTan2)), 0.0, 1.0) ; } void main(){ vec3 vNormalisedLocalSurfaceNormal = normalize(vvLocalSurfaceNormal) ; vec3 vNormalisedLocalSurfaceToLightDirection = normalize(vvLocalSurfaceToLightDirection) ; vec3 vNormalisedLocalReflectedSurfaceToViewerDirection = normalize(vvLocalReflectedSurfaceToViewerDirection) ; vec3 vNormalisedLocalSurfaceToViewerDirection = normalize(vvLocalSurfaceToViewerDirection) ; vec3 vLocalLightViewHalfVector = normalize(vNormalisedLocalSurfaceToLightDirection + vNormalisedLocalSurfaceToViewerDirection) ; float fLightIntensity = max(dot(vNormalisedLocalSurfaceToLightDirection, vNormalisedLocalSurfaceNormal), 0.0) ; float fMetalness = 1.;//texture2D(metalnessMap, vUv).r ; // float fRoughness = max(0.001, texture2D(roughnessMap, vUv).r ) ; // float fRoughness = texture2D(roughnessMap, vUv).r ; float fRoughness = max(0.001, texture2D(roughnessMap, fract(vec2(vUv.x ,vUv.y) )).r ) ; float distributionMicroFacet = computeGGXDistribution(vNormalisedLocalSurfaceNormal, vNormalisedLocalSurfaceToLightDirection, fRoughness) ; float geometryMicroFacet = computeGGXPartialGeometryTerm(vNormalisedLocalSurfaceToViewerDirection, vNormalisedLocalSurfaceNormal, vLocalLightViewHalfVector, fRoughness) ; float microFacetContribution = distributionMicroFacet * geometryMicroFacet ; float fLightSourceFresnelTerm = computeFresnelTerm(0.9, vNormalisedLocalSurfaceToViewerDirection, vNormalisedLocalSurfaceNormal) ; vec3 rgbAlbedo = vec3(1.);//texture2D(albedoMap, vUv).rgb ; vec3 rgbFragment = vec3(1.);//rgbAlbedo * (1.0 - fMetalness); // vec3 rgbSourceReflection = textureCubeLod(cubeMap, vNormalisedLocalReflectedSurfaceToViewerDirection, 9.0 * fRoughness).rgb ; vec4 emissiveColor ; vec2 uxv=vec2(vUv.x,vUv.y ); float s = (vViewModelPosition.z); float sy = (s-0.5)*2.; // uxv=vec2(fau.x * ( uxv.x-0.5 ) * ( 1./(1.+fau2.x*s) )+0.5 , fau4.y*( ( uxv.y-0.5 ) * ( 1./( 1. + (fau2.y*s) + (1.-s)*(fau3.y) ) ) + fau.y ) -1.); // vec2 uv_f=vec2(uxv.x,uxv.y ); uxv=vec2( 212. * ( uxv.x-0.5 ) * ( 1./(1.+200.*s) )+0.5 , 1. * ( uxv.y-0.5 ) * ( 1./( 1. + (5.*s) + (1.-s)*(-0.7) ) ) + 0.508 ); vec2 uv_f=vec2(1.-uxv.x,uxv.y*3.-1. ); //emissiveColor = texture2D( emissiveMap, uv_f, 9.0 * fRoughness);//0.75,1.,0.3,0.699 //emissiveColor = vec3(1.,1.,0.); emissiveColor = texture2D( emissiveMap, vec2(((1.-vUv.x)-0.493)*uvm.x* ( 1./(1.+(uvk.x+s)*uvt.x) )+0.5 , (vUv.y-0.5)*( 1./( 1. + uvt.y*(5.*s/600.) + (1.-s/600.)*uvm.y*(-0.7) ) )*uvk.y + 0.79 ), 9.0 * fRoughness); vec2 uv_L=vec2( ( ( vUv.x-0.5 ) * ( 1./(1.+0.5*(s)) )*1.93+0.5),(vUv.y-0.5)*1.11+0.5+0.045 ); vec4 lightm= texture2D( lightMap, uv_L, 9.0 * fRoughness); emissiveColor.rgb = emissive *(reflect*emissiveMapTexelToLinear( emissiveColor).rgb + (1.-reflect)*lightm.rgb); vec3 rgbSourceReflection = emissiveColor.rgb; vec3 rgbReflection = rgbSourceReflection ; // rgbReflection *= rgbAlbedo * fMetalness ; // rgbReflection *= fLightSourceFresnelTerm ; // rgbReflection = min(rgbReflection, rgbSourceReflection) ; // conservation of energy vec3 rgbSpecular = vec3(0.0) ; if (fLightIntensity > 0.0) { rgbSpecular = vec3(1.0) ; rgbSpecular *= microFacetContribution * fLightSourceFresnelTerm ; rgbSpecular = min(vec3(1.0), rgbSpecular) ; // conservation of energy } rgbFragment += rgbSpecular ; rgbFragment *= fLightIntensity ; rgbFragment += rgbReflection ; //rgbFragment =rgbFragment*0.4 0.6*lightm.rgb; gl_FragColor.rgb = rgbFragment ; gl_FragColor.a = 1.0 ; // TODO : Worry about materials which allow transparency! }
#define TIMESCALE 0.25 #define TILES 4 #define COLOR 0.7, 1.6, 2.8 vec2 n3mod289(vec2 x) { return x - floor(x * (1.0 / 289.0)) * 289.0; } vec3 n3mod289(vec3 x) { return x - floor(x * (1.0 / 289.0)) * 289.0; } vec4 n3mod289(vec4 x) { return x - floor(x * (1.0 / 289.0)) * 289.0; } vec4 permute(vec4 x) { return n3mod289(((x*34.0)+1.0)*x); } vec4 taylorInvSqrt(vec4 r) { return 1.79284291400159 - 0.85373472095314 * r; } float snoise(vec3 v) { const vec2 C = vec2(1.0/6.0, 1.0/3.0) ; const vec4 D = vec4(0.0, 0.5, 1.0, 2.0); // First corner vec3 i = floor(v + dot(v, C.yyy) ); vec3 x0 = v - i + dot(i, C.xxx) ; // Other corners vec3 g = step(x0.yzx, x0.xyz); vec3 l = 1.0 - g; vec3 i1 = min( g.xyz, l.zxy ); vec3 i2 = max( g.xyz, l.zxy ); // x0 = x0 - 0.0 + 0.0 * C.xxx; // x1 = x0 - i1 + 1.0 * C.xxx; // x2 = x0 - i2 + 2.0 * C.xxx; // x3 = x0 - 1.0 + 3.0 * C.xxx; vec3 x1 = x0 - i1 + C.xxx; vec3 x2 = x0 - i2 + C.yyy; // 2.0*C.x = 1/3 = C.y vec3 x3 = x0 - D.yyy; // -1.0+3.0*C.x = -0.5 = -D.y // Permutations i = n3mod289(i); vec4 p = permute( permute( permute( i.z + vec4(0.0, i1.z, i2.z, 1.0 )) + i.y + vec4(0.0, i1.y, i2.y, 1.0 )) + i.x + vec4(0.0, i1.x, i2.x, 1.0 )); // Gradients: 7x7 points over a square, mapped onto an octahedron. // The ring size 17*17 = 289 is close to a multiple of 49 (49*6 = 294) float n_ = 0.142857142857; // 1.0/7.0 vec3 ns = n_ * D.wyz - D.xzx; vec4 j = p - 49.0 * floor(p * ns.z * ns.z); // mod(p,7*7) vec4 x_ = floor(j * ns.z); vec4 y_ = floor(j - 7.0 * x_ ); // mod(j,N) vec4 x = x_ *ns.x + ns.yyyy; vec4 y = y_ *ns.x + ns.yyyy; vec4 h = 1.0 - abs(x) - abs(y); vec4 b0 = vec4( x.xy, y.xy ); vec4 b1 = vec4( x.zw, y.zw ); //vec4 s0 = vec4(lessThan(b0,0.0))*2.0 - 1.0; //vec4 s1 = vec4(lessThan(b1,0.0))*2.0 - 1.0; vec4 s0 = floor(b0)*2.0 + 1.0; vec4 s1 = floor(b1)*2.0 + 1.0; vec4 sh = -step(h, vec4(0.0)); vec4 a0 = b0.xzyw + s0.xzyw*sh.xxyy ; vec4 a1 = b1.xzyw + s1.xzyw*sh.zzww ; vec3 p0 = vec3(a0.xy,h.x); vec3 p1 = vec3(a0.zw,h.y); vec3 p2 = vec3(a1.xy,h.z); vec3 p3 = vec3(a1.zw,h.w); //Normalise gradients vec4 norm = taylorInvSqrt(vec4(dot(p0,p0), dot(p1,p1), dot(p2, p2), dot(p3,p3))); p0 *= norm.x; p1 *= norm.y; p2 *= norm.z; p3 *= norm.w; // Mix final noise value vec4 m = max(0.6 - vec4(dot(x0,x0), dot(x1,x1), dot(x2,x2), dot(x3,x3)), 0.0); m = m * m; return 42.0 * dot( m*m, vec4( dot(p0,x0), dot(p1,x1), dot(p2,x2), dot(p3,x3) ) ); } mat2 rotate2d(float _angle){ return mat2(cos(_angle),-sin(_angle), sin(_angle),cos(_angle)); } float fuzzy(float n,vec2 fn){ float exp1=fn.x; float exp2=fn.y; // m = (pow(n,exp1))/( (pow(n,exp1)) + pow( 1. - ( pow(n,exp2) ),exp1 ) ); return (pow(n,exp1))/( (pow(n,exp1)) + pow( 1. - ( pow(n,exp2) ),exp1 ) ); } uniform sampler2D texturex; uniform vec3 iResolution; uniform float uSpeed; uniform float uGlobalTime; uniform float uVolatility; uniform float uSeed; uniform float zoom; varying vec2 vUv; void main() { // vec2 fragCoord = vUv * iResolution.xy; vec2 uv = vUv*1.; // uv.x *= iResolution.x / iResolution.y; //vec4 noise = texture2D(texturex, uv ); float z = 200.*(300. + 5.*uGlobalTime * uSpeed); float duv = 5.*snoise(vec3(uv, z)) * uVolatility*uSeed; float duv2 = 3.*snoise(vec3(uv, z+313.4)) * uVolatility*uSeed; uv += duv; // move space from the center to the vec2(0.0) //vec2 st = uv; // rotate the space // uv -= vec2(0.5+3.*duv,0.5); // float fa=-sin(uGlobalTime)*5.*3.14 *uSeed*duv2; // uv = ( ( rotate2d( fa ) ) )* uv*(1.); // uv += vec2(0.5+3.*duv,0.5); // move it back to the original place // rotate the space // uv -= vec2(0.5,0.5+3.*duv2); // float fa2=sin(uGlobalTime)*7.*3.14 *uSeed*duv; // uv = ( ( rotate2d( fa2 ) ) )* uv*(1.); // uv += vec2(0.5,0.5+3.*duv2); // move it back to the original place // move space from the center to the vec2(0.0) //vec2 st = uv; uv -= vec2(0.5,0.5); // rotate the space float fa=sin(uGlobalTime)*4.*3.14*length(uv-0.5)*duv *uSeed; uv = ( ( rotate2d( fa ) ) )* uv*(1.+0.2*length(uv-0.5)*uSeed); // move it back to the original place uv += vec2(0.5,0.5); vec4 xz= texture2D(texturex, uv); gl_FragColor = vec4( xz.xyz,(1.-fuzzy( uSeed,vec2(0.5,8.)))*xz.w*(1.-uSeed*5.*length(uv-0.5) ) ); // gl_FragColor = vec4( xz.xyz,(1.-fuzzy( uSeed,vec2(0.5,8.)))*xz.w ); // gl_FragColor = vec4(noise.xyz, 1.0) ; //gl_FragColor = vec4(0.,1.,0., 1.0) ; }
#define TIMESCALE 0.25 #define TILES 4 #define COLOR 0.7, 1.6, 2.8 float fuzzy(float n,vec2 fn){ float exp1=fn.x; float exp2=fn.y; // m = (pow(n,exp1))/( (pow(n,exp1)) + pow( 1. - ( pow(n,exp2) ),exp1 ) ); return (pow(n,exp1))/( (pow(n,exp1)) + pow( 1. - ( pow(n,exp2) ),exp1 ) ); } uniform sampler2D texturex; uniform vec3 iResolution; uniform float uSpeed; uniform float uGlobalTime; uniform float uVolatility; uniform float uSeed; uniform float zoom; uniform float light; varying vec2 vUv; void main() { // vec2 fragCoord = vUv * iResolution.xy; vec2 uv = vUv*1.; // uv.x *= iResolution.x / iResolution.y; //vec4 noise = texture2D(texturex, uv ); vec4 xz= texture2D(texturex, uv); gl_FragColor = vec4( light*xz.xyz,(1.-fuzzy( uSeed,vec2(0.5,8.)))*xz.w*(1.-uSeed*5.*length(uv-0.5) ) ); }
varying vec2 vUv; uniform float zoom; void main() { // vUv = uv; // vUv=position.xy*0.5+0.5; vUv = uv; gl_Position = projectionMatrix * modelViewMatrix * vec4( position*(1.+zoom), 1.0 ); // gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); // gl_Position = vec4( position, 1.0 ); }
#define TIMESCALE 0.25 #define TILES 4 #define COLOR 0.7, 1.6, 2.8 uniform sampler2D texturex; uniform vec3 iResolution; uniform float uSpeed; uniform float uGlobalTime; uniform float uVolatility; uniform float uSeed; varying vec2 vUv; void main() { // vec2 fragCoord = vUv * iResolution.xy; vec2 uv = vUv*1.; vec4 xz= texture2D(texturex,vec2( 4.*(1.-uv.x )*uv.x , uv.y ) ); gl_FragColor = xz ; // gl_FragColor =vec4( xz.xyz,(1.-fuzzy( uSeed,vec2(0.5,8.)))*xz.w ); // // gl_FragColor = vec4(noise.xyz, 1.0) ; // // gl_FragColor = vec4(0.,1.,0., 1.0) ; }
//uniform sampler2D iChannelFLOW; uniform float iTime; uniform float k; uniform float l; uniform float dt; uniform float g; uniform float divfact; const float sizeGlob = 256.; const int PNUM = 200; vec4 T( vec2 U ) {return vec4(resolution.xy,1.,1.)*texture2D(iChannelFLOW,U/resolution.xy);} //vec4 T ( vec2 U ) {return vec4(840)*texture2D(iChannelFLOW,U/vec2(840.,472.));} void main(){ vec2 uv = gl_FragCoord.xy / resolution.xy; vec2 U = gl_FragCoord.xy; vec2 R = resolution.xy; // vec2 R = vec2(840.,472.); // vec2 U = gl_FragCoord.xy/resolution.xy*R; float dx=1.; // vec2 U = uv.xy; vec4 a = T((U+vec2(dx,0.))); vec4 b = T((U+vec2(0.,dx))); vec4 c = T((U+vec2(-dx,0.))); vec4 d = T((U+vec2(0.,-dx))); vec2 vu= T((U-dt*T(U).xy)).xy; vec4 Q = T((U-dt*vu)); vec2 gp = vec2(a.z-c.z,b.z-d.z);//pressure gradient vec2 gw = vec2(a.w-c.w,b.w-d.w);//density gradient float r = (1.+10.*Q.w)*.1;//*dt; vec2 f = r*k*gp - l*gw + r*Q.w*g*vec2(0.,-1.); //f*=20.*dt; float p = 0.25*(a.z+b.z+c.z+d.z); float div = (c.x-a.x+d.y-b.y);//divergence Q.xyz = vec3(Q.x+f.x,Q.y+f.y,p - divfact*div)*.998; //Q.z= max(Q.z,-20.); if (iTime < 1.) Q = vec4(0.); if (U.x < 1.||U.y < 1.||R.x-U.x < -1.||R.y-U.y < 1.) Q.xy *= 0.; if (U.x < 0.1*R.x&&U.y < 0.4*R.y) Q.xy *= 0.; if (U.x < 0.4*R.x&&U.y < 0.2*R.y) Q.xy *= 0.; if (length(U-vec2(0.,0.8*R.y)) < 15.) {Q.xy= Q.xy*.5+resolution.xy*.5*vec2(1.+1.5*sin(1.5*iTime),0.); Q.w = 1.+0.2*sin(1.2*iTime);}; // Q.w=1.; // Q.z=0.; // Q.xy = gl_FragCoord.xy / 512.; // gl_FragColor = xz; gl_FragColor = Q/vec4(resolution.xy,1.,1.); }
//uniform sampler2D iChannelFLOW; uniform float iTime; uniform float dt ; uniform float K ; uniform float L ; uniform float nu ; uniform float kappa ; uniform float g ; uniform float q ; const float sizeGlob = 256.; const int PNUM = 200; vec4 T(vec2 p) {return texture2D(iChannelFLOW,(p));} void main(){ vec2 uv = gl_FragCoord.xy / resolution.xy; // vec2 p = gl_FragCoord.xy; // vec2 R = resolution.xy; vec2 R = vec2(840.,472.); vec2 p = gl_FragCoord.xy/resolution.xy*R; vec4 c = T(p/R); vec4 n = T((p + vec2(0.,1.))/R); vec4 e = T((p + vec2(1.,0.))/R); vec4 s = T((p - vec2(0.,1.))/R); vec4 w = T((p - vec2(1.,0.))/R); vec4 laplacian = (n + e + s + w - 4.*c); vec4 dx = (e - w)/2.; vec4 dy = (n - s)/2.; // velocity field divergence float div = dx.x + dy.y; // mass conservation, Euler method step c.z -= q*dt*(dx.z * c.x + dy.z * c.y + div * c.z); // semi-Langrangian advection vec2 vu = T((p-dt*c.xy)/R).xy; c.xyw = T((p - dt*vu.xy)/R).xyw; // viscosity/diffusion c.xyw += dt * vec3(nu,nu,kappa) * laplacian.xyw; // nullify divergence with pressure field gradient c.xy -= K * vec2(dx.z,dy.z)- L * vec2(dx.w,dy.w) + vec2(0.,g)*c.w; // external source if (iTime < 1.) c = vec4(0.); if (p.x < 1.||p.y < 1.||R.x-p.x < -1.||R.y-p.y < 1.) c.xy *= 0.; if (p.x < 0.1*R.x&&p.y < 0.4*R.y) c.xy *= 0.; if (p.x < 0.4*R.x&&p.y < 0.2*R.y) c.xy *= 0.; if (length(p-vec2(0.,0.8*R.y)) < 8.) {c.xy= c.xy*.5+1.5*vec2(1.+0.4*sin(1.5*iTime),0.); c.w = 1.+0.2*sin(1.2*iTime);}; // dissipation c.xyz *= 0.9998; c.w *= 1.0003; c.xyzw = clamp(c.xyzw, vec4(-15.,-15.,0.8,0.), vec4(15.,15.,15.,15.)); // c=vec4(uv, 0., 1.); gl_FragColor = c; }
#define TIMESCALE 0.25 #define TILES 4 #define COLOR 0.7, 1.6, 2.8 uniform sampler2D texturex; uniform vec3 iResolution; uniform float uSpeed; uniform float uGlobalTime; uniform float uVolatility; uniform float uSeed; varying vec2 vUv; void main() { // vec2 fragCoord = vUv * iResolution.xy; vec2 uv = vUv*1.; vec4 xz= texture2D(texturex,vec2( uv.x , uv.y ) ); gl_FragColor = vec4(uVolatility*xz.xyz ,1.); // gl_FragColor =vec4( xz.xyz,(1.-fuzzy( uSeed,vec2(0.5,8.)))*xz.w ); // // gl_FragColor = vec4(noise.xyz, 1.0) ; // // gl_FragColor = vec4(0.,1.,0., 1.0) ; }
#define TIMESCALE 0.25 #define TILES 4 #define COLOR 0.7, 1.6, 2.8 uniform sampler2D texturex; uniform sampler2D iChannel0; uniform vec2 iResolution; uniform float uSpeed; uniform float uGlobalTime; uniform float uVolatility; uniform float uSeed; varying vec2 vUv; vec4 T1( vec2 U ) {return texture2D(iChannel0,U);} void main() { vec2 fragCoord = vUv * iResolution.xy; vec2 uv = vUv*1.; vec4 xz= texture2D(texturex,vec2( uv.x , uv.y ) ); //vec2 uv2= gl_FragCoord.xy / iResolution.xy; float k = min(T1(uv).w, 0.4); vec4 C = 0.2+0.8*sin(k*vec4(8.,12.,16.,1.)); //gl_FragColor = vec4(uVolatility*xz.xyz ,1.); gl_FragColor = C; gl_FragColor = texture2D(iChannel0,uv.xy); // gl_FragColor.w=1.; // gl_FragColor =vec4( xz.xyz,(1.-fuzzy( uSeed,vec2(0.5,8.)))*xz.w ); // // gl_FragColor = vec4(noise.xyz, 1.0) ; // gl_FragColor = vec4(vUv,0., 1.0) ; }
float EPSILON = 0.002; vec2 twist = vec2(2.0,7.0); float planesDistance = 0.3; vec4 bumpMapParams1 = vec4(2.0,7.0,0.01,-0.01); vec4 bumpMapParams2 = vec4(2.0,3.0,-0.01,0.01); vec4 heightMapParams = vec4(3.0,1.0,0.0,0.01); vec4 heightInfluence = vec4(-0.025,-0.05,0.8,1.8); float fogDensity = 0.2; float fogDistance = 0.1; vec3 groundColor1 = vec3(0.2,0.3,0.3); vec3 groundColor2 = vec3(0.4,0.8,0.4); vec3 columnColors = vec3(0.9,0.3,0.3); vec4 ambient = vec4(0.2,0.3,0.4,0.0); vec3 lightColor = vec3(0.4,0.7,0.7); vec4 fogColor = vec4(0.0,0.1,0.5,1.0); vec3 rimColor = vec3(1.0,0.75,0.75); float pi = 3.14159265359; #define DRAG_MULT 0.048 #define ITERATIONS_RAYMARCH 13 #define ITERATIONS_NORMAL 48 #define WATER_DEPTH 0.3 //#define Mouse (iMouse.xy / iResolution.xy) //#define Resolution (iResolution.xy) //#define Time (iTime) uniform sampler2D texturex; uniform sampler2D iChannel0; uniform vec3 iResolution; uniform float uSpeed; uniform float uGlobalTime; uniform float uVolatility; uniform float uSeed; varying vec2 vUv; // returns vec2 with wave height in X and its derivative in Y vec3 getatm(vec3 ray, float roughness){ vec3 sharp = mix(vec3( 0.0293, 0.0698, 0.1717) * 10.0, vec3(3.0), pow(1.0 - ray.y, 8.0)); vec3 rough = vec3(vec3( 0.0293, 0.0698, 0.1717) + vec3(1.0)); return mix(sharp, rough, roughness); } float sun(vec3 ray){ return pow(max(0.0, dot(ray, normalize(vec3(1.0, 1.0, 0.0)))), 668.0) * 110.0; } mat2 rot(float a) { vec2 s = sin(vec2(a, a + pi/2.0)); return mat2(s.y,s.x,-s.x,s.y); } float smin( float a, float b, float k ) { float h = clamp( 0.5+0.5*(b-a)/k, 0.0, 1.0 ); return mix( b, a, h ) - k*h*(1.0-h); } float sphere(vec3 pos, float radius, vec3 scale) { return length(pos*scale)-radius; } float heightmap(vec2 uv) { return heightMapParams.x*texture2D(iChannel0, (uv + uGlobalTime*heightMapParams.zw)*heightMapParams.y).x; } vec2 wavedx(vec2 position, vec2 direction, float speed, float frequency, float timeshift) { float x = dot(direction, position) * frequency + timeshift * speed; float wave = exp(sin(x) - 1.0); float dx = wave * cos(x); return vec2(wave, -dx); } float getwaves(vec3 position, int iterations){ float iter = 0.0; float phase = 6.0; float speed = 2.0; float weight = 1.0; float w = 0.0; float ws = 0.0; vec3 pos=position; vec3 p2 = pos; p2.x += sin(p2.z*3.0 + p2.y*5.0)*0.15; p2.xy *= rot(floor(p2.z*2.0)*twist.y); pos.xy *= rot(pos.z*twist.x); float h = heightmap(pos.xz)*heightInfluence.x; vec3 columnsrep = vec3(0.75,1.0,0.5); vec3 reppos = (mod(p2 + vec3(uGlobalTime*0.01 + sin(pos.z*0.5),0.0,0.0),columnsrep)-0.5*columnsrep); float columnsScaleX = 1.0 + sin(p2.y*20.0*sin(p2.z) + uGlobalTime*5.0 + pos.z)*0.15; float columnsScaleY = (sin(uGlobalTime + pos.z*4.0)*0.5+0.5); float columns = sphere(vec3(reppos.x, pos.y+0.25, reppos.z), 0.035, vec3(columnsScaleX,columnsScaleY,columnsScaleX)); float corridor = planesDistance - abs(pos.y) + h; float d = smin(corridor, columns, 0.25); for(int i=0;i < ITERATIONS_RAYMARCH;i++){ vec2 p = vec2(sin(iter), cos(iter)); vec2 res = wavedx(pos.xz, p, speed, phase, uGlobalTime); pos.xz += (normalize(p) * res.y * weight * DRAG_MULT); w += res.x * weight; iter += 12.0; ws += weight; weight = mix(weight, 0.0, 0.2); phase *= 1.18; speed *= 1.07; } return d+abs(WATER_DEPTH*(w / ws)-0.5*WATER_DEPTH); } float H = 0.0; //vec3 normal(vec2 pos, float e, float depth){ // vec2 ex = vec2(e, 0); // H = getwaves(pos.xy * 0.1, ITERATIONS_NORMAL) * depth; // vec3 a = vec3(pos.x, H, pos.y); // return normalize(cross(normalize(a-vec3(pos.x - e, getwaves(pos.xy * 0.1 - ex.xy * 0.1, ITERATIONS_NORMAL) * depth, pos.y)), // normalize(a-vec3(pos.x, getwaves(pos.xy * 0.1 + ex.yx * 0.1, ITERATIONS_NORMAL) * depth, pos.y + e)))); //} mat3 rotmat(vec3 axis, float angle) { axis = normalize(axis); float s = sin(angle); float c = cos(angle); float oc = 1.0 - c; return mat3(oc * axis.x * axis.x + c, oc * axis.x * axis.y - axis.z * s, oc * axis.z * axis.x + axis.y * s, oc * axis.x * axis.y + axis.z * s, oc * axis.y * axis.y + c, oc * axis.y * axis.z - axis.x * s, oc * axis.z * axis.x - axis.y * s, oc * axis.y * axis.z + axis.x * s, oc * axis.z * axis.z + c); } float intersectPlane(vec3 origin, vec3 direction, vec3 point, vec3 normal) { return clamp(dot(point - origin, normal) / dot(direction, normal), -1.0, 9991999.0); } float bumpmap(vec2 uv) { float b1 = bumpMapParams1.x*(1.0 - texture2D(iChannel0, (uv + uGlobalTime*bumpMapParams1.zw)*bumpMapParams1.y).x); float b2 = bumpMapParams2.x*(1.0-texture2D(iChannel0, (uv + uGlobalTime*bumpMapParams2.zw)*bumpMapParams2.x).x); return b1+b2; } float distfunc(vec3 pos) { vec3 p2 = pos; p2.x += sin(p2.z*3.0 + p2.y*5.0)*0.15; p2.xy *= rot(floor(p2.z*2.0)*twist.y); pos.xy *= rot(pos.z*twist.x); float h = heightmap(pos.xz)*heightInfluence.x; vec3 columnsrep = vec3(0.75,1.0,0.5); vec3 reppos = (mod(p2 + vec3(uGlobalTime*0.01 + sin(pos.z*0.5),0.0,0.0),columnsrep)-0.5*columnsrep); float columnsScaleX = 1.0 + sin(p2.y*20.0*sin(p2.z) + uGlobalTime*5.0 + pos.z)*0.15; float columnsScaleY = (sin(uGlobalTime + pos.z*4.0)*0.5+0.5); float columns = sphere(vec3(reppos.x, pos.y+0.25, reppos.z), 0.035, vec3(columnsScaleX,columnsScaleY,columnsScaleX)); float corridor = planesDistance - abs(pos.y) + h; float d = smin(corridor, columns, 0.25); return d; } float raymarchwater(vec3 camera, vec3 start, vec3 end, float depth,vec3 ray){ vec3 pos = start; float h = 0.0; float hupper = depth; float hlower = 0.0; vec2 zer = vec2(0.0); vec3 dir = normalize(end - start); //for(int i=0;i < 318;i++){ // h = getwaves(pos.xz * 0.1, ITERATIONS_RAYMARCH) * depth - depth; // if(h + 0.01 > pos.y) { // return distance(pos, camera); // } // pos += dir * (pos.y - h); //} //return -1.0; // const int MAX_ITER = 50; const float MAX_DIST = 30.0; float totalDist = 0.0; float totalDist2 = 0.0; //vec3 pos = cameraOrigin; float dist = EPSILON; vec3 col = vec3(0.0); float glow = 0.0; for(int j = 0; j < MAX_ITER; j++) { //dist = distfunc(pos); dist = getwaves(pos, ITERATIONS_RAYMARCH) ; totalDist = totalDist + dist; pos += dist*ray; if(dist < EPSILON || totalDist > MAX_DIST) { break; } } return totalDist ; } float rayMarch(vec3 rayDir, vec3 cameraOrigin) { const int MAX_ITER = 50; const float MAX_DIST = 30.0; float totalDist = 0.0; float totalDist2 = 0.0; vec3 pos = cameraOrigin; float dist = EPSILON; vec3 col = vec3(0.0); float glow = 0.0; for(int j = 0; j < MAX_ITER; j++) { dist = distfunc(pos); totalDist = totalDist + dist; pos += dist*rayDir; if(dist < EPSILON || totalDist > MAX_DIST) { break; } } return totalDist ; } //Taken from https://www.shadertoy.com/view/Xds3zN mat3 setCamera( in vec3 ro, in vec3 ta, float cr ) { vec3 cw = normalize(ta-ro); vec3 cp = vec3(sin(cr), cos(cr),0.0); vec3 cu = normalize( cross(cw,cp) ); vec3 cv = normalize( cross(cu,cw) ); return mat3( cu, cv, cw ); } vec3 calculateNormals(vec3 pos) { vec2 eps = vec2(0.0, EPSILON*1.0); vec3 n = normalize(vec3( distfunc(pos + eps.yxx) - distfunc(pos - eps.yxx), distfunc(pos + eps.xyx) - distfunc(pos - eps.xyx), distfunc(pos + eps.xxy) - distfunc(pos - eps.xxy))); return n; } //Taken from https://www.shadertoy.com/view/XlXXWj vec3 doBumpMap(vec2 uv, vec3 nor, float bumpfactor) { const float eps = 0.001; float ref = bumpmap(uv); vec3 grad = vec3(bumpmap(vec2(uv.x-eps, uv.y))-ref, 0.0, bumpmap(vec2(uv.x, uv.y-eps))-ref); grad -= nor*dot(nor, grad); return normalize( nor + grad*bumpfactor ); } void main() { vec3 cameraOrigin = vec3(0.0, 0.0, uGlobalTime*-0.1); vec3 cameraTarget = cameraOrigin + vec3(0.0, 0.0, 1.0);; // vec2 screenPos = (fragCoord.xy/iResolution.xy)*2.0-1.0; // screenPos.x *= iResolution.x/iResolution.y; vec2 screenPos=vUv*2.0-1.0; screenPos.x *= iResolution.x/iResolution.y; mat3 cam = setCamera(cameraOrigin, cameraTarget, 0.0 ); vec3 rayDir = cam* normalize( vec3(screenPos.xy,2.0) ); rayDir.xy *= rot(uGlobalTime*0.1); float dist = rayMarch(rayDir, cameraOrigin); vec3 pos = cameraOrigin + dist*rayDir; vec2 uv = pos.xy * rot(pos.z*twist.x); float h = heightmap(vec2(uv.x, pos.z)); // vec3 n = calculateNormals(pos); // vec3 bump = doBumpMap(vec2(uv.x, pos.z), n, 3.0); // float m = smoothstep(-0.15,0.2, planesDistance - abs(uv.y) + h*heightInfluence.y + sin(uGlobalTime)*0.05); // vec3 color = mix(mix(groundColor1, groundColor2, smoothstep(heightInfluence.z,heightInfluence.w,h)), columnColors, m); // float fog = dist*fogDensity-fogDistance; // float heightfog = pos.y; // float rim = (1.0-max(0.0, dot(-normalize(rayDir), bump))); // vec3 lightPos = pos - (cameraOrigin + vec3(0.0,0.0,1.0)); // vec3 lightDir = -normalize(lightPos); // float lightdist = length(lightPos); // float atten = 1.0 / (1.0 + lightdist*lightdist*3.0); // float light = max(0.0, dot(lightDir, bump)); // vec3 r = reflect(normalize(rayDir), bump); // float spec = clamp (dot (r, lightDir),0.0,1.0); // float specpow = pow(spec,20.0); // vec3 c = color*(ambient.xyz + mix(rim*rim*rim, rim*0.35+0.65, m)*rimColor + lightColor*(light*atten*2.0 + specpow*1.5)); // vec4 res = mix(vec4(c, rim), fogColor, clamp(fog+heightfog,0.0,1.0)); vec3 ray=rayDir; vec3 wfloor = vec3(0.0, -WATER_DEPTH, 0.0); vec3 wceil = vec3(0.0, 0.0, 0.0); vec3 orig = cameraOrigin; float hihit = intersectPlane(orig, ray, wceil, vec3(0.0, 1.0, 0.0)); float lohit = intersectPlane(orig, ray, wfloor, vec3(0.0, 1.0, 0.0)); vec3 hipos = orig + ray * hihit; vec3 lopos = orig + ray * lohit; float dist2 = raymarchwater(orig, hipos, lopos, WATER_DEPTH,ray); vec3 pos2 = orig + ray * dist2; // vec3 N = normal(pos2.xz, 0.01, WATER_DEPTH); vec3 N = calculateNormals(pos2); vec2 velocity = N.xz * (1.0 - N.y); vec3 R = reflect(ray, N); float roughness = 1.0 - 1.0 / (dist2 * 0.01 + 1.0); N = normalize(mix(N, vec3(0.0, 1.0, 0.0), roughness)); R = normalize(mix(R, N, roughness)); R.y = abs(R.y); float fresnel = (0.04 + (1.0-0.04)*(pow(1.0 - max(0.0, dot(-N, ray)), 5.0))); vec3 C = fresnel * (getatm(R, roughness) + sun(R)) * 2.0; gl_FragColor = vec4(C,1.); }
#define TIMESCALE 0.25 #define TILES 4 #define COLOR 0.7, 1.6, 2.8 // uniform sampler2D iChannel0; uniform vec3 iResolution; uniform float uSpeed; uniform float uGlobalTime; uniform float uVolatility; uniform float uSeed; uniform float opacity; //varying vec2 vUv; //#define time uGlobalTime*0.1 precision highp float; precision highp int; //uniform samplerCube cubeMap ; uniform sampler2D emissiveMap ; uniform sampler2D emissiveMap2 ; uniform sampler2D metalnessMap ; uniform sampler2D roughnessMap; uniform sampler2D lightMap; uniform sampler2D albedoMap ; uniform vec3 emissive ; uniform vec2 uvm ; uniform vec2 uvt ; uniform vec2 uvk ; uniform float reflect ; uniform float switchx; varying vec3 vViewModelPosition; varying vec3 vvLocalSurfaceNormal ; varying vec3 vvLocalSurfaceToLightDirection; varying vec3 vvLocalReflectedSurfaceToViewerDirection; //varying vec2 vuvCoord0 ; varying vec2 vUv ; uniform mat3 uvTransform; varying vec3 vvLocalSurfaceToViewerDirection; varying float normals; const float cpi = 3.141592653589793238462643383279502884 ; //________________________________________________________________ //________________________________________________________________ //________________________________________________________________ float computeFresnelTerm(float fZero, vec3 vSurfaceToViewerDirection, vec3 vSurfaceNormal) { float baseValue = 1.0 - dot(vSurfaceToViewerDirection, vSurfaceNormal); float exponential = pow(baseValue, 5.0) ; float fresnel = exponential + fZero * (1.0 - exponential) ; return fresnel ; } float chiGGX(float f) { return f > 0.0 ? 1.0 : 0.0 ; } float computeGGXDistribution(vec3 vSurfaceNormal, vec3 vSurfaceToLightDirection, float fRoughness) { float fNormalDotLight = clamp(dot(vSurfaceNormal, vSurfaceToLightDirection), 0.0, 1.0) ; float fNormalDotLightSquared = fNormalDotLight * fNormalDotLight ; float fRoughnessSquared = fRoughness * fRoughness ; float fDen = fNormalDotLightSquared * fRoughnessSquared + (1. - fNormalDotLightSquared); return clamp((chiGGX(fNormalDotLight) * fRoughnessSquared) / (cpi * fDen * fDen), 0.0, 1.0); } float computeGGXPartialGeometryTerm(vec3 vSurfaceToViewerDirection, vec3 vSurfaceNormal, vec3 vLightViewHalfVector, float fRoughness) { float fViewerDotLightViewHalf = clamp(dot(vSurfaceToViewerDirection, vLightViewHalfVector), 0.0, 1.0) ; float fChi = chiGGX(fViewerDotLightViewHalf / clamp(dot(vSurfaceToViewerDirection, vSurfaceNormal), 0.0, 1.0)); fViewerDotLightViewHalf *= fViewerDotLightViewHalf; float fTan2 = (1.0 - fViewerDotLightViewHalf) / fViewerDotLightViewHalf; return clamp((fChi * 2.0) / (1.0 + sqrt(1. + fRoughness * fRoughness * fTan2)), 0.0, 1.0) ; } float hash21(in vec2 n){ return fract(sin(dot(n, vec2(12.9898, 4.1414))) * 43758.5453); } mat2 makem2(in float theta){float c = cos(theta);float s = sin(theta);return mat2(c,-s,s,c);} //float noise( in vec2 x ){return texture2D(iChannel0, x*.01).x;} //vec2 gradn(vec2 p) //{ // float ep = .09; // float gradx = noise(vec2(p.x+ep,p.y))-noise(vec2(p.x-ep,p.y)); // float grady = noise(vec2(p.x,p.y+ep))-noise(vec2(p.x,p.y-ep)); // return vec2(gradx,grady); //} float rand(vec2 st) { // float a = 12.9898; // float b = 78.233; // float c = 43758.5453; // float dt= dot(co.xy ,vec2(a,b)); // float sn= mod(dt,3.14); // return fract(sin(sn) * c); return fract(sin(dot(st.xy,vec2(12.9898,78.233)))*43758.5453123); } vec3 permute(vec3 x) { return mod(((x*34.0)+1.0)*x, 289.0); } float snoise(vec2 v){ const vec4 C = vec4(0.211324865405187, 0.366025403784439, -0.577350269189626, 0.024390243902439); vec2 i = floor(v + dot(v, C.yy) ); vec2 x0 = v - i + dot(i, C.xx); vec2 i1; i1 = (x0.x > x0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0); vec4 x12 = x0.xyxy + C.xxzz; x12.xy -= i1; i = mod(i, 289.0); vec3 p = permute( permute( i.y + vec3(0.0, i1.y, 1.0 )) + i.x + vec3(0.0, i1.x, 1.0 )); vec3 m = max(0.5 - vec3(dot(x0,x0), dot(x12.xy,x12.xy), dot(x12.zw,x12.zw)), 0.0); m = m*m ; m = m*m ; vec3 x = 2.0 * fract(p * C.www) - 1.0; vec3 h = abs(x) - 0.5; vec3 ox = floor(x + 0.5); vec3 a0 = x - ox; m *= 1.79284291400159 - 0.85373472095314 * ( a0*a0 + h*h ); vec3 g; g.x = a0.x * x0.x + h.x * x0.y; g.yz = a0.yz * x12.xz + h.yz * x12.yw; return 130.0 * dot(m, g); } void main() { vec2 uv = vUv*1.; vec3 vNormalisedLocalSurfaceNormal = (-vvLocalSurfaceNormal) ; vec3 vNormalisedLocalSurfaceToLightDirection = (vvLocalSurfaceToLightDirection) ; vec3 vNormalisedLocalReflectedSurfaceToViewerDirection = (vvLocalReflectedSurfaceToViewerDirection) ; vec3 vNormalisedLocalSurfaceToViewerDirection = normalize(vvLocalSurfaceToViewerDirection) ; vec3 vLocalLightViewHalfVector = normalize(vNormalisedLocalSurfaceToLightDirection + vNormalisedLocalSurfaceToViewerDirection) ; // vNormalisedLocalSurfaceToLightDirection.y*=0.01; // vNormalisedLocalSurfaceNormal.y*=0.01; float fLightIntensity = max(dot(normalize(vNormalisedLocalSurfaceToLightDirection), normalize(vNormalisedLocalSurfaceNormal)), 0.0) ; // float fMetalness = 0.; float fMetalness = texture2D(metalnessMap, fract(uvm*vec2(vUv.x ,uGlobalTime*0.1+vUv.y))).r ; //float noise=texture2D(iChannel0, fract(uvm*vec2(vUv))).x; float noise=rand( floor(100.*(uvm*vec2(floor(uGlobalTime)*0.7+vUv.x ,floor(uGlobalTime)+vUv.y)))) ; // float fRoughness = max(0.001, texture2D(roughnessMap, vUv).r ) ; // float fRoughness = 1. ; float fRoughness = max(0.001, texture2D(roughnessMap, fract(uvm*vec2(vUv.x ,uGlobalTime*0.1+vUv.y) )).r ) ; float distributionMicroFacet = computeGGXDistribution(vNormalisedLocalSurfaceNormal, vNormalisedLocalSurfaceToLightDirection, fRoughness) ; float geometryMicroFacet = computeGGXPartialGeometryTerm(vNormalisedLocalSurfaceToViewerDirection, vNormalisedLocalSurfaceNormal, vLocalLightViewHalfVector, fRoughness) ; float microFacetContribution = distributionMicroFacet * geometryMicroFacet ; float fLightSourceFresnelTerm = computeFresnelTerm(9.9, vNormalisedLocalSurfaceToViewerDirection, vNormalisedLocalSurfaceNormal) ; vec3 rgbAlbedo=vec3(0.) ; if(switchx > 0.02 && switchx < 0.98) rgbAlbedo = 0.7*texture2D( emissiveMap2, fract(uvm*vec2(vUv.x ,uGlobalTime*0.1+vUv.y) )).rgb*switchx+(1.-switchx)*texture2D( emissiveMap, fract(uvm*vec2(vUv.x ,uGlobalTime*0.1+vUv.y) )).rgb ; else if(switchx <= 0.02) rgbAlbedo = texture2D( emissiveMap, fract(uvm*vec2(vUv.x ,uGlobalTime*0.1+vUv.y) )).rgb; else rgbAlbedo = 0.7*texture2D( emissiveMap2, fract(uvm*vec2(vUv.x ,uGlobalTime*0.1+vUv.y) )).rgb; vec3 rgbFragment = rgbAlbedo * (1.0 - fMetalness); // vec3 rgbSourceReflection = textureCubeLod(cubeMap, vNormalisedLocalReflectedSurfaceToViewerDirection, 9.0 * fRoughness).rgb ; //vec4 emissiveColor ; //emissiveColor = vec4(1.);//texture2D( emissiveMap, fract(uvm*vec2(vUv.x ,uGlobalTime*0.1+vUv.y) ));//0.75,1.,0.3,0.699 //emissiveColor = vec3(1.,1.,0.); //emissiveColor = texture2D( emissiveMap, vec2(((1.-vUv.x)-0.493)*uvm.x* ( 1./(1.+(uvk.x+s)*uvt.x) )+0.5 , (vUv.y-0.5)*( 1./( 1. + uvt.y*(5.*s/600.) + (1.-s/600.)*uvm.y*(-0.7) ) )*uvk.y + 0.79 ), 9.0 * fRoughness); //vec2 uv_L=vec2( ( ( vUv.x-0.5 ) * ( 1./(1.+0.5*(s)) )*1.93+0.5),(vUv.y-0.5)*1.11+0.5+0.045 ); //vec4 lightm= texture2D( lightMap, uv_L, 9.0 * fRoughness); //emissiveColor.rgb = emissive *(reflect*emissiveMapTexelToLinear( emissiveColor).rgb + (1.-reflect)*lightm.rgb); // emissiveColor.rgb = emissive * emissiveMapTexelToLinear( emissiveColor).rgb ; // vec3 rgbSourceReflection = rgbAlbedo*fMetalness; float fresnel2 = computeFresnelTerm(0.1, vNormalisedLocalSurfaceToViewerDirection, vNormalisedLocalSurfaceNormal); vec3 rgbReflection = rgbAlbedo*fMetalness; // rgbReflection *= fMetalness ; rgbReflection *= fLightSourceFresnelTerm * 0.2; //rgbReflection = min(rgbReflection, rgbSourceReflection) ; // conservation of energy vec3 rgbSpecular = vec3(0.0) ; if (fLightIntensity > 0.0) { float rr=rand( vec2(vUv.x-uGlobalTime*0.7 ,uGlobalTime+vUv.y)); if(noise*rr>0.4){ rgbSpecular = vec3(1.0) ; rgbSpecular *= microFacetContribution * fLightSourceFresnelTerm *opacity; rgbSpecular = rgbSpecular*fMetalness*noise;// min(vec3(1.0), rgbSpecular) ; // conservation of energy } } float luce_spec=( 10.*(1.-reflect) + reflect ); rgbFragment += luce_spec*vec3(0.3)*microFacetContribution * fresnel2 ; rgbFragment += luce_spec*rgbSpecular; rgbFragment *= (fLightIntensity+(normals))*reflect ; rgbFragment += rgbReflection*(reflect*0.6+0.4) ; // rgbFragment =vec3( rgbSpecular ) ; // rgbFragment *= 0.4*fLightIntensity ; // rgbFragment += rgbSpecular ; // rgbFragment += rgbReflection ; //rgbFragment =rgbFragment*0.4 0.6*lightm.rgb; //faufres gl_FragColor.rgb = rgbFragment ; gl_FragColor.a = 1. ; // TODO : Worry about materials which allow transparency! // gl_FragColor.rgb = (1.+normalize(vvLocalSurfaceToLightDirection))/2.; //gl_FragColor.rgb = vec3( (fLightIntensity+(normals))/2.); // gl_FragColor.rgb = vec3(computeFresnelTerm(0.4, vNormalisedLocalSurfaceToViewerDirection, vNormalisedLocalSurfaceNormal)); // gl_FragColor.rgb = (1.+normalize(-vNormalisedLocalSurfaceNormal))/2.; // gl_FragColor*=fres+((vec4(1.0)-fres)*absorb*vec4(scatter))+((vec4(1.0)-fres)*absorb*vec4(1.0-scatter));; //________________________ //________________________ //________________________ //________________________ }
uniform vec3 iResolution; uniform float uGlobalTime; // uniform sampler2D iChannel0; uniform sampler2D normalMap; uniform vec2 normalScale; uniform float normalStrong; uniform float complex; uniform vec2 uvm ; uniform float uSeed; uniform float uSpeed; uniform float uVolatility; uniform float debug; precision highp float; varying vec3 vViewModelPosition; varying vec3 vvLocalSurfaceNormal ; varying vec3 vvLocalSurfaceToLightDirection; varying vec3 vvLocalReflectedSurfaceToViewerDirection; varying vec3 vvLocalSurfaceToViewerDirection; //varying vec2 vuvCoord0 ; uniform mat3 uvTransform; uniform vec3 glLightPosition; uniform vec2 uvt; varying vec2 vUv; varying float normals; const float pi = 3.141592653589793238462643383279502884 ; mat2 rotate2d(float _angle){ return mat2(cos(_angle),-sin(_angle), sin(_angle),cos(_angle)); } mat3 rotate3d(float _angle,vec3 axis){ return mat3( cos(_angle) + axis.x*axis.x*( 1.-cos(_angle) ), axis.y*axis.x * (1. - cos(_angle) ) -axis.z*sin(_angle) , axis.z*axis.x * (1. - cos(_angle) ) +axis.y*sin(_angle) , axis.y*axis.x * (1. - cos(_angle) ) +axis.z*sin(_angle) , cos(_angle) + axis.y*axis.y*( 1.-cos(_angle) ), axis.z*axis.x * (1. - cos(_angle) ) -axis.x*sin(_angle) , axis.z*axis.x * (1. - cos(_angle) ) -axis.y*sin(_angle) , axis.z*axis.x * (1. - cos(_angle) ) +axis.x*sin(_angle) , cos(_angle) + axis.z*axis.z*( 1.-cos(_angle) ) ); } //________________________________________________________________ //________________________________________________________________ //________________________________________________________________ const float MAX_GRADIENT = 55.0; // should be actual maximum rate of change of GetHeight() #define DEBUG_MAX_GRADIENT 0 // make MAX_GRADIENT as low as possible without letting any white appear float GetHeight( vec2 uv ) { if ( uv.x < 0.0 ) return 1.0; float updown = sin( uv.x * 12.0 + -1.*uGlobalTime * 0.6 ) * mix( 1.0, 0.2, uv.x ) * 0.12; float yspread = (uv.y - 0.5) * mix( 1.0, 0.1, uv.x ) + 0.5; //float yspread = (uv.y ); float leftright = sin( ( + updown) * 20.0 ); float checker = sin( (uv.x + -1.*uGlobalTime * 0.05) * 40.0 ) * sin( uv.y * 10.0 -1.*uGlobalTime * 1.0 ) * 0.5 + 0.5; float yCenterToEdge = sin(3.14/2.*((uv.y - 0.5) / 0.5)); yCenterToEdge *= yCenterToEdge; float xpow = mix( 0.17, 0.25, yCenterToEdge ); float phase = fract( pow( uv.x, xpow ) * 40.0 + leftright * 0.32 + checker * 0.2 + -1.*uGlobalTime * 0.1 * 1.4 ); //phase = phase * phase; float wave = cos( phase * 2.0 * 3.14159 ) * 0.5 + 0.5; //wave += cos( phase * 2.0 * 3.14159 * 14.0 ) * 0.005; //wave = pow( wave, 4.0 ); float height = mix( 1.0, wave, pow( uv.x, 0.8 ) ); return height; } const float BUMP_STRENGTH = 0.03; float GetUnshadowedLightFrac( vec2 uv, float startHeight, vec3 lightDir ) { const float SOFT_SHADOW_SLOPE = 4.0; const float DIST_THRESHOLD = 0.001; lightDir /= length( lightDir.xy ); // MAX_GRADIENT is in XY direction only lightDir.z /= BUMP_STRENGTH; vec3 pos = vec3( uv, startHeight ) + lightDir * DIST_THRESHOLD; float traveledDist = DIST_THRESHOLD; float softShadowAmount = 1.0; for ( int step = 0; step < 5; step++ ) { float height = GetHeight( pos.xy ); if ( height > pos.z ) return 0.0; float diff = pos.z - height; softShadowAmount = min( diff / (SOFT_SHADOW_SLOPE * traveledDist), softShadowAmount ); float minDistToHit = diff / MAX_GRADIENT + DIST_THRESHOLD; traveledDist += minDistToHit; pos += lightDir * minDistToHit; if ( pos.z > 1.0 + SOFT_SHADOW_SLOPE ) break; } return softShadowAmount; } vec3 Color( float x ) { const vec3 c0 = vec3( 1.0, 0.8, 0.5 ) * 1.8; const vec3 c1 = vec3( 1.0, 0.5, 0.25 ) * 1.1; const vec3 c2 = vec3( 0.5, 0.15, 0.4 ) * 0.8; const vec3 c3 = vec3( 0.2, 0.04, 0.35 ) * 0.5; const vec3 c4 = vec3( 0.001, 0.003, 0.05 ); if ( x < 0.4 ) { if ( x < 0.1 ) return mix( c0, c1, x / 0.1 ); else return mix( c1, c2, (x - 0.1) / 0.3 ); } else { if ( x < 0.6 ) return mix( c2, c3, (x - 0.4) / 0.2 ); else { x = min( x, 1.0 ); return mix( c3, c4, (x - 0.6) / 0.4 ); } } } float sinsin( vec2 uv ) { return min( abs( sin( uv.x ) * sin( uv.y ) ) * 1.2, 1.0 ); } float Glitter( vec2 uv ) { uv *= 0.8; uv.x *= iResolution.x / iResolution.y; uv.x += sin( uv.y * 20.0 ) * 0.03; float x = sinsin( (uv.xx * vec2( 0.64, 0.77 ) + uv.yy * vec2( 0.77, -0.64 )) * 300.0 ); x *= sinsin( (uv.xx * vec2( 0.34, 0.94 ) + uv.yy * vec2( 0.94, -0.34 )) * 211.0 ); x *= sinsin( (uv.xx * vec2( 0.99, 0.12 ) + uv.yy * vec2( 0.12, -0.99 )) * 73.0 ); // return x; // to see what's going on here return pow( x * 1.015, 100.0 ); } //________________________________________________________________ //________________________________________________________________ //________________________________________________________________ mat2 rot(float a) { vec2 s = sin(vec2(a, a + pi/2.0)); return mat2(s.y,s.x,-s.x,s.y); } ////______________________________________________ float hash(int n) { return fract(sin(float(n) + 1.951) * 43758.5453123); } float noise(vec3 x) { vec3 p = floor(x); vec3 f = fract(x); f = f*f*(vec3(3.0) - vec3(2.0) * f); float n = p.x + p.y*57.0 + 113.0*p.z; return mix( mix( mix(hash(int(n + 0.0)), hash(int(n + 1.0)), f.x), mix(hash(int(n + 57.0)), hash(int(n + 58.0)), f.x), f.y), mix( mix(hash(int(n + 113.0)), hash(int(n + 114.0)), f.x), mix(hash(int(n + 170.0)), hash(int(n + 171.0)), f.x), f.y), f.z); } float computeW(float d,vec3 px,float cellCountx,vec3 wxx){ vec3 pCell = px * cellCountx; vec3 tp = floor(pCell) + vec3(wxx.x, wxx.y, wxx.z); tp = pCell - tp - noise(mod(tp, cellCountx / 1.0)); float dx = min(d, dot(tp, tp)); return dx; } float cells(vec3 p, float cellCount) { float d = 1.0e10; float dH = 1.0e10; float dV = 1.0e10; float diff=0.08; for (int xo = -1; xo <= 1; xo++) { for (int yo = -1; yo <= 1; yo++) { for (int zo = -1; zo <= 1; zo++) { //vec3 tp = floor(pCell) + vec3(xo, yo, zo); //tp = pCell - tp - noise(mod(tp, cellCount / 1.0)); //d = min(d, dot(tp, tp)); d = computeW(d,p,cellCount,vec3(xo, yo, zo)); //dH = computeW( dH, vec3(p.x+diff,p.y,p.z), cellCount, vec3(xo, yo, zo) ); //dV = computeW( dV, vec3(p.x,p.y+diff,p.z), cellCount, vec3(xo, yo, zo) ); } } } d = min(d, 1.0); d = max(d, 0.0); return d; } // From GLM (gtc/noise.hpp & detail/_noise.hpp) vec4 mod289(vec4 x) { return x - floor(x * vec4(1.0) / vec4(289.0)) * vec4(289.0); } vec4 permute(vec4 x) { return mod289(((x * 34.0) + 1.0) * x); } vec4 taylorInvSqrt(vec4 r) { return vec4(1.79284291400159) - vec4(0.85373472095314) * r; } vec4 fade(vec4 t) { return (t * t * t) * (t * (t * vec4(6) - vec4(15)) + vec4(10)); } float remap(float originalValue, float originalMin, float originalMax, float newMin, float newMax) { return newMin + (((originalValue - originalMin) / (originalMax - originalMin)) * (newMax - newMin)); } // ====================================================================== float worleyNoise3D(vec3 p, float cellCount) { return cells(p, cellCount); } float stackable3DNoise(float pixelz) { //float ar = float(iResolution.x) / float(iResolution.y); //vec3 coord = vec3(uv.x,uv.y, (pixelz) / 128.0); vec3 coord = vec3(fract(vec2(uvt.x*vUv.x,uGlobalTime*0.3+uvt.y*vUv.y)), (pixelz) / 128.0); // 3 octaves float cellCount = 2.0; float worleyNoise0 = (1.0 - worleyNoise3D(coord, cellCount * 1.0)); float worleyNoise1 = (1.0 - worleyNoise3D(coord, cellCount * 2.0)); // vec3 worleyNoise2 = (1.0 - worleyNoise3D(coord, cellCount * 4.0)); // vec3 worleyNoise3 = (1.0 - worleyNoise3D(coord, cellCount * 8.0)); float worleyFBM0 = worleyNoise0*0.75 + worleyNoise1*0.25;; // vec3 worleyFBM0 = worleyNoise0*0.625 + worleyNoise1*0.25 + worleyNoise2*0.125; // vec3 worleyFBM1 = worleyNoise1*0.625 + worleyNoise2*0.25 + worleyNoise3*0.125; // vec3 worleyFBM2 = worleyNoise2*0.75 + worleyNoise2*0.25; // cellCount=4 -> worleyNoise4 is just noise due to sampling frequency=texel freque. So only take into account 2 frequencies for FBM return worleyFBM0; } //____________________ //____________________ #define TAU 6.28318530718 #define MAX_ITER 2 //____________________ #define SCALE_WATER 3.0 #define SCALE_HIGHLIGHTS 1.0 // Simplex 2D noise vec3 permute(vec3 x) { return mod(((x*34.0)+1.0)*x, 289.0); } float snoise(vec2 v){ const vec4 C = vec4(0.211324865405187, 0.366025403784439, -0.577350269189626, 0.024390243902439); vec2 i = floor(v + dot(v, C.yy) ); vec2 x0 = v - i + dot(i, C.xx); vec2 i1; i1 = (x0.x > x0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0); vec4 x12 = x0.xyxy + C.xxzz; x12.xy -= i1; i = mod(i, 289.0); vec3 p = permute( permute( i.y + vec3(0.0, i1.y, 1.0 )) + i.x + vec3(0.0, i1.x, 1.0 )); vec3 m = max(0.5 - vec3(dot(x0,x0), dot(x12.xy,x12.xy), dot(x12.zw,x12.zw)), 0.0); m = m*m ; m = m*m ; vec3 x = 2.0 * fract(p * C.www) - 1.0; vec3 h = abs(x) - 0.5; vec3 ox = floor(x + 0.5); vec3 a0 = x - ox; m *= 1.79284291400159 - 0.85373472095314 * ( a0*a0 + h*h ); vec3 g; g.x = a0.x * x0.x + h.x * x0.y; g.yz = a0.yz * x12.xz + h.yz * x12.yw; return 130.0 * dot(m, g); } float avg(vec4 color) { return (color.r + color.g + color.b)/3.0; } vec2 rep(vec2 v) { return abs(fract(v)-0.5); } vec4 waterTexture(vec2 uv) { float noise = snoise(rep(uv)*SCALE_WATER); noise = noise * 0.15 + 0.10; return vec4(vec3(noise), 1.); } vec4 highlightsTexture(vec2 uv) { float noise = snoise(rep(uv)*SCALE_HIGHLIGHTS); noise = noise * 0.40 + 0.08; return vec4(vec3(noise), 1.); } vec4 getFlatColor(vec2 uv, float time) { float speed = 1.1; float opacity = 0.5; vec4 water1 = waterTexture(fract(uv*debug) + time*0.02*speed - 0.1); vec4 water2 = waterTexture(uv.xy + time*speed*vec2(-0.02, -0.02) + 0.1); vec4 highlights1 = highlightsTexture(uv.xy + time*speed / vec2(-10, 100)); vec4 highlights2 = highlightsTexture(uv.xy + time*speed / vec2(10, 100)); water1.rgb = vec3(avg(water1)); water2.rgb = vec3(avg(water2)); highlights1.rgb = vec3(avg(highlights1)/1.5); highlights2.rgb = vec3(avg(highlights2)/1.5); float alpha = 0.0; if(avg(water1 + water2 + highlights1 + highlights2) > uVolatility) { alpha = (avg(water1 + water2 + highlights1 + highlights2)-uVolatility)/uSpeed; } return vec4(alpha); } //____________________ //____________________ float fuzzy(float n,vec2 fn){ float exp1=fn.x; float exp2=fn.y; float z1=pow(n,exp1); float z2=pow(n,exp2); return (z1)/( (z1) + pow( 1. - ( z2 ),exp1 ) ); } //____________________ void main() { float y_norm = (1.+(position.y)/(iResolution.y))/2.;//(position.y+iResolution.y)/(iResolution.y*2.); float x_norm = (1.+(position.x)/(iResolution.y))/2.; float z_norm = (1.+(position.z)/(iResolution.y))/2.; float smorza3=pow(1.-y_norm,0.8)+0.1; vec3 dpos=vec3( 0. ); float yfakt=sin(16.9*y_norm + uGlobalTime*.5+3.14*sin( 3.14*(uv.x) ) ); float rfakt=cos(uGlobalTime*.01+16.9*y_norm ) + 3.7*cos(uGlobalTime*0.007+(2.54*z_norm)); float kfakt=3.*sin(uGlobalTime*0.01+(1.4*y_norm)) +2.5*cos(uGlobalTime*.04+(2.14*y_norm)) -3.3*cos(uGlobalTime*.06+(1.814*y_norm)) ; //float rotfakt=4.2*cos(uGlobalTime*0.003+(0.84*x_norm)) +1.3*sin(uGlobalTime*.05+(2.14*x_norm)) -3.3*cos(uGlobalTime*.03+(0.514*x_norm)) ; float rotfakt2=1.7*cos(uGlobalTime*0.01+(2.54*z_norm)) +1.2*sin(uGlobalTime*.03+(1.14*x_norm)) -3.2*cos(uGlobalTime*.04+(2.514*z_norm)) ; vec3 pos=position ; pos.xz *= rot(0.6*kfakt); //pos.yz *= rot(0.6*rotfakt); //pos.xy *= rot(0.2*rotfakt2); // pos=rotate3d(0.2*(kfakt), normalize(vec3(kfakt,0.,0.)) )*rotate3d(0.2*(rotfakt2), normalize(vec3(0.,0.,rotfakt2)) )*rotate3d(0.2*(rotfakt), normalize(vec3(rotfakt,0.,0.)) ) * pos; //pos=rotate3d( rotfakt*kfakt*rotfakt2*0.03, normalize(vec3(rotfakt,kfakt,rotfakt2)) )*pos; vUv = vec2( uv ); float z_norm_fin = (1.+(pos.z)/(iResolution.y))/2.; if(z_norm_fin < 0.87){ float sa = 0.83-z_norm_fin;if(sa < 0.) sa=0.; float smorza_x= pow(sa,0.4) ; float smorza_x2= pow(length(vec2(x_norm-0.5,z_norm-0.5)),0.4); ; //pos.xz *= (1.+smorza_x)*rot(0.6*kfakt); vec3 norm_pos=vec3(normalize(pos)); dpos.x =-smorza_x* smorza_x2*(360.*(-2.+yfakt+rfakt) * norm_pos.x);//+ smorza3*smorza*yfakt*iResolution.x*0.18 ; dpos.y =smorza_x* smorza_x2*(complex*(rotfakt2) * norm_pos.y);//+ smorza3*smorza*yfakt*iResolution.x*0.18 ; dpos.z =-smorza_x* smorza_x2*(360.*(-2.+yfakt+rfakt) * norm_pos.z );//+ smorza3*smorza*yfakt*iResolution.x*0.18 ; pos+=dpos; // vec3 dpos3= vec3(0.); // float smorza_x3= pow((1.-length(vec2(x_norm-0.5,z_norm-0.5))) ,1.); ; // vec2 rott = smorza_x3*vec2( 0., iResolution.y*0.8);//*rot(1.*kfakt); // dpos3.x+= rott.x; // dpos3.z+= rott.y; // dpos3.y+= smorza_x3*50.*(y_norm-0.5); // float voro= texture2D(texturex,vec2( fract(uv.x*130.) ,fract(-uGlobalTime*2.+ uv.y*130.) ) ).x; // pos-=voro*nor*8. - n*10.; //______________ //______________ //______________ //______________ float holes = getFlatColor(vUv, uGlobalTime*0.5).x; //______________ //______________ //______________ //______________ //uv -= vec2(0.5,0.5); // rotate the space //float fa=sin(uGlobalTime)*4.*3.14*length(uv-0.5)*duv *uSeed; //uv = ( ( rotate2d( fa ) ) )* uv*(1.+0.2*length(uv-0.5)*uSeed); // move it back to the original place //uv += vec2(0.5,0.5); vec2 cyl_fact=0.9*vec2(iResolution.x,iResolution.z)/iResolution.z+1.5*vec2( pow( (z_norm_fin+0.2) / 1.2 , 0.8) ); pos= pos*vec3(cyl_fact,1.+1.2*pow( (1.- z_norm_fin) , 0.7)); vec3 normalm = texture2D(normalMap, fract(normalScale*vec2(vUv.x ,uGlobalTime*0.1+vUv.y))).rgb ; vec3 nor = normalize( pos - vec3(0.,0.,0.)) ; ////pos-=nor*normalStrong*normalm; //vec3 n = normal; float z = uSeed; vec3 n = vec3(stackable3DNoise(z),0.,0.); pos+= smorza_x*nor*1500.*(1.-n.x); vec3 nrml=vec3(n.y - n.x,n.z - n.x,0.); nor+=(nor*normalStrong*normalize(normalm.rbg * 2.0 - 1.0))*smorza_x2; normals=n.x; if(holes>0.03){ if(holes>1.)holes=1.; vec3 nor2 = normalize( normalize( pos - vec3( 0. , 0. , 0. ) )+vec3( 0. , n.x*(holes) + normalize(pos).y ,-( 1.-z_norm) ) ); // pos-= smorza_x2*nor2*430.*fuzzy(holes,vec2(1.4,1.));//time pos-= smorza_x*smorza_x2*nor2*1500.*holes;//*fuzzy(holes,vec2(1.4,1.));//time normals+=smorza_x*smorza_x2*holes;//fuzzy(holes,vec2(1.4,1.)); } vec3 transformed = vec3( pos ); // normals=(normalize(nor)+1.)/2.; vec3 normalx = (nor); vec3 objectNormal = vec3( normalx.x, normalx.y, normalx.z ); vec3 transformedNormal = objectNormal; transformedNormal = normalMatrix * transformedNormal; //*** vvLocalSurfaceNormal = normalize( transformedNormal ); //*** vec4 mvPosition = vec4( transformed.xyz, 1.0 ); mvPosition = modelViewMatrix * mvPosition; vViewModelPosition = - mvPosition.xyz; // vec3 vViewModelPosition = vec3(gl_ModelViewMatrixInverse * vec4(0, 0, 0, 1.0)); // vec3 vLightModelPosition = (gl_ModelViewMatrixInverse * gl_LightSource[0].position).xyz; //vec3 vViewModelPosition = vec4(gl_ModelViewMatrixInverse * vec4(0., 0., 0., 1.0)).xyz; // vvLocalSurfaceToViewerDirection = (1.+normalize(vec3(transformed.r,0.,transformed.b) ) )/2.; //*** vvLocalSurfaceToViewerDirection = normalize( vViewModelPosition - transformed ) ; //*** //faufres //glLightPosition=vec3(0.,10.,-700.); //vec3 vLightModelPosition = (glLightPosition).xyz; //glLightPositionX.z+=(y_norm-0.5)*2.*debug; vec3 vLightModelPosition = (normalMatrix * glLightPosition.xyz).xyz; // vec3 vLightModelPosition = ( glLightPosition.xyz).xyz; //*** vvLocalSurfaceToLightDirection = normalize(vLightModelPosition - transformed) ; //*** // normals=abs(vvLocalSurfaceNormal); //normals=abs(vvLocalSurfaceToLightDirection); //normals=abs(vec3(dot(vvLocalSurfaceToLightDirection,vvLocalSurfaceNormal))); //vvLocalSurfaceNormal = normalize(normalx) ; vec3 vLocalSurfaceToViewerDirection = normalize(vViewModelPosition - transformed) ; vvLocalReflectedSurfaceToViewerDirection = normalize(reflect(vLocalSurfaceToViewerDirection, vvLocalSurfaceNormal)) ; gl_Position = projectionMatrix * mvPosition; //vec3 final=vec3(transformed); //normals=z_norm_fin; // final = rotate3d(0.2*rotfakt*smorza*smorza5,normalize(vec3(1.,0.,z_norm))) * final ; // gl_Position = projectionMatrix * modelViewMatrix * vec4( final , 1.0 ); } }
#define TIMESCALE 0.25 #define TILES 4 #define COLOR 0.7, 1.6, 2.8 uniform sampler2D texturex; uniform vec3 iResolution; uniform float uSpeed; uniform float uGlobalTime; uniform float uVolatility; uniform vec2 uvt; uniform float uSeed; varying vec2 vUv; varying vec3 vViewModelPosition; void main() { // vec2 fragCoord = vUv * iResolution.xy; vec2 uv = vUv*1.; float s = (vViewModelPosition.z)/(600.); // vec4 xz= texture2D(texturex,vec2( uv.x , uv.y ) ); vec2 uv_L=vec2( ( ( vUv.x-0.5 ) * ( 1./(1.+0.495*(s)) )*1.875+0.5),(vUv.y-0.5)*0.945+0.5+0.+0.024+uvt.y ); // vec4 lightm= texture2D( lightMap, uv_L, 9.0 * fRoughness); vec4 xz= texture2D(texturex,uv_L ); gl_FragColor = vec4(uVolatility*xz.xyz ,1.); // gl_FragColor =vec4( xz.xyz,(1.-fuzzy( uSeed,vec2(0.5,8.)))*xz.w ); // // gl_FragColor = vec4(noise.xyz, 1.0) ; // // gl_FragColor = vec4(0.,1.,0., 1.0) ; }
#define TIMESCALE 0.25 #define TILES 4 #define COLOR 0.7, 1.6, 2.8 uniform sampler2D texturex; uniform vec3 iResolution; uniform float uSpeed; uniform float uGlobalTime; uniform float uVolatility; uniform float uSeed; uniform float repeat; varying vec2 vUv; void main() { // vec2 fragCoord = vUv * iResolution.xy; vec2 uv = vUv*1.; if(vUv.y < uSeed ){ vec4 xz= texture2D(texturex, vec2(fract(uv.x*repeat+uGlobalTime),fract(uv.y*repeat))); // gl_FragColor =vec4( (1. - step(xz.xyz,vec3(0.1) )) , uSeed*xz.w); gl_FragColor =vec4( xz.xyz, uVolatility*xz.w); } }
#define TIMESCALE 0.25 #define TILES 4 #define COLOR 0.7, 1.6, 2.8 uniform sampler2D texturex; uniform vec3 iResolution; uniform float uSpeed; uniform float uGlobalTime; uniform float uVolatility; uniform float uSeed; varying vec2 vUv; void main() { // vec2 fragCoord = vUv * iResolution.xy; vec2 uv = vUv*1.; vec4 xz= texture2D(texturex, uv); gl_FragColor =vec4( (1. - step(xz.xyz,vec3(0.1) )) , uSeed*xz.w); }
varying vec2 vUv; void main() { vUv = uv; gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); }
#define TIMESCALE 0.25 #define TILES 4 #define COLOR 0.7, 1.6, 2.8 vec2 n3mod289(vec2 x) { return x - floor(x * (1.0 / 289.0)) * 289.0; } vec3 n3mod289(vec3 x) { return x - floor(x * (1.0 / 289.0)) * 289.0; } vec4 n3mod289(vec4 x) { return x - floor(x * (1.0 / 289.0)) * 289.0; } vec4 permute(vec4 x) { return n3mod289(((x*34.0)+1.0)*x); } vec4 taylorInvSqrt(vec4 r) { return 1.79284291400159 - 0.85373472095314 * r; } float snoise(vec3 v) { const vec2 C = vec2(1.0/6.0, 1.0/3.0) ; const vec4 D = vec4(0.0, 0.5, 1.0, 2.0); // First corner vec3 i = floor(v + dot(v, C.yyy) ); vec3 x0 = v - i + dot(i, C.xxx) ; // Other corners vec3 g = step(x0.yzx, x0.xyz); vec3 l = 1.0 - g; vec3 i1 = min( g.xyz, l.zxy ); vec3 i2 = max( g.xyz, l.zxy ); // x0 = x0 - 0.0 + 0.0 * C.xxx; // x1 = x0 - i1 + 1.0 * C.xxx; // x2 = x0 - i2 + 2.0 * C.xxx; // x3 = x0 - 1.0 + 3.0 * C.xxx; vec3 x1 = x0 - i1 + C.xxx; vec3 x2 = x0 - i2 + C.yyy; // 2.0*C.x = 1/3 = C.y vec3 x3 = x0 - D.yyy; // -1.0+3.0*C.x = -0.5 = -D.y // Permutations i = n3mod289(i); vec4 p = permute( permute( permute( i.z + vec4(0.0, i1.z, i2.z, 1.0 )) + i.y + vec4(0.0, i1.y, i2.y, 1.0 )) + i.x + vec4(0.0, i1.x, i2.x, 1.0 )); // Gradients: 7x7 points over a square, mapped onto an octahedron. // The ring size 17*17 = 289 is close to a multiple of 49 (49*6 = 294) float n_ = 0.142857142857; // 1.0/7.0 vec3 ns = n_ * D.wyz - D.xzx; vec4 j = p - 49.0 * floor(p * ns.z * ns.z); // mod(p,7*7) vec4 x_ = floor(j * ns.z); vec4 y_ = floor(j - 7.0 * x_ ); // mod(j,N) vec4 x = x_ *ns.x + ns.yyyy; vec4 y = y_ *ns.x + ns.yyyy; vec4 h = 1.0 - abs(x) - abs(y); vec4 b0 = vec4( x.xy, y.xy ); vec4 b1 = vec4( x.zw, y.zw ); //vec4 s0 = vec4(lessThan(b0,0.0))*2.0 - 1.0; //vec4 s1 = vec4(lessThan(b1,0.0))*2.0 - 1.0; vec4 s0 = floor(b0)*2.0 + 1.0; vec4 s1 = floor(b1)*2.0 + 1.0; vec4 sh = -step(h, vec4(0.0)); vec4 a0 = b0.xzyw + s0.xzyw*sh.xxyy ; vec4 a1 = b1.xzyw + s1.xzyw*sh.zzww ; vec3 p0 = vec3(a0.xy,h.x); vec3 p1 = vec3(a0.zw,h.y); vec3 p2 = vec3(a1.xy,h.z); vec3 p3 = vec3(a1.zw,h.w); //Normalise gradients vec4 norm = taylorInvSqrt(vec4(dot(p0,p0), dot(p1,p1), dot(p2, p2), dot(p3,p3))); p0 *= norm.x; p1 *= norm.y; p2 *= norm.z; p3 *= norm.w; // Mix final noise value vec4 m = max(0.6 - vec4(dot(x0,x0), dot(x1,x1), dot(x2,x2), dot(x3,x3)), 0.0); m = m * m; return 42.0 * dot( m*m, vec4( dot(p0,x0), dot(p1,x1), dot(p2,x2), dot(p3,x3) ) ); } mat3 rotate3d(float _angle,vec3 axis){ return mat3( cos(_angle) + axis.x*axis.x*( 1.-cos(_angle) ), axis.y*axis.x * (1. - cos(_angle) ) -axis.z*sin(_angle) , axis.z*axis.x * (1. - cos(_angle) ) +axis.y*sin(_angle) , axis.y*axis.x * (1. - cos(_angle) ) +axis.z*sin(_angle) , cos(_angle) + axis.y*axis.y*( 1.-cos(_angle) ), axis.z*axis.x * (1. - cos(_angle) ) -axis.x*sin(_angle) , axis.z*axis.x * (1. - cos(_angle) ) -axis.y*sin(_angle) , axis.z*axis.x * (1. - cos(_angle) ) +axis.x*sin(_angle) , cos(_angle) + axis.z*axis.z*( 1.-cos(_angle) ) ); } mat2 rotate2d(float _angle){ return mat2(cos(_angle),-sin(_angle), sin(_angle),cos(_angle)); } float fuzzy(float n,vec2 fn){ float exp1=fn.x; float exp2=fn.y; // m = (pow(n,exp1))/( (pow(n,exp1)) + pow( 1. - ( pow(n,exp2) ),exp1 ) ); return (pow(n,exp1))/( (pow(n,exp1)) + pow( 1. - ( pow(n,exp2) ),exp1 ) ); } uniform sampler2D texturex; uniform vec3 iResolution; uniform float uSpeed; uniform float uGlobalTime; uniform float uVolatility; uniform float uSeed; varying vec3 vViewModelPosition; varying vec3 vvLocalSurfaceNormal ; varying vec3 vvLocalSurfaceToLightDirection; varying vec3 vvLocalReflectedSurfaceToViewerDirection; varying vec3 vvLocalSurfaceToViewerDirection; //varying vec2 vuvCoord0 ; uniform mat3 uvTransform; uniform vec3 glLightPosition; varying vec2 vUv; const float cpi = 3.141592653589793238462643383279502884 ; void main() { vUv = uv; vUv = ( uvTransform * vec3( uv, 1 ) ).xy; vec2 uvp=vUv.xy; uvp -= vec2(0.5,0.5); // rotate the space // float fa=sin(uGlobalTime)*4.*3.14*length(uvp-0.5)*uSeed; float fa=sin(uGlobalTime)*4.*3.14; //uvp = ( ( rotate2d( fa ) ) )* uvp;//*(1.+0.2*length(uvp-0.5)*uSeed); vec3 posz = rotate3d(0.01*uGlobalTime*length(vec3(0.,0.,2.)-position)*length(vec3(0.,0.,2.)-position),normalize(vec3(0.,0.,1.)))*(position); // move it back to the original place //uvp += vec2(0.5,0.5); //vUv = uvp; // uvp=vUv ; // vec3 posz = vec3(sin(uvp.x*2.*cpi),sin(uvp.y*2.*cpi),cos(uvp.x*2.*cpi)); // gl_Position = projectionMatrix * modelViewMatrix * vec4( position.xyz*posz, 1.0 ); // vec3 posz = (vec3(sin(uvp.y*2.*cpi)*cos(uvp.x*2.*cpi),cos(uvp.y*2.*cpi),sin(uvp.y*2.*cpi)*sin(uvp.x*2.*cpi))); // float z = 200.*(300. + 5.*uGlobalTime * uSpeed); float duv = 5.*snoise(vec3(position)) * uVolatility*uSeed; // float duv2 = 3.*snoise(vec3(uvp, z+313.4)) * uVolatility*uSeed; vec3 posi2=vec3( posz+0.2*normal*(duv + length(position-vec3(0.,0.,2.))*length(position-vec3(0.,0.,2.)) ) ); //vec3 posi2=position; vec3 objectNormal = vec3( normal ); vec3 transformedNormal = objectNormal; transformedNormal = normalMatrix * transformedNormal; vvLocalSurfaceNormal = normalize( transformedNormal ); vec3 transformed = vec3( posi2 ); vec4 mvPosition = vec4( transformed, 1.0 ); mvPosition = modelViewMatrix * mvPosition; vViewModelPosition = - mvPosition.xyz; // vec3 vViewModelPosition = vec3(gl_ModelViewMatrixInverse * vec4(0, 0, 0, 1.0)); // vec3 vLightModelPosition = (gl_ModelViewMatrixInverse * gl_LightSource[0].position).xyz; //vec3 vViewModelPosition = vec4(gl_ModelViewMatrixInverse * vec4(0., 0., 0., 1.0)).xyz; vvLocalSurfaceToViewerDirection = normalize(vViewModelPosition - transformed) ; //glLightPosition=vec3(0.,10.,-700.); vec3 vLightModelPosition = (glLightPosition).xyz; vvLocalSurfaceToLightDirection = (vLightModelPosition - transformed) ; //vvLocalSurfaceNormal = normalize(normal) ; vec3 vLocalSurfaceToViewerDirection = normalize(vViewModelPosition - transformed) ; vvLocalReflectedSurfaceToViewerDirection = normalize(reflect(vLocalSurfaceToViewerDirection, vvLocalSurfaceNormal)) ; gl_Position = projectionMatrix * modelViewMatrix * vec4(posi2,1.); }
#define TIMESCALE 0.25 #define TILES 4 #define COLOR 0.7, 1.6, 2.8 precision highp float; precision highp int; vec2 n3mod289(vec2 x) { return x - floor(x * (1.0 / 289.0)) * 289.0; } vec3 n3mod289(vec3 x) { return x - floor(x * (1.0 / 289.0)) * 289.0; } vec4 n3mod289(vec4 x) { return x - floor(x * (1.0 / 289.0)) * 289.0; } vec4 permute(vec4 x) { return n3mod289(((x*34.0)+1.0)*x); } vec4 taylorInvSqrt(vec4 r) { return 1.79284291400159 - 0.85373472095314 * r; } float snoise(vec3 v) { const vec2 C = vec2(1.0/6.0, 1.0/3.0) ; const vec4 D = vec4(0.0, 0.5, 1.0, 2.0); // First corner vec3 i = floor(v + dot(v, C.yyy) ); vec3 x0 = v - i + dot(i, C.xxx) ; // Other corners vec3 g = step(x0.yzx, x0.xyz); vec3 l = 1.0 - g; vec3 i1 = min( g.xyz, l.zxy ); vec3 i2 = max( g.xyz, l.zxy ); // x0 = x0 - 0.0 + 0.0 * C.xxx; // x1 = x0 - i1 + 1.0 * C.xxx; // x2 = x0 - i2 + 2.0 * C.xxx; // x3 = x0 - 1.0 + 3.0 * C.xxx; vec3 x1 = x0 - i1 + C.xxx; vec3 x2 = x0 - i2 + C.yyy; // 2.0*C.x = 1/3 = C.y vec3 x3 = x0 - D.yyy; // -1.0+3.0*C.x = -0.5 = -D.y // Permutations i = n3mod289(i); vec4 p = permute( permute( permute( i.z + vec4(0.0, i1.z, i2.z, 1.0 )) + i.y + vec4(0.0, i1.y, i2.y, 1.0 )) + i.x + vec4(0.0, i1.x, i2.x, 1.0 )); // Gradients: 7x7 points over a square, mapped onto an octahedron. // The ring size 17*17 = 289 is close to a multiple of 49 (49*6 = 294) float n_ = 0.142857142857; // 1.0/7.0 vec3 ns = n_ * D.wyz - D.xzx; vec4 j = p - 49.0 * floor(p * ns.z * ns.z); // mod(p,7*7) vec4 x_ = floor(j * ns.z); vec4 y_ = floor(j - 7.0 * x_ ); // mod(j,N) vec4 x = x_ *ns.x + ns.yyyy; vec4 y = y_ *ns.x + ns.yyyy; vec4 h = 1.0 - abs(x) - abs(y); vec4 b0 = vec4( x.xy, y.xy ); vec4 b1 = vec4( x.zw, y.zw ); //vec4 s0 = vec4(lessThan(b0,0.0))*2.0 - 1.0; //vec4 s1 = vec4(lessThan(b1,0.0))*2.0 - 1.0; vec4 s0 = floor(b0)*2.0 + 1.0; vec4 s1 = floor(b1)*2.0 + 1.0; vec4 sh = -step(h, vec4(0.0)); vec4 a0 = b0.xzyw + s0.xzyw*sh.xxyy ; vec4 a1 = b1.xzyw + s1.xzyw*sh.zzww ; vec3 p0 = vec3(a0.xy,h.x); vec3 p1 = vec3(a0.zw,h.y); vec3 p2 = vec3(a1.xy,h.z); vec3 p3 = vec3(a1.zw,h.w); //Normalise gradients vec4 norm = taylorInvSqrt(vec4(dot(p0,p0), dot(p1,p1), dot(p2, p2), dot(p3,p3))); p0 *= norm.x; p1 *= norm.y; p2 *= norm.z; p3 *= norm.w; // Mix final noise value vec4 m = max(0.6 - vec4(dot(x0,x0), dot(x1,x1), dot(x2,x2), dot(x3,x3)), 0.0); m = m * m; return 42.0 * dot( m*m, vec4( dot(p0,x0), dot(p1,x1), dot(p2,x2), dot(p3,x3) ) ); } mat2 rotate2d(float _angle){ return mat2(cos(_angle),-sin(_angle), sin(_angle),cos(_angle)); } mat3 rotate3d(float _angle,vec3 axis){ return mat3( cos(_angle) + axis.x*axis.x*( 1.-cos(_angle) ), axis.y*axis.x * (1. - cos(_angle) ) -axis.z*sin(_angle) , axis.z*axis.x * (1. - cos(_angle) ) +axis.y*sin(_angle) , axis.y*axis.x * (1. - cos(_angle) ) +axis.z*sin(_angle) , cos(_angle) + axis.y*axis.y*( 1.-cos(_angle) ), axis.z*axis.x * (1. - cos(_angle) ) -axis.x*sin(_angle) , axis.z*axis.x * (1. - cos(_angle) ) -axis.y*sin(_angle) , axis.z*axis.x * (1. - cos(_angle) ) +axis.x*sin(_angle) , cos(_angle) + axis.z*axis.z*( 1.-cos(_angle) ) ); } float fuzzy(float n,vec2 fn){ float exp1=fn.x; float exp2=fn.y; // m = (pow(n,exp1))/( (pow(n,exp1)) + pow( 1. - ( pow(n,exp2) ),exp1 ) ); return (pow(n,exp1))/( (pow(n,exp1)) + pow( 1. - ( pow(n,exp2) ),exp1 ) ); } //uniform samplerCube cubeMap ; uniform sampler2D emissiveMap ; uniform sampler2D metalnessMap ; uniform sampler2D roughnessMap; uniform sampler2D lightMap; uniform sampler2D albedoMap ; uniform vec3 emissive ; uniform vec2 uvm ; uniform vec2 uvt ; uniform vec2 uvk ; uniform float reflect ; varying vec3 vViewModelPosition; varying vec3 vvLocalSurfaceNormal ; varying vec3 vvLocalSurfaceToLightDirection; varying vec3 vvLocalReflectedSurfaceToViewerDirection; //varying vec2 vuvCoord0 ; varying vec2 vUv ; uniform mat3 uvTransform; varying vec3 vvLocalSurfaceToViewerDirection; const float cpi = 3.141592653589793238462643383279502884 ; float computeFresnelTerm(float fZero, vec3 vSurfaceToViewerDirection, vec3 vSurfaceNormal) { float baseValue = 1.0 - dot(vSurfaceToViewerDirection, vSurfaceNormal); float exponential = pow(baseValue, 5.0) ; float fresnel = exponential + fZero * (1.0 - exponential) ; return fresnel ; } float chiGGX(float f) { return f > 0.0 ? 1.0 : 0.0 ; } float computeGGXDistribution(vec3 vSurfaceNormal, vec3 vSurfaceToLightDirection, float fRoughness) { float fNormalDotLight = clamp(dot(vSurfaceNormal, vSurfaceToLightDirection), 0.0, 1.0) ; float fNormalDotLightSquared = fNormalDotLight * fNormalDotLight ; float fRoughnessSquared = fRoughness * fRoughness ; float fDen = fNormalDotLightSquared * fRoughnessSquared + (1. - fNormalDotLightSquared); return clamp((chiGGX(fNormalDotLight) * fRoughnessSquared) / (cpi * fDen * fDen), 0.0, 1.0); } float computeGGXPartialGeometryTerm(vec3 vSurfaceToViewerDirection, vec3 vSurfaceNormal, vec3 vLightViewHalfVector, float fRoughness) { float fViewerDotLightViewHalf = clamp(dot(vSurfaceToViewerDirection, vLightViewHalfVector), 0.0, 1.0) ; float fChi = chiGGX(fViewerDotLightViewHalf / clamp(dot(vSurfaceToViewerDirection, vSurfaceNormal), 0.0, 1.0)); fViewerDotLightViewHalf *= fViewerDotLightViewHalf; float fTan2 = (1.0 - fViewerDotLightViewHalf) / fViewerDotLightViewHalf; return clamp((fChi * 2.0) / (1.0 + sqrt(1. + fRoughness * fRoughness * fTan2)), 0.0, 1.0) ; } uniform sampler2D texturex; uniform vec3 iResolution; uniform float uSpeed; uniform float uGlobalTime; uniform float uVolatility; uniform float uSeed; // varying vec2 vUv; void main() { // vec2 uv = vUv*1.; // float z = 200.*(300. + 5.*uGlobalTime * uSpeed); //float duv = 5.*snoise(vec3(uv, z)) * uVolatility*uSeed; //float duv2 = 3.*snoise(vec3(uv, z+313.4)) * uVolatility*uSeed; //uv += duv; //uv -= vec2(0.5,0.5); // rotate the space //float fa=sin(uGlobalTime)*4.*3.14*length(uv-0.5)*duv *uSeed; //uv = ( ( rotate2d( fa ) ) )* uv*(1.+0.2*length(uv-0.5)*uSeed); // move it back to the original place //uv += vec2(0.5,0.5); //vec4 xz= texture2D(texturex, uv); //gl_FragColor = vec4( xz.xyz,(1.-fuzzy( uSeed,vec2(0.5,8.)))*xz.w*(1.-uSeed*5.*length(uv-0.5) ) ); vec3 vNormalisedLocalSurfaceNormal = normalize(vvLocalSurfaceNormal) ; vec3 vNormalisedLocalSurfaceToLightDirection = normalize(vvLocalSurfaceToLightDirection) ; vec3 vNormalisedLocalReflectedSurfaceToViewerDirection = normalize(vvLocalReflectedSurfaceToViewerDirection) ; vec3 vNormalisedLocalSurfaceToViewerDirection = normalize(vvLocalSurfaceToViewerDirection) ; vec3 vLocalLightViewHalfVector = normalize(vNormalisedLocalSurfaceToLightDirection + vNormalisedLocalSurfaceToViewerDirection) ; float fLightIntensity = max(dot(vNormalisedLocalSurfaceToLightDirection, vNormalisedLocalSurfaceNormal), 0.0) ; float fMetalness = texture2D(metalnessMap, vUv).r ; // float fRoughness = max(0.001, texture2D(roughnessMap, vUv).r ) ; // float fRoughness = texture2D(roughnessMap, vUv).r ; // float fRoughness = max(0.001, texture2D(roughnessMap, fract(vec2(vUv.x*uvm.x ,vUv.y*uvm.y) )).r ) ; float fRoughness = max(0.001, texture2D(roughnessMap, vUv ).r ) ; float distributionMicroFacet = computeGGXDistribution(vNormalisedLocalSurfaceNormal, vNormalisedLocalSurfaceToLightDirection, fRoughness) ; float geometryMicroFacet = computeGGXPartialGeometryTerm(vNormalisedLocalSurfaceToViewerDirection, vNormalisedLocalSurfaceNormal, vLocalLightViewHalfVector, fRoughness) ; float microFacetContribution = distributionMicroFacet * geometryMicroFacet ; //float fLightSourceFresnelTerm = computeFresnelTerm(0.9, vNormalisedLocalSurfaceToViewerDirection, vNormalisedLocalSurfaceNormal) ; float fLightSourceFresnelTerm = computeFresnelTerm(1.6, vNormalisedLocalSurfaceToViewerDirection, vNormalisedLocalSurfaceNormal) ; vec3 rgbAlbedo = vec3(1.);//texture2D(albedoMap, vUv).rgb ; // vec3 rgbFragment = vec3(1.);//rgbAlbedo * (1.0 - fMetalness); vec3 rgbFragment = rgbAlbedo * (1.0 - fMetalness); // vec3 rgbSourceReflection = textureCubeLod(cubeMap, vNormalisedLocalReflectedSurfaceToViewerDirection, 9.0 * fRoughness).rgb ; vec4 emissiveColor ; vec2 uxv=vec2(vUv.x,vUv.y ); float s = (vViewModelPosition.z); float sy = (s-0.5)*2.; // uxv=vec2(fau.x * ( uxv.x-0.5 ) * ( 1./(1.+fau2.x*s) )+0.5 , fau4.y*( ( uxv.y-0.5 ) * ( 1./( 1. + (fau2.y*s) + (1.-s)*(fau3.y) ) ) + fau.y ) -1.); // vec2 uv_f=vec2(uxv.x,uxv.y ); uxv=vec2( 212. * ( uxv.x-0.5 ) * ( 1./(1.+200.*s) )+0.5 , 1. * ( uxv.y-0.5 ) * ( 1./( 1. + (5.*s) + (1.-s)*(-0.7) ) ) + 0.508 ); vec2 uv_f=vec2(1.-uxv.x,uxv.y*3.-1. ); emissiveColor = texture2D( emissiveMap, vUv, 9.0 * fRoughness);//0.75,1.,0.3,0.699 // emissiveColor = texture2D( emissiveMap, uv_f, 9.0 * fRoughness);//0.75,1.,0.3,0.699 //emissiveColor = vec4(1.,1.,0.,1.); //emissiveColor = texture2D( emissiveMap, vec2(((1.-vUv.x)-0.5)*uvm.x* ( 1./(1.+(uvk.x+s)*uvt.x) )+0.5 , (vUv.y-0.5)*( 1./( 1. + uvt.y*(5.*s/600.) + (1.-s/600.)*uvm.y*(-0.7) ) )*uvk.y + 0.79 ), 9.0 * fRoughness); vec2 uv_L=vec2( ( ( vUv.x-0.5 ) * ( 1./(1.+0.5*(s)) )*1.93+0.5),(vUv.y-0.5)*1.11+0.5+0.045 ); // vec4 lightm= texture2D( lightMap, uv_L, 9.0 * fRoughness); vec4 lightm= texture2D( lightMap, vUv, 9.0 * fRoughness); emissiveColor.rgb = emissive *(reflect*emissiveMapTexelToLinear( emissiveColor).rgb + (1.-reflect)*lightm.rgb); vec3 rgbSourceReflection = emissiveColor.rgb; vec3 rgbReflection = rgbSourceReflection ; rgbReflection *= rgbAlbedo * fMetalness ; rgbReflection *= fLightSourceFresnelTerm ; rgbReflection = min(rgbReflection, rgbSourceReflection) ; // conservation of energy vec3 rgbSpecular = vec3(0.0) ; if (fLightIntensity > 0.0) { rgbSpecular = vec3(1.0) ; rgbSpecular *= microFacetContribution * fLightSourceFresnelTerm ; rgbSpecular = min(vec3(1.0), rgbSpecular) ; // conservation of energy } rgbFragment += rgbSpecular ; rgbFragment *= fLightIntensity ; rgbFragment += rgbReflection ; //rgbFragment =rgbFragment*0.4 0.6*lightm.rgb; gl_FragColor.rgb = rgbFragment ; gl_FragColor.a = 1.0 ; // TODO : Worry about materials which allow transparency! }
uniform sampler2D texturex; uniform vec3 iResolution; uniform float uSpeed; uniform float uGlobalTime; uniform float uVolatility; uniform float uSeed; float rand(vec2 n) { return fract(sin(dot(n, vec2(12.9898, 4.1414))) * 43758.5453); } float noise(vec2 p){ vec2 ip = floor(p); vec2 u = fract(p); u = u*u*(3.0-2.0*u); float res = mix( mix(rand(ip),rand(ip+vec2(1.0,0.0)),u.x), mix(rand(ip+vec2(0.0,1.0)),rand(ip+vec2(1.0,1.0)),u.x),u.y); return res*res; } const mat2 mtx = mat2( 0.80, 0.60, -0.60, 0.80 ); float fbm( vec2 p ) { float f = 0.0; f += 0.500000*noise( p + uGlobalTime ); p = mtx*p*2.02; f += 0.031250*noise( p ); p = mtx*p*2.01; f += 0.250000*noise( p ); p = mtx*p*2.03; f += 0.125000*noise( p ); p = mtx*p*2.01; f += 0.062500*noise( p ); p = mtx*p*2.04; f += 0.015625*noise( p + sin(uGlobalTime) ); return f/0.96875; } float pattern( vec2 p ) { return fbm( p + fbm( p + fbm( p ) ) ); } varying vec3 vViewModelPosition; varying vec3 vvLocalSurfaceNormal ; varying vec3 vvLocalSurfaceToLightDirection; varying vec3 vvLocalReflectedSurfaceToViewerDirection; varying vec3 vvLocalSurfaceToViewerDirection; //varying vec2 vuvCoord0 ; uniform mat3 uvTransform; uniform vec3 glLightPosition; varying vec2 vUv; const float cpi = 3.141592653589793238462643383279502884 ; void main() { vUv = uv; vUv = ( uvTransform * vec3( uv, 1 ) ).xy; vec2 uvp=vUv.xy; uvp -= vec2(0.5,0.5); float fa=sin(uGlobalTime)*4.*3.14; vec3 posz = vec3(position.x,position.y,pattern(position.xy)); vec3 posi2=vec3( posz ); vec3 objectNormal = vec3( normal ); vec3 transformedNormal = objectNormal; transformedNormal = normalMatrix * transformedNormal; vvLocalSurfaceNormal = normalize( transformedNormal ); vec3 transformed = vec3( posi2 ); vec4 mvPosition = vec4( transformed, 1.0 ); mvPosition = modelViewMatrix * mvPosition; vViewModelPosition = - mvPosition.xyz; // vec3 vViewModelPosition = vec3(gl_ModelViewMatrixInverse * vec4(0, 0, 0, 1.0)); // vec3 vLightModelPosition = (gl_ModelViewMatrixInverse * gl_LightSource[0].position).xyz; //vec3 vViewModelPosition = vec4(gl_ModelViewMatrixInverse * vec4(0., 0., 0., 1.0)).xyz; vvLocalSurfaceToViewerDirection = normalize(vViewModelPosition - transformed) ; //glLightPosition=vec3(0.,10.,-700.); vec3 vLightModelPosition = (glLightPosition).xyz; vvLocalSurfaceToLightDirection = (vLightModelPosition - transformed) ; //vvLocalSurfaceNormal = normalize(normal) ; vec3 vLocalSurfaceToViewerDirection = normalize(vViewModelPosition - transformed) ; vvLocalReflectedSurfaceToViewerDirection = normalize(reflect(vLocalSurfaceToViewerDirection, vvLocalSurfaceNormal)) ; gl_Position = projectionMatrix * modelViewMatrix * vec4(posi2,1.); }
#define TIMESCALE 0.25 #define TILES 4 #define COLOR 0.7, 1.6, 2.8 precision highp float; precision highp int; //uniform samplerCube cubeMap ; uniform sampler2D emissiveMap ; uniform sampler2D metalnessMap ; uniform sampler2D roughnessMap; uniform sampler2D lightMap; uniform sampler2D albedoMap ; uniform vec3 emissive ; uniform vec2 uvm ; uniform vec2 uvt ; uniform vec2 uvk ; uniform float reflect ; varying vec3 vViewModelPosition; varying vec3 vvLocalSurfaceNormal ; varying vec3 vvLocalSurfaceToLightDirection; varying vec3 vvLocalReflectedSurfaceToViewerDirection; //varying vec2 vuvCoord0 ; varying vec2 vUv ; uniform mat3 uvTransform; varying vec3 vvLocalSurfaceToViewerDirection; const float cpi = 3.141592653589793238462643383279502884 ; float computeFresnelTerm(float fZero, vec3 vSurfaceToViewerDirection, vec3 vSurfaceNormal) { float baseValue = 1.0 - dot(vSurfaceToViewerDirection, vSurfaceNormal); float exponential = pow(baseValue, 5.0) ; float fresnel = exponential + fZero * (1.0 - exponential) ; return fresnel ; } float chiGGX(float f) { return f > 0.0 ? 1.0 : 0.0 ; } float computeGGXDistribution(vec3 vSurfaceNormal, vec3 vSurfaceToLightDirection, float fRoughness) { float fNormalDotLight = clamp(dot(vSurfaceNormal, vSurfaceToLightDirection), 0.0, 1.0) ; float fNormalDotLightSquared = fNormalDotLight * fNormalDotLight ; float fRoughnessSquared = fRoughness * fRoughness ; float fDen = fNormalDotLightSquared * fRoughnessSquared + (1. - fNormalDotLightSquared); return clamp((chiGGX(fNormalDotLight) * fRoughnessSquared) / (cpi * fDen * fDen), 0.0, 1.0); } float computeGGXPartialGeometryTerm(vec3 vSurfaceToViewerDirection, vec3 vSurfaceNormal, vec3 vLightViewHalfVector, float fRoughness) { float fViewerDotLightViewHalf = clamp(dot(vSurfaceToViewerDirection, vLightViewHalfVector), 0.0, 1.0) ; float fChi = chiGGX(fViewerDotLightViewHalf / clamp(dot(vSurfaceToViewerDirection, vSurfaceNormal), 0.0, 1.0)); fViewerDotLightViewHalf *= fViewerDotLightViewHalf; float fTan2 = (1.0 - fViewerDotLightViewHalf) / fViewerDotLightViewHalf; return clamp((fChi * 2.0) / (1.0 + sqrt(1. + fRoughness * fRoughness * fTan2)), 0.0, 1.0) ; } uniform sampler2D texturex; uniform vec3 iResolution; uniform float uSpeed; uniform float uGlobalTime; uniform float uVolatility; uniform float uSeed; // varying vec2 vUv; void main() { vec3 vNormalisedLocalSurfaceNormal = normalize(vvLocalSurfaceNormal) ; vec3 vNormalisedLocalSurfaceToLightDirection = normalize(vvLocalSurfaceToLightDirection) ; vec3 vNormalisedLocalReflectedSurfaceToViewerDirection = normalize(vvLocalReflectedSurfaceToViewerDirection) ; vec3 vNormalisedLocalSurfaceToViewerDirection = normalize(vvLocalSurfaceToViewerDirection) ; vec3 vLocalLightViewHalfVector = normalize(vNormalisedLocalSurfaceToLightDirection + vNormalisedLocalSurfaceToViewerDirection) ; float fLightIntensity = max(dot(vNormalisedLocalSurfaceToLightDirection, vNormalisedLocalSurfaceNormal), 0.0) ; float fMetalness = texture2D(metalnessMap, vUv).r ; // float fRoughness = max(0.001, texture2D(roughnessMap, vUv).r ) ; // float fRoughness = texture2D(roughnessMap, vUv).r ; // float fRoughness = max(0.001, texture2D(roughnessMap, fract(vec2(vUv.x*uvm.x ,vUv.y*uvm.y) )).r ) ; float fRoughness = max(0.001, texture2D(roughnessMap, vUv ).r ) ; float distributionMicroFacet = computeGGXDistribution(vNormalisedLocalSurfaceNormal, vNormalisedLocalSurfaceToLightDirection, fRoughness) ; float geometryMicroFacet = computeGGXPartialGeometryTerm(vNormalisedLocalSurfaceToViewerDirection, vNormalisedLocalSurfaceNormal, vLocalLightViewHalfVector, fRoughness) ; float microFacetContribution = distributionMicroFacet * geometryMicroFacet ; //float fLightSourceFresnelTerm = computeFresnelTerm(0.9, vNormalisedLocalSurfaceToViewerDirection, vNormalisedLocalSurfaceNormal) ; float fLightSourceFresnelTerm = computeFresnelTerm(1.6, vNormalisedLocalSurfaceToViewerDirection, vNormalisedLocalSurfaceNormal) ; vec3 rgbAlbedo = vec3(1.);//texture2D(albedoMap, vUv).rgb ; // vec3 rgbFragment = vec3(1.);//rgbAlbedo * (1.0 - fMetalness); vec3 rgbFragment = rgbAlbedo * (1.0 - fMetalness); // vec3 rgbSourceReflection = textureCubeLod(cubeMap, vNormalisedLocalReflectedSurfaceToViewerDirection, 9.0 * fRoughness).rgb ; vec4 emissiveColor ; vec2 uxv=vec2(vUv.x,vUv.y ); float s = (vViewModelPosition.z); float sy = (s-0.5)*2.; // uxv=vec2(fau.x * ( uxv.x-0.5 ) * ( 1./(1.+fau2.x*s) )+0.5 , fau4.y*( ( uxv.y-0.5 ) * ( 1./( 1. + (fau2.y*s) + (1.-s)*(fau3.y) ) ) + fau.y ) -1.); // vec2 uv_f=vec2(uxv.x,uxv.y ); uxv=vec2( 212. * ( uxv.x-0.5 ) * ( 1./(1.+200.*s) )+0.5 , 1. * ( uxv.y-0.5 ) * ( 1./( 1. + (5.*s) + (1.-s)*(-0.7) ) ) + 0.508 ); vec2 uv_f=vec2(1.-uxv.x,uxv.y*3.-1. ); emissiveColor = texture2D( emissiveMap, vUv, 9.0 * fRoughness);//0.75,1.,0.3,0.699 // emissiveColor = texture2D( emissiveMap, uv_f, 9.0 * fRoughness);//0.75,1.,0.3,0.699 //emissiveColor = vec4(1.,1.,0.,1.); //emissiveColor = texture2D( emissiveMap, vec2(((1.-vUv.x)-0.5)*uvm.x* ( 1./(1.+(uvk.x+s)*uvt.x) )+0.5 , (vUv.y-0.5)*( 1./( 1. + uvt.y*(5.*s/600.) + (1.-s/600.)*uvm.y*(-0.7) ) )*uvk.y + 0.79 ), 9.0 * fRoughness); vec2 uv_L=vec2( ( ( vUv.x-0.5 ) * ( 1./(1.+0.5*(s)) )*1.93+0.5),(vUv.y-0.5)*1.11+0.5+0.045 ); // vec4 lightm= texture2D( lightMap, uv_L, 9.0 * fRoughness); vec4 lightm= texture2D( lightMap, vUv, 9.0 * fRoughness); emissiveColor.rgb = emissive *(reflect*emissiveMapTexelToLinear( emissiveColor).rgb + (1.-reflect)*lightm.rgb); vec3 rgbSourceReflection = emissiveColor.rgb; vec3 rgbReflection = rgbSourceReflection ; rgbReflection *= rgbAlbedo * fMetalness ; rgbReflection *= fLightSourceFresnelTerm ; rgbReflection = min(rgbReflection, rgbSourceReflection) ; // conservation of energy vec3 rgbSpecular = vec3(0.0) ; if (fLightIntensity > 0.0) { rgbSpecular = vec3(1.0) ; rgbSpecular *= microFacetContribution * fLightSourceFresnelTerm ; rgbSpecular = min(vec3(1.0), rgbSpecular) ; // conservation of energy } rgbFragment += rgbSpecular ; rgbFragment *= fLightIntensity ; rgbFragment += rgbReflection ; //rgbFragment =rgbFragment*0.4 0.6*lightm.rgb; gl_FragColor.rgb = rgbFragment ; gl_FragColor.a = 1.0 ; // TODO : Worry about materials which allow transparency! }
uniform sampler2D texturex; uniform vec3 iResolution; uniform float uSpeed; uniform float uGlobalTime; uniform float uVolatility; uniform float uSeed; const mat2 m = mat2( 0.80, 0.60, -0.60, 0.80 ); float noise( in vec2 p ) { return sin(p.x)*sin(p.y); } float fbm4( vec2 p ) { float f = 0.0; f += 0.5000*noise( p ); p = m*p*2.02; f += 0.2500*noise( p ); p = m*p*2.03; f += 0.1250*noise( p ); p = m*p*2.01; f += 0.0625*noise( p ); return f/0.9375; } float fbm6( vec2 p ) { float f = 0.0; f += 0.500000*(0.5+0.5*noise( p )); p = m*p*2.02; f += 0.250000*(0.5+0.5*noise( p )); p = m*p*2.03; f += 0.125000*(0.5+0.5*noise( p )); p = m*p*2.01; f += 0.062500*(0.5+0.5*noise( p )); p = m*p*2.04; f += 0.031250*(0.5+0.5*noise( p )); p = m*p*2.01; f += 0.015625*(0.5+0.5*noise( p )); return f/0.96875; } vec2 fbm4_2( vec2 p ) { return vec2(fbm4(p), fbm4(p+vec2(7.8))); } vec2 fbm6_2( vec2 p ) { return vec2(fbm6(p+vec2(16.8)), fbm6(p+vec2(11.5))); } //==================================================================== float func( vec2 q, out vec4 ron ) { q += 0.03*sin( vec2(0.27,0.23)*uGlobalTime + length(q)*vec2(4.1,4.3)); vec2 o = fbm4_2( 0.9*q ); o += 0.04*sin( vec2(0.12,0.14)*uGlobalTime + length(o)); vec2 n = fbm6_2( 3.0*o ); ron = vec4( o, n ); float f = 0.5 + 0.5*fbm4( 1.8*q + 6.0*n ); return mix( f, f*f*f*3.5, f*abs(n.x) ); } varying vec3 vViewModelPosition; varying vec3 vvLocalSurfaceNormal ; varying vec3 vvLocalSurfaceToLightDirection; varying vec3 vvLocalReflectedSurfaceToViewerDirection; varying vec3 vvLocalSurfaceToViewerDirection; //varying vec2 vuvCoord0 ; uniform mat3 uvTransform; uniform vec3 glLightPosition; varying float warp; varying vec2 vUv; const float cpi = 3.141592653589793238462643383279502884 ; void main() { vUv = uv; vUv = ( uvTransform * vec3( uv, 1 ) ).xy; vec2 uvp=vUv.xy; uvp -= vec2(0.5,0.5); float fa=sin(uGlobalTime)*4.*3.14; //vec3 posz = vec3(position.x,position.y,pattern(position.xy)); vec2 p = position.xy; float e = 2.0/200.; vec4 on = vec4(0.0); float f = func(p, on); vec3 col = vec3(0.0); // col = mix( vec3(0.2,0.1,0.4), vec3(0.3,0.05,0.05), f ); // col = mix( col, vec3(0.9,0.9,0.9), dot(on.zw,on.zw) ); // col = mix( col, vec3(0.4,0.3,0.3), 0.2 + 0.5*on.y*on.y ); // col = mix( col, vec3(0.0,0.2,0.4), 0.5*smoothstep(1.2,1.3,abs(on.z)+abs(on.w)) ); // col = clamp( col*f*2.0, 0.0, 1.0 ); col=vec3(f); #if 0 // gpu derivatives - bad quality, but fast vec3 nor = normalize( vec3( dFdx(f)*iResolution.x, 6.0, dFdy(f)*iResolution.y ) ); #else // manual derivatives - better quality, but slower vec4 kk; vec3 nor = normalize( vec3( func(p+vec2(e,0.0),kk)-f, 2.0*e, func(p+vec2(0.0,e),kk)-f ) ); #endif vec3 lig = normalize( vec3( 0.9, 0.2, -0.4 ) ); float dif = clamp( 0.3+0.7*dot( nor, lig ), 0.0, 1.0 ); vec3 lin = vec3(0.70,0.90,0.95)*(nor.y*0.5+0.5) + vec3(0.15,0.10,0.05)*dif; col *= 1.1*lin; vec3 posz = vec3(position.x*(0.8+0.2*col.x),position.y*(0.8+0.2*col.x),col.x*4.5*length(0.5-position.x)*length(-0.5-position.x)*length(0.5-position.y)*length(-0.5-position.y)); warp=col.x; vec3 posi2=vec3( posz ); vec3 objectNormal = vec3( normal ); vec3 transformedNormal = objectNormal; transformedNormal = normalMatrix * transformedNormal; vvLocalSurfaceNormal = normalize( transformedNormal ); vec3 transformed = vec3( posi2 ); vec4 mvPosition = vec4( transformed, 1.0 ); mvPosition = modelViewMatrix * mvPosition; vViewModelPosition = - mvPosition.xyz; // vec3 vViewModelPosition = vec3(gl_ModelViewMatrixInverse * vec4(0, 0, 0, 1.0)); // vec3 vLightModelPosition = (gl_ModelViewMatrixInverse * gl_LightSource[0].position).xyz; //vec3 vViewModelPosition = vec4(gl_ModelViewMatrixInverse * vec4(0., 0., 0., 1.0)).xyz; vvLocalSurfaceToViewerDirection = normalize(vViewModelPosition - transformed) ; //glLightPosition=vec3(0.,10.,-700.); vec3 vLightModelPosition = (glLightPosition).xyz; vvLocalSurfaceToLightDirection = (vLightModelPosition - transformed) ; //vvLocalSurfaceNormal = normalize(normal) ; vec3 vLocalSurfaceToViewerDirection = normalize(vViewModelPosition - transformed) ; vvLocalReflectedSurfaceToViewerDirection = normalize(reflect(vLocalSurfaceToViewerDirection, vvLocalSurfaceNormal)) ; gl_Position = projectionMatrix * modelViewMatrix * vec4(posi2,1.); }
#define TIMESCALE 0.25 #define TILES 4 #define COLOR 0.7, 1.6, 2.8 precision highp float; precision highp int; //uniform samplerCube cubeMap ; uniform sampler2D emissiveMap ; uniform sampler2D metalnessMap ; uniform sampler2D roughnessMap; uniform sampler2D lightMap; uniform sampler2D albedoMap ; uniform vec3 emissive ; uniform vec2 uvm ; uniform vec2 uvt ; uniform vec2 uvk ; uniform float reflect ; varying float warp; varying vec3 vViewModelPosition; varying vec3 vvLocalSurfaceNormal ; varying vec3 vvLocalSurfaceToLightDirection; varying vec3 vvLocalReflectedSurfaceToViewerDirection; //varying vec2 vuvCoord0 ; varying vec2 vUv ; uniform mat3 uvTransform; varying vec3 vvLocalSurfaceToViewerDirection; const float cpi = 3.141592653589793238462643383279502884 ; float computeFresnelTerm(float fZero, vec3 vSurfaceToViewerDirection, vec3 vSurfaceNormal) { float baseValue = 1.0 - dot(vSurfaceToViewerDirection, vSurfaceNormal); float exponential = pow(baseValue, 5.0) ; float fresnel = exponential + fZero * (1.0 - exponential) ; return fresnel ; } float chiGGX(float f) { return f > 0.0 ? 1.0 : 0.0 ; } float computeGGXDistribution(vec3 vSurfaceNormal, vec3 vSurfaceToLightDirection, float fRoughness) { float fNormalDotLight = clamp(dot(vSurfaceNormal, vSurfaceToLightDirection), 0.0, 1.0) ; float fNormalDotLightSquared = fNormalDotLight * fNormalDotLight ; float fRoughnessSquared = fRoughness * fRoughness ; float fDen = fNormalDotLightSquared * fRoughnessSquared + (1. - fNormalDotLightSquared); return clamp((chiGGX(fNormalDotLight) * fRoughnessSquared) / (cpi * fDen * fDen), 0.0, 1.0); } float computeGGXPartialGeometryTerm(vec3 vSurfaceToViewerDirection, vec3 vSurfaceNormal, vec3 vLightViewHalfVector, float fRoughness) { float fViewerDotLightViewHalf = clamp(dot(vSurfaceToViewerDirection, vLightViewHalfVector), 0.0, 1.0) ; float fChi = chiGGX(fViewerDotLightViewHalf / clamp(dot(vSurfaceToViewerDirection, vSurfaceNormal), 0.0, 1.0)); fViewerDotLightViewHalf *= fViewerDotLightViewHalf; float fTan2 = (1.0 - fViewerDotLightViewHalf) / fViewerDotLightViewHalf; return clamp((fChi * 2.0) / (1.0 + sqrt(1. + fRoughness * fRoughness * fTan2)), 0.0, 1.0) ; } uniform sampler2D texturex; uniform vec3 iResolution; uniform float uSpeed; uniform float uGlobalTime; uniform float uVolatility; uniform float uSeed; // varying vec2 vUv; void main() { vec3 vNormalisedLocalSurfaceNormal = normalize(vvLocalSurfaceNormal) ; vec3 vNormalisedLocalSurfaceToLightDirection = normalize(vvLocalSurfaceToLightDirection) ; vec3 vNormalisedLocalReflectedSurfaceToViewerDirection = normalize(vvLocalReflectedSurfaceToViewerDirection) ; vec3 vNormalisedLocalSurfaceToViewerDirection = normalize(vvLocalSurfaceToViewerDirection) ; vec3 vLocalLightViewHalfVector = normalize(vNormalisedLocalSurfaceToLightDirection + vNormalisedLocalSurfaceToViewerDirection) ; float fLightIntensity = max(dot(vNormalisedLocalSurfaceToLightDirection, vNormalisedLocalSurfaceNormal), 0.0) ; float fMetalness = texture2D(metalnessMap, vUv).r ; // float fRoughness = max(0.001, texture2D(roughnessMap, vUv).r ) ; // float fRoughness = texture2D(roughnessMap, vUv).r ; // float fRoughness = max(0.001, texture2D(roughnessMap, fract(vec2(vUv.x*uvm.x ,vUv.y*uvm.y) )).r ) ; float fRoughness = max(0.001, texture2D(roughnessMap, vUv ).r ) ; float distributionMicroFacet = computeGGXDistribution(vNormalisedLocalSurfaceNormal, vNormalisedLocalSurfaceToLightDirection, fRoughness) ; float geometryMicroFacet = computeGGXPartialGeometryTerm(vNormalisedLocalSurfaceToViewerDirection, vNormalisedLocalSurfaceNormal, vLocalLightViewHalfVector, fRoughness) ; float microFacetContribution = distributionMicroFacet * geometryMicroFacet ; //float fLightSourceFresnelTerm = computeFresnelTerm(0.9, vNormalisedLocalSurfaceToViewerDirection, vNormalisedLocalSurfaceNormal) ; float fLightSourceFresnelTerm = computeFresnelTerm(1.6, vNormalisedLocalSurfaceToViewerDirection, vNormalisedLocalSurfaceNormal) ; vec3 rgbAlbedo = vec3(1.);//texture2D(albedoMap, vUv).rgb ; // vec3 rgbFragment = vec3(1.);//rgbAlbedo * (1.0 - fMetalness); vec3 rgbFragment = rgbAlbedo * (1.0 - fMetalness); // vec3 rgbSourceReflection = textureCubeLod(cubeMap, vNormalisedLocalReflectedSurfaceToViewerDirection, 9.0 * fRoughness).rgb ; vec4 emissiveColor ; vec2 uxv=vec2(vUv.x,vUv.y ); float s = (vViewModelPosition.z); float sy = (s-0.5)*2.; // uxv=vec2(fau.x * ( uxv.x-0.5 ) * ( 1./(1.+fau2.x*s) )+0.5 , fau4.y*( ( uxv.y-0.5 ) * ( 1./( 1. + (fau2.y*s) + (1.-s)*(fau3.y) ) ) + fau.y ) -1.); // vec2 uv_f=vec2(uxv.x,uxv.y ); uxv=vec2( 212. * ( uxv.x-0.5 ) * ( 1./(1.+200.*s) )+0.5 , 1. * ( uxv.y-0.5 ) * ( 1./( 1. + (5.*s) + (1.-s)*(-0.7) ) ) + 0.508 ); vec2 uv_f=vec2(1.-uxv.x,uxv.y*3.-1. ); emissiveColor = texture2D( emissiveMap, vUv, 9.0 * fRoughness);//0.75,1.,0.3,0.699 // emissiveColor = texture2D( emissiveMap, uv_f, 9.0 * fRoughness);//0.75,1.,0.3,0.699 //emissiveColor = vec4(1.,1.,0.,1.); //emissiveColor = texture2D( emissiveMap, vec2(((1.-vUv.x)-0.5)*uvm.x* ( 1./(1.+(uvk.x+s)*uvt.x) )+0.5 , (vUv.y-0.5)*( 1./( 1. + uvt.y*(5.*s/600.) + (1.-s/600.)*uvm.y*(-0.7) ) )*uvk.y + 0.79 ), 9.0 * fRoughness); vec2 uv_L=vec2( ( ( vUv.x-0.5 ) * ( 1./(1.+0.5*(s)) )*1.93+0.5),(vUv.y-0.5)*1.11+0.5+0.045 ); // vec4 lightm= texture2D( lightMap, uv_L, 9.0 * fRoughness); vec4 lightm= texture2D( lightMap, vUv, 9.0 * fRoughness); emissiveColor.rgb = emissive *(reflect*emissiveMapTexelToLinear( emissiveColor).rgb + (1.-reflect)*lightm.rgb); vec3 rgbSourceReflection = emissiveColor.rgb; vec3 rgbReflection = rgbSourceReflection ; rgbReflection *= rgbAlbedo * fMetalness ; rgbReflection *= fLightSourceFresnelTerm ; rgbReflection = min(rgbReflection, rgbSourceReflection) ; // conservation of energy vec3 rgbSpecular = vec3(0.0) ; if (fLightIntensity > 0.0) { rgbSpecular = vec3(1.0) ; rgbSpecular *= microFacetContribution * fLightSourceFresnelTerm ; rgbSpecular = min(vec3(1.0), rgbSpecular) ; // conservation of energy } rgbFragment += rgbSpecular ; rgbFragment *= fLightIntensity ; rgbFragment += rgbReflection ; //rgbFragment =rgbFragment*0.4 0.6*lightm.rgb; gl_FragColor.rgb = rgbFragment*warp ; gl_FragColor.a = 1.0 ; // TODO : Worry about materials which allow transparency! }
varying vec2 vUv; varying vec3 vViewModelPosition; void main() { // vUv = uv; // vUv=position.xy*0.5+0.5; vUv = uv; vec4 zz = - modelViewMatrix * vec4(position,1.); vViewModelPosition=zz.xyz; gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); // gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); // //gl_Position = vec4( position, 1.0 ); }
#define TIMESCALE 0.25 #define TILES 4 #define COLOR 0.7, 1.6, 2.8 uniform sampler2D texturex; uniform vec3 iResolution; uniform float uSpeed; uniform float uGlobalTime; uniform float uVolatility; uniform float uSeed; varying vec2 vUv; uniform float move; uniform float move2; uniform float move3; uniform float move4; uniform vec2 uvm; float rand(vec2 co){ return fract(sin(dot(co.xy, vec2(12.8273, 67.245))) * 53726.17623); } void main() { vec2 uv = vUv*1.; vec4 xz= texture2D(texturex, fract(vec2(vUv.x*uvm.x + move2 ,vUv.y*uvm.y + move ) )); gl_FragColor =vec4(move4*xz.x,move4*xz.y,move4*xz.z,xz.w); }
varying vec2 vUv; uniform float move; uniform float move2; uniform float move3; uniform vec2 uvm; uniform float tunnel_lungo; void main() { // vUv = uv; // vUv=position.xy*0.5+0.5; vUv = uv; vec3 transformed=position; float x = fract(-((position.y+move3)-20.)/(tunnel_lungo+20.)); transformed.y = -x*(tunnel_lungo+20.) +20.; // transformed.y = (position.y+move3) - (tunnel_lungo/2.)*floor((move3)/(tunnel_lungo/2.)) ; float xq=650.; float max=- fract(-((-(xq)+30.+move3)-50.)/(tunnel_lungo+50.))*(tunnel_lungo+50.) +50.; float min=- fract(-((-(xq)+move3)-50.)/(tunnel_lungo+50.))*(tunnel_lungo+50.) +50.; float xq2=800.; float max2=- fract(-((-(xq2)+30.+move3)-50.)/(tunnel_lungo+50.))*(tunnel_lungo+50.) +50.; float min2=- fract(-((-(xq2)+move3)-50.)/(tunnel_lungo+50.))*(tunnel_lungo+50.) +50.; float xq3=1100.; float max3=- fract(-((-(xq3)+30.+move3)-50.)/(tunnel_lungo+50.))*(tunnel_lungo+50.) +50.; float min3=- fract(-((-(xq3)+move3)-50.)/(tunnel_lungo+50.))*(tunnel_lungo+50.) +50.; if(transformed.y > min && transformed.y < max){ if(x < 0.999){ gl_Position = projectionMatrix * modelViewMatrix * vec4( transformed, 1.0 ); } }else if(transformed.y > min2 && transformed.y < max2){ if(x < 0.999){ gl_Position = projectionMatrix * modelViewMatrix * vec4( transformed, 1.0 ); } }else if(transformed.y > min3 && transformed.y < max3){ if(x < 0.999){ gl_Position = projectionMatrix * modelViewMatrix * vec4( transformed, 1.0 ); } } //gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); //gl_Position = vec4( position, 1.0 ); }
varying vec2 vUv; uniform float move; uniform float move2; uniform float move3; uniform vec2 uvm; uniform float tunnel_lungo; void main() { // vUv = uv; // vUv=position.xy*0.5+0.5; vUv = uv; vec3 transformed=position; // transformed.y = (position.y+move3) - (tunnel_lungo/2.)*floor((move3)/(tunnel_lungo/2.)) ; float x = fract(-((position.y+move3)-20.)/(tunnel_lungo+20.)); transformed.y = -x*(tunnel_lungo+20.) +20.; if(x < 0.99 && transformed.y > -400.){ gl_Position = projectionMatrix * modelViewMatrix * vec4( transformed, 1.0 ); } //gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); //gl_Position = vec4( position, 1.0 ); }
#define TIMESCALE 0.25 #define TILES 4 #define COLOR 0.7, 1.6, 2.8 float fuzzy(float n,vec2 fn){ float exp1=fn.x; float exp2=fn.y; // m = (pow(n,exp1))/( (pow(n,exp1)) + pow( 1. - ( pow(n,exp2) ),exp1 ) ); return (pow(n,exp1))/( (pow(n,exp1)) + pow( 1. - ( pow(n,exp2) ),exp1 ) ); } uniform sampler2D texturex; uniform vec3 iResolution; varying vec2 vUv; void main() { // vec2 fragCoord = vUv * iResolution.xy; vec2 uv = vUv*1.; // uv.x *= iResolution.x / iResolution.y; vec4 noise = texture2D(texturex, uv ); gl_FragColor = noise ; //gl_FragColor = vec4(0.,1.,0., 1.0) ; }
varying vec2 vUv; void main() { // vUv = uv; // vUv=position.xy*0.5+0.5; vUv = uv; gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); // gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); //gl_Position = vec4( position, 1.0 ); }
void main() { // vec2 fragCoord = vUv * iResolution.xy; gl_FragColor = vec4( 1.,0.,0.,1. ); }
void main() { gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); }
uniform vec3 viewVector; varying float intensity; void main() { // vec2 fragCoord = vUv * iResolution.xy; vec3 glow = vec3(1., 1., 1.) * intensity; gl_FragColor = vec4( glow, intensity ); }
uniform vec3 viewVector; varying float intensity; varying vec2 vUv; void main() { vUv = uv; // vUv=position.xy*0.5+0.5; vUv = uv; gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); vec3 actual_normal = vec3(modelMatrix * vec4(normal, 0.0)); //intensity = 2.*(pow( dot(normalize(viewVector), actual_normal), 6.0 ) ); intensity = (pow( dot(normalize(viewVector), actual_normal), 6.0 ) ); // gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); //gl_Position = vec4( position, 1.0 ); }
#define TIMESCALE 0.25 #define TILES 4 #define COLOR 0.7, 1.6, 2.8 #define TAU 6.28318530718 #define MAX_ITER 5 varying vec3 vWorldPosition; varying vec3 positionx; varying vec2 vUv; void main() { // vUv = uv; // vUv=position.xy*0.5+0.5; vUv = uv; positionx=position; //vec2 p = mod(uv*TAU, TAU)-250.0; vWorldPosition=vec4(modelMatrix*vec4( position.xyz, 1.0 ) ).xyz; gl_Position = projectionMatrix * modelViewMatrix * vec4( position.xyz, 1.0 ); }
#define TIMESCALE 0.25 #define TILES 4 #define COLOR 0.7, 1.6, 2.8 #define TAU 6.28318530718 #define MAX_ITER 2 // uniform sampler2D texturex; varying vec2 vUv; varying vec3 vWorldPosition; varying vec3 positionx; uniform float opacity; float rand(vec2 co){ return fract(sin(dot(co.xy, vec2(12.8273, 67.245))) * 53726.17623); } void main() { // float time = .5+23.0; // float time = .5+23.0+0.005*vWorldPosition.x+0.009*(vWorldPosition.y-50.); // float time = +23.0+0.00*vWorldPosition.x+0.00*vWorldPosition.z+0.00*(vWorldPosition.y-50.); float time = +23.0+0.004*vWorldPosition.x+0.002*vWorldPosition.z+0.005*(vWorldPosition.y-50.); // uv should be the 0-1 uv of texture... //vec2 uv = fragCoord.xy / iResolution.xy; // vec2 uv = vUv*1.; vec2 uv = vec2(vUv.x,vUv.y); vec2 p = mod(uv*TAU*0.3, TAU)-250.0; // vec2 p = vec2(mod(uv.x*TAU*0.3, TAU)-250.0,mod(uv.y*TAU*0.3, TAU)-250.0); vec2 i = vec2(p); float c = 1.0; float inten = .005; for (int n = 0; n < MAX_ITER; n++) { float t = time * (1.0 - (3.5 / float(n+1))); i = p + vec2( cos(t - i.x) + sin(t + i.y), sin(t - i.y) + cos(t + i.x) ); c += 1.0/(length(vec2(p.x / ((sin(i.x+t))/inten),p.y / ((cos(i.y+t))/inten))) ); } c /= float(MAX_ITER)*1.6; c = 1.17-pow(c, 1.4); vec3 colour = vec3(pow(abs(c), 8.0)); colour = clamp(colour + vec3(0.2, 0.2, 0.2), 0.0, 1.0); if(positionx.z > 0.){discard;} if(vWorldPosition.y < -200.){discard;} //if(colour.x < 0.1){discard;} gl_FragColor =vec4(colour,opacity*(0.3+0.4*colour.x)); }