Upload sphere-shader.ts
Browse files- sphere-shader.ts +91 -0
sphere-shader.ts
ADDED
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* @license
|
3 |
+
* SPDX-License-Identifier: Apache-2.0
|
4 |
+
*/
|
5 |
+
const vs = `#define STANDARD
|
6 |
+
varying vec3 vViewPosition;
|
7 |
+
#ifdef USE_TRANSMISSION
|
8 |
+
varying vec3 vWorldPosition;
|
9 |
+
#endif
|
10 |
+
#include <common>
|
11 |
+
#include <batching_pars_vertex>
|
12 |
+
#include <uv_pars_vertex>
|
13 |
+
#include <displacementmap_pars_vertex>
|
14 |
+
#include <color_pars_vertex>
|
15 |
+
#include <fog_pars_vertex>
|
16 |
+
#include <normal_pars_vertex>
|
17 |
+
#include <morphtarget_pars_vertex>
|
18 |
+
#include <skinning_pars_vertex>
|
19 |
+
#include <shadowmap_pars_vertex>
|
20 |
+
#include <logdepthbuf_pars_vertex>
|
21 |
+
#include <clipping_planes_pars_vertex>
|
22 |
+
|
23 |
+
uniform float time;
|
24 |
+
|
25 |
+
uniform vec4 inputData;
|
26 |
+
uniform vec4 outputData;
|
27 |
+
|
28 |
+
vec3 calc( vec3 pos ) {
|
29 |
+
|
30 |
+
vec3 dir = normalize( pos );
|
31 |
+
vec3 p = dir + vec3( time, 0., 0. );
|
32 |
+
return pos +
|
33 |
+
1. * inputData.x * inputData.y * dir * (.5 + .5 * sin(inputData.z * pos.x + time)) +
|
34 |
+
1. * outputData.x * outputData.y * dir * (.5 + .5 * sin(outputData.z * pos.y + time))
|
35 |
+
;
|
36 |
+
}
|
37 |
+
|
38 |
+
vec3 spherical( float r, float theta, float phi ) {
|
39 |
+
return r * vec3(
|
40 |
+
cos( theta ) * cos( phi ),
|
41 |
+
sin( theta ) * cos( phi ),
|
42 |
+
sin( phi )
|
43 |
+
);
|
44 |
+
}
|
45 |
+
|
46 |
+
void main() {
|
47 |
+
#include <uv_vertex>
|
48 |
+
#include <color_vertex>
|
49 |
+
#include <morphinstance_vertex>
|
50 |
+
#include <morphcolor_vertex>
|
51 |
+
#include <batching_vertex>
|
52 |
+
#include <beginnormal_vertex>
|
53 |
+
#include <morphnormal_vertex>
|
54 |
+
#include <skinbase_vertex>
|
55 |
+
#include <skinnormal_vertex>
|
56 |
+
#include <defaultnormal_vertex>
|
57 |
+
#include <normal_vertex>
|
58 |
+
#include <begin_vertex>
|
59 |
+
|
60 |
+
float inc = 0.001;
|
61 |
+
|
62 |
+
float r = length( position );
|
63 |
+
float theta = ( uv.x + 0.5 ) * 2. * PI;
|
64 |
+
float phi = -( uv.y + 0.5 ) * PI;
|
65 |
+
|
66 |
+
vec3 np = calc( spherical( r, theta, phi ) );
|
67 |
+
|
68 |
+
vec3 tangent = normalize( calc( spherical( r, theta + inc, phi ) ) - np );
|
69 |
+
vec3 bitangent = normalize( calc( spherical( r, theta, phi + inc ) ) - np );
|
70 |
+
transformedNormal = -normalMatrix * normalize( cross( tangent, bitangent ) );
|
71 |
+
|
72 |
+
vNormal = normalize( transformedNormal );
|
73 |
+
|
74 |
+
transformed = np;
|
75 |
+
|
76 |
+
#include <morphtarget_vertex>
|
77 |
+
#include <skinning_vertex>
|
78 |
+
#include <displacementmap_vertex>
|
79 |
+
#include <project_vertex>
|
80 |
+
#include <logdepthbuf_vertex>
|
81 |
+
#include <clipping_planes_vertex>
|
82 |
+
vViewPosition = - mvPosition.xyz;
|
83 |
+
#include <worldpos_vertex>
|
84 |
+
#include <shadowmap_vertex>
|
85 |
+
#include <fog_vertex>
|
86 |
+
#ifdef USE_TRANSMISSION
|
87 |
+
vWorldPosition = worldPosition.xyz;
|
88 |
+
#endif
|
89 |
+
}`;
|
90 |
+
|
91 |
+
export {vs};
|