Update globe files
This commit is contained in:
@@ -1,59 +0,0 @@
|
|||||||
export default `
|
|
||||||
#define PI 3.34159265359
|
|
||||||
#define RECIPROCAL_PI 0.31830988618
|
|
||||||
#define saturate(a) clamp( a, 0.0, 1.0 )
|
|
||||||
|
|
||||||
precision highp float;
|
|
||||||
|
|
||||||
varying vec3 vNormal;
|
|
||||||
varying vec2 vUv;
|
|
||||||
varying vec3 vPos;
|
|
||||||
|
|
||||||
uniform sampler2D tInput;
|
|
||||||
uniform vec3 uCameraPosition;
|
|
||||||
|
|
||||||
|
|
||||||
vec3 F_Schlick_Frostbite (in vec3 f0 , in float f90 , in float u )
|
|
||||||
{
|
|
||||||
return f0 + ( f90 - f0 ) * pow (1. - u, 5.);
|
|
||||||
}
|
|
||||||
|
|
||||||
void main(void) {
|
|
||||||
|
|
||||||
vec3 N = vNormal;
|
|
||||||
vec3 outColor = vec3(0.);
|
|
||||||
vec3 diffuseColor = texture2D(tInput, vUv).rgb;//pow( texture2D(tInput, vUv).rgb, vec3(2.2) );
|
|
||||||
|
|
||||||
vec3 V = normalize(uCameraPosition - vPos);
|
|
||||||
vec3 L = normalize( vec3(20.,20.,20.) );
|
|
||||||
vec3 Ldir = normalize( L - vPos ) ;
|
|
||||||
vec3 radiance = vec3(0.);
|
|
||||||
float NdotL = max(0., dot(N,L) );
|
|
||||||
vec3 lColor = vec3(1.);
|
|
||||||
|
|
||||||
|
|
||||||
float attenuation = 1.;//calcLightAttenuation(length(L - worldPos), directLight.distance, directLight.decay);
|
|
||||||
|
|
||||||
float roughness = clamp( 1., 0.04, 1.0 );
|
|
||||||
vec3 H = normalize(L);
|
|
||||||
float LdotH = saturate ( dot (L , H ));
|
|
||||||
float NdotH = saturate ( dot (N , H ));
|
|
||||||
float energyBias = mix(0., 0.5, roughness );
|
|
||||||
float energyFactor = mix(1.0, 1.0 / 1.51, roughness );
|
|
||||||
float f90 = energyBias + 2.0 * LdotH * LdotH * roughness ;
|
|
||||||
vec3 f0 = vec3(1.0, 1.0, 1.0);
|
|
||||||
float lightScatter = F_Schlick_Frostbite ( f0 , f90 , NdotL ).r;
|
|
||||||
vec3 irradiance = NdotL * lColor;
|
|
||||||
outColor = diffuseColor * irradiance * lightScatter * energyFactor * attenuation;
|
|
||||||
|
|
||||||
|
|
||||||
vec3 ambient = vec3(192./255., 181./255., 215./255.);
|
|
||||||
// outColor.r = max(ambient.r, outColor.r);
|
|
||||||
// outColor.g = max(ambient.g, outColor.g);
|
|
||||||
// outColor.b = max(ambient.b, outColor.b);
|
|
||||||
outColor = diffuseColor * vec3(NdotL) + diffuseColor * ambient * (1.-NdotL);
|
|
||||||
|
|
||||||
|
|
||||||
gl_FragColor = vec4( outColor, 1. );
|
|
||||||
}
|
|
||||||
`
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import Program from './Program';
|
import Program from './Program';
|
||||||
import vertexShader from './shaders/default-vs.glsl';
|
import vertexShader from './shaders/default-vs.glsl?raw';
|
||||||
import fragmentShader from './shaders/mesh-fs.glsl';
|
import fragmentShader from './shaders/mesh-fs.glsl?raw';
|
||||||
|
|
||||||
class Material extends Program {
|
class Material extends Program {
|
||||||
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import UNIFORM_TYPE from './uniformTypes';
|
import UNIFORM_TYPE from './uniformTypes';
|
||||||
import defaultVertexShader from './shaders/default-vs.glsl';
|
import defaultVertexShader from './shaders/default-vs.glsl?raw';
|
||||||
import defaultFragmentShader from './shaders/default-fs.glsl';
|
import defaultFragmentShader from './shaders/default-fs.glsl?raw';
|
||||||
import uuid from './utils/uuid';
|
import uuid from './utils/uuid';
|
||||||
|
|
||||||
const TEXTURE_2D = 35678
|
const TEXTURE_2D = 35678
|
||||||
53
src/modules/globe/globe-fs.glsl
Normal file
53
src/modules/globe/globe-fs.glsl
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
#define PI 3.34159265359
|
||||||
|
#define RECIPROCAL_PI 0.31830988618
|
||||||
|
#define saturate(a) clamp(a, 0.0, 1.0)
|
||||||
|
|
||||||
|
precision highp float;
|
||||||
|
|
||||||
|
varying vec3 vNormal;
|
||||||
|
varying vec2 vUv;
|
||||||
|
varying vec3 vPos;
|
||||||
|
|
||||||
|
uniform sampler2D tInput;
|
||||||
|
uniform vec3 uCameraPosition;
|
||||||
|
|
||||||
|
|
||||||
|
vec3 F_Schlick_Frostbite (in vec3 f0, in float f90, in float u) {
|
||||||
|
return f0 + (f90 - f0) * pow (1. - u, 5.);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void main (void) {
|
||||||
|
vec3 N = vNormal;
|
||||||
|
vec3 outColor = vec3(0.);
|
||||||
|
vec3 diffuseColor = texture2D(tInput, vUv).rgb; //pow(texture2D(tInput, vUv).rgb, vec3(2.2));
|
||||||
|
|
||||||
|
vec3 V = normalize(uCameraPosition - vPos);
|
||||||
|
vec3 L = normalize(vec3(20., 20., 20.));
|
||||||
|
vec3 Ldir = normalize(L - vPos);
|
||||||
|
vec3 radiance = vec3(0.);
|
||||||
|
float NdotL = max(0., dot(N, L));
|
||||||
|
vec3 lColor = vec3(1.);
|
||||||
|
|
||||||
|
float attenuation = 1.; // calcLightAttenuation(length(L - worldPos), directLight.distance, directLight.decay);
|
||||||
|
|
||||||
|
float roughness = clamp(1., 0.04, 1.0);
|
||||||
|
vec3 H = normalize(L);
|
||||||
|
float LdotH = saturate(dot(L, H));
|
||||||
|
float NdotH = saturate(dot(N, H));
|
||||||
|
float energyBias = mix(0., 0.5, roughness);
|
||||||
|
float energyFactor = mix(1.0, 1.0 / 1.51, roughness);
|
||||||
|
float f90 = energyBias + 2.0 * LdotH * LdotH * roughness;
|
||||||
|
vec3 f0 = vec3(1.0, 1.0, 1.0);
|
||||||
|
float lightScatter = F_Schlick_Frostbite (f0, f90, NdotL).r;
|
||||||
|
vec3 irradiance = NdotL * lColor;
|
||||||
|
outColor = diffuseColor * irradiance * lightScatter * energyFactor * attenuation;
|
||||||
|
|
||||||
|
vec3 ambient = vec3(192./255., 181./255., 215./255.);
|
||||||
|
// outColor.r = max(ambient.r, outColor.r);
|
||||||
|
// outColor.g = max(ambient.g, outColor.g);
|
||||||
|
// outColor.b = max(ambient.b, outColor.b);
|
||||||
|
outColor = diffuseColor * vec3(NdotL) + diffuseColor * ambient * (1. - NdotL);
|
||||||
|
|
||||||
|
gl_FragColor = vec4(outColor, 1.);
|
||||||
|
}
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
export default `
|
|
||||||
precision highp float;
|
precision highp float;
|
||||||
|
|
||||||
attribute vec3 normal;
|
attribute vec3 normal;
|
||||||
@@ -15,12 +14,11 @@ varying vec2 vUv;
|
|||||||
varying vec3 vNormal;
|
varying vec3 vNormal;
|
||||||
varying vec3 vPos;
|
varying vec3 vPos;
|
||||||
|
|
||||||
|
|
||||||
void main(void) {
|
void main(void) {
|
||||||
vUv = uv;
|
vUv = uv;
|
||||||
vNormal = (uNormalMatrix * vec4(normal, 1.)).rgb;
|
vNormal = (uNormalMatrix * vec4(normal, 1.)).rgb;
|
||||||
vPos = (uMMatrix * vec4(position, 1.)).rgb;
|
vPos = (uMMatrix * vec4(position, 1.)).rgb;
|
||||||
gl_Position = uPMatrix * uMVMatrix * vec4(position, 1.0);
|
gl_Position = uPMatrix * uMVMatrix * vec4(position, 1.0);
|
||||||
|
|
||||||
gl_Position[1] += uCameraOffsetY * gl_Position.w;
|
gl_Position[1] += uCameraOffsetY * gl_Position.w;
|
||||||
}
|
}
|
||||||
`
|
|
||||||
@@ -4,8 +4,8 @@ import { vec2, vec3, mat4 } from './beam'
|
|||||||
import { Container, Mesh, Material, Texture, SphereGeometryBuffer, PlaneGeometryBuffer } from './beam'
|
import { Container, Mesh, Material, Texture, SphereGeometryBuffer, PlaneGeometryBuffer } from './beam'
|
||||||
|
|
||||||
// GLSL shaders as strings
|
// GLSL shaders as strings
|
||||||
import GlobeVS from './globe-vs'
|
import GlobeVS from './globe-vs.glsl?raw'
|
||||||
import GlobeFS from './globe-fs'
|
import GlobeFS from './globe-fs.glsl?raw'
|
||||||
|
|
||||||
const FOV = 1 // Camera Field of view; we use 1 to prevent strong perspective effect on the globe
|
const FOV = 1 // Camera Field of view; we use 1 to prevent strong perspective effect on the globe
|
||||||
|
|
||||||
@@ -172,8 +172,8 @@ class WebglGlobe {
|
|||||||
// Wrap marker in link
|
// Wrap marker in link
|
||||||
let el = document.createElement('a')
|
let el = document.createElement('a')
|
||||||
el.style.pointerEvents = 'auto'
|
el.style.pointerEvents = 'auto'
|
||||||
el.setAttribute('href', '/location/' + markers[i].countrySlug + '/' + markers[i].slug)
|
el.setAttribute('href', `/${markers[i].countrySlug}/${markers[i].slug}`)
|
||||||
el.setAttribute('sapper-noscroll', '')
|
el.setAttribute('sveltekit-noscroll', '')
|
||||||
if (markers[i].className) el.classList.add(markers[i].className)
|
if (markers[i].className) el.classList.add(markers[i].className)
|
||||||
|
|
||||||
// Add label
|
// Add label
|
||||||
Reference in New Issue
Block a user