-
Notifications
You must be signed in to change notification settings - Fork 0
/
pet-pak-shader.html
176 lines (154 loc) · 10.6 KB
/
pet-pak-shader.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
<!DOCTYPE html>
<html lang="en" class="">
<head>
<meta charset="utf-8" />
<title>Three.js — playground</title>
<meta name="description" content="" />
<meta name="keywords" content="" />
<meta name="author" content="Bornfight" />
<meta property="og:locale" content="en_US" />
<meta property="og:site_name" content="Bornfight" />
<meta property="og:type" content="website" />
<meta property="og:url" content="https://www.bornfight.com/" />
<meta property="og:title" content="Bornfight" />
<meta property="og:image" content="static/ui/three-js-playground-cover.jpg">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta
name="viewport"
content="width=device-width, initial-scale=1.0, maximum-scale=1"
/>
<link
rel="icon"
type="image/png"
href="static/ui/favicon/favicon.png"
/>
<style id="critical-css"></style>
<link rel="stylesheet" href="static/dist/style.css" />
</head>
<script type="x-shader/x-vertex" id="shader-vertex">
uniform float mRefractionRatio;
uniform float mFresnelBias;
uniform float mFresnelScale;
uniform float mFresnelPower;
varying vec3 vReflect;
varying vec3 vRefract[3];
varying float vReflectionFactor;
void main() {
vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
vec4 worldPosition = modelMatrix * vec4( position, 1.0 );
vec3 worldNormal = normalize( mat3( modelMatrix[0].xyz, modelMatrix[1].xyz, modelMatrix[2].xyz ) * normal );
vec3 I = worldPosition.xyz - cameraPosition;
vReflect = reflect( I, worldNormal );
vRefract[0] = refract( normalize( I ), worldNormal, mRefractionRatio );
vRefract[1] = refract( normalize( I ), worldNormal, mRefractionRatio * 0.99 );
vRefract[2] = refract( normalize( I ), worldNormal, mRefractionRatio * 0.98 );
vReflectionFactor = mFresnelBias + mFresnelScale * pow( 1.0 + dot( normalize( I ), worldNormal ), mFresnelPower );
gl_Position = projectionMatrix * mvPosition;
}
</script>
<script type="x-shader/x-fragment" id="shader-fragment">
uniform samplerCube tCube;
varying vec3 vReflect;
varying vec3 vRefract[3];
varying float vReflectionFactor;
void main() {
vec4 reflectedColor = textureCube( tCube, vec3( -vReflect.x, vReflect.yz ) );
vec4 refractedColor = vec4( 1.0 );
refractedColor.r = textureCube( tCube, vec3( -vRefract[0].x, vRefract[0].yz ) ).r;
refractedColor.g = textureCube( tCube, vec3( -vRefract[1].x, vRefract[1].yz ) ).g;
refractedColor.b = textureCube( tCube, vec3( -vRefract[2].x, vRefract[2].yz ) ).b;
gl_FragColor = mix( refractedColor, reflectedColor, clamp( vReflectionFactor, 0.0, 1.0 ) );
}
</script>
<body class="is-light">
<!-- LOADER -->
<div class="o-loader"></div>
<!-- //LOADER -->
<!-- NAVIGATION -->
<div class="o-navigation js-navigation-wrapper">
<div class="c-navigation">
<div class="o-container">
<a href="index.html" class="c-logo" title="Bornfight">
<svg version="1.1" id="bornfight" xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 140 32.8" style="enable-background:new 0 0 140 32.8;" xml:space="preserve">
<g>
<path class="bornfight" d="M15.5,22.6c-2.5,2.1-4.8,2.1-7.9,2.1H0V0.5h7.4c2.9,0,5.6,0,7.7,2.4c1,1.1,1.5,2.5,1.4,4c0,2-1,3.9-2.8,4.9
c2.6,0.9,4,2.9,4,5.6C17.8,19.3,17,21.3,15.5,22.6z M8.3,5.9H5.9v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,21.1,137,21.2
L137,21.2L137,21.2z M136.8,20c0-0.2-0.1-0.4-0.3-0.5c-0.2-0.1-0.3-0.1-0.5-0.1h-0.5v1.2h0.7c0.2,0,0.3,0,0.4-0.2
C136.7,20.3,136.8,20.2,136.8,20L136.8,20z" />
</g>
</svg>
</a>
<a href="index.html" class="c-link c-link--back">
<span class="c-link__prepend">
<svg
class="u-icon u-icon--chevron-left"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 16 15"
>
<path
d="M10.4.9l1.4 1.4-5 5.2 4.9 5.2-1.5 1.4-6.1-6.6L10.4.9z"
></path>
</svg>
</span>
<span class="c-link__label">Back</span>
</a>
</div>
</div>
</div>
<!-- //NAVIGATION -->
<!-- PAGE -->
<div id="edu" class="o-page o-page--pet-pak">
<div class="o-page__inner">
<section class="o-section o-section--pet-pak">
<div class="o-section__content">
<div class="c-fbx-example-wrapper">
<div class="c-fbx-example js-model-container-shader" data-model-source="static/models/bottle.glb">
<!-- CANVAS ELEMENT WILL BE INJECTED HERE -->
</div>
</div>
</div>
</section>
</div>
</div>
<!-- FOOTER -->
<div class="o-footer">
<footer class="c-footer">
<div class="o-container">
<a href="https://github.com/kvidek/three.js-playground" target="_blank" class="c-social-link"
title="Github">
<span class="c-link__icon">
<svg class="u-icon u-icon--github" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 999.937 999.937"><path
d="M0 499.968c0-138.012 48.825-255.843 146.476-353.493C244.125 48.825 361.956 0 499.969 0 637.98 0 755.811 48.825 853.462 146.475c97.649 97.65 146.475 215.481 146.475 353.493s-48.825 255.843-146.475 353.493c-97.65 97.65-215.481 146.476-353.493 146.476-138.013 0-255.844-48.825-353.493-146.476C48.825 755.812 0 637.979 0 499.968zm54.684 0c0 122.389 43.617 227.199 130.851 314.434 87.234 87.233 192.045 130.851 314.434 130.851 122.388 0 227.199-43.617 314.433-130.851 87.234-87.234 130.851-192.045 130.851-314.434 0-122.388-43.616-227.199-130.851-314.433C727.168 98.301 622.356 54.684 499.969 54.684c-122.389 0-227.199 43.617-314.434 130.851C98.301 272.769 54.684 377.58 54.684 499.968zm140.617 107.415c-2.604-2.604-2.604-5.208 0-7.812 5.207-5.208 11.718-7.161 19.529-5.859 7.812 1.302 12.369 2.604 13.671 3.906 9.114 3.906 19.205 12.694 30.271 26.366 11.066 13.671 19.855 23.11 26.366 28.318 31.248 26.04 63.146 27.993 95.696 5.859 2.604-9.114 6.836-16.926 12.694-23.437 5.858-6.51 11.393-11.066 16.601-13.671 5.209-2.604 14.323-6.51 27.343-11.718-42.967-3.906-77.795-11.393-104.486-22.46s-47.849-25.063-63.473-41.989c-20.832-23.436-33.527-54.033-38.084-91.791-4.558-37.758-1.628-72.261 8.789-103.509 7.812-19.53 18.879-37.106 33.2-52.731-10.416-32.55-8.463-69.657 5.859-111.321 41.664 2.604 79.422 16.926 113.274 42.966 65.1-16.926 132.804-17.577 203.111-1.953 9.114-6.51 23.111-14.647 41.989-24.413 18.879-9.765 42.641-15.299 71.285-16.601 5.208 14.322 8.789 31.248 10.742 50.778s.977 37.758-2.929 54.684c29.945 31.248 45.569 72.912 46.871 124.992 0 41.664-7.16 76.167-21.482 103.509s-39.711 50.127-76.167 68.354c-24.738 11.719-57.288 18.879-97.65 21.483 18.229 9.114 31.574 18.554 40.037 28.319 8.464 9.765 13.997 25.063 16.602 45.895v61.521l1.952 59.566c3.906 6.511 8.464 12.044 13.672 16.602 5.208 4.557 9.765 7.812 13.671 9.765 3.905 1.953 5.208 4.883 3.905 8.789-1.302 3.906-6.51 5.859-15.623 5.859-22.135 0-39.711-7.812-52.731-23.437-3.906-6.51-5.859-14.321-5.859-23.436v-93.744c0-10.416-2.604-17.903-7.812-22.46-5.208-4.558-10.416-7.487-15.624-8.789v123.039c0 22.134 2.604 36.456 7.812 42.966s8.463 13.021 9.766 19.53c1.302 1.302.325 2.278-2.93 2.929-3.254.65-8.788-.325-16.601-2.929-16.926-3.906-28.644-12.695-35.154-26.366-6.51-13.671-9.765-28.319-9.765-43.943V667.926H488.25v121.086c0 15.624-3.256 30.598-9.766 44.919-9.113 18.229-26.04 27.993-50.777 29.295-3.906-1.302-5.859-2.604-5.859-3.905 1.302-1.303 5.208-7.812 11.718-19.53 1.302-2.604 2.93-7.812 4.883-15.624 1.954-7.812 2.93-16.926 2.93-27.342v-123.04c-5.208 1.302-10.091 4.231-14.648 8.789s-6.836 12.044-6.836 22.46v93.744c0 9.113-1.953 16.926-5.859 23.436-11.718 15.624-29.295 23.437-52.73 23.437-9.114 0-14.322-1.953-15.624-5.859-1.303-2.604-.977-4.883.977-6.836s4.883-4.232 8.789-6.836c3.906-2.604 6.51-4.558 7.812-5.859 5.208-3.906 9.113-9.114 11.718-15.624 3.906-5.208 4.882-18.879 2.929-41.013s-2.279-36.456-.977-42.966c-33.853 11.718-68.355 5.858-103.51-17.577-10.416-10.416-20.832-25.39-31.248-44.919-7.812-14.323-23.436-31.249-46.871-50.779z" /></svg>
</span>
</a>
<p class="u-b2">Copyright © 2020. — <a href="mailto:[email protected]">[email protected]</a>
</p>
</div>
</footer>
</div>
<!-- //FOOTER -->
<!-- //PAGE -->
<script src="static/dist/vendor.js"></script>
<script src="static/dist/bundle.js" defer></script>
</body>
</html>