Skip to content

Commit 9dfd454

Browse files
committed
use varying in sketch
1 parent 40fd5a3 commit 9dfd454

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

preview/global/sketch.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,23 @@ function fresnelShaderCallback() {
1818
const fresnelBias = uniformFloat(-0.1);
1919
const fresnelScale = uniformFloat(2);
2020
const mouseIntensity = uniformVector2(()=>[map(mouseX, 0, width, 0, 0.15), map(mouseY, 0, height, 0, 0.15)]);
21+
let val = varyingFloat('val');
22+
let colr = varyingVector4('colr');
2123

2224
getCameraInputs((inputs) => {
2325
let n = normalize(inputs.normal);
2426
let v = normalize(-inputs.position);
2527
let base = 1.0 - dot(n, v);
28+
val = mouseIntensity.y;
2629
let fresnel = fresnelScale * pow(base, fresnelPower) + fresnelBias;
2730
let col = mix([mouseIntensity.y, 0, mouseIntensity.x], [1, .5, .7], fresnel);
2831
inputs.color = [col.x, col.y, col.z, 1];
2932
return inputs;
3033
});
34+
35+
getFinalColor((col) => {
36+
return col * [val,col.y,col.y,1];
37+
})
3138
}
3239

3340
function starShaderCallback() {

0 commit comments

Comments
 (0)