Skip to content

Commit 73345ff

Browse files
committed
sketch finish
1 parent bc12e73 commit 73345ff

File tree

1 file changed

+22
-28
lines changed

1 file changed

+22
-28
lines changed

preview/global/sketch.js

Lines changed: 22 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,16 @@ let pixellizeShader;
1212
let fresnelShader;
1313
let bloomShader;
1414

15-
1615
function fresnelShaderCallback() {
1716
const fresnelPower = uniformFloat(2);
1817
const fresnelBias = uniformFloat(-0.1);
1918
const fresnelScale = uniformFloat(2);
2019
getCameraInputs((inputs) => {
21-
let myValue = [1,0,0];
2220
let n = normalize(inputs.normal);
23-
If(n == n, () => assign(myValue, 1));
2421
let v = normalize(-inputs.position);
2522
let base = 1.0 - dot(n, v);
2623
let fresnel = fresnelScale * pow(base, fresnelPower) + fresnelBias;
27-
28-
29-
let col = mix(myValue, [1, .5, .7], fresnel);
30-
24+
let col = mix([0, 0, 0], [1, .5, .7], fresnel);
3125
inputs.color = [col, 1];
3226
return inputs;
3327
});
@@ -48,7 +42,7 @@ function starShaderCallback() {
4842
let r = skyRadius;
4943
r *= 1.5 * sin(phi);
5044
let x = r * sin(phi) * cos(theta);
51-
let y = r *1.5* cos(phi);
45+
let y = r * 1.5 * cos(phi);
5246
let z = r * sin(phi) * sin(theta);
5347
return [x, y, z];
5448
}
@@ -66,7 +60,7 @@ function starShaderCallback() {
6660
}
6761

6862
function pixellizeShaderCallback() {
69-
const pixelSize = uniformFloat(()=> width/2);
63+
const pixelSize = uniformFloat(()=> width*.75);
7064
getColor((input, canvasContent) => {
7165
let coord = input.texCoord;
7266
coord = floor(coord * pixelSize) / pixelSize;
@@ -80,51 +74,51 @@ function bloomShaderCallback() {
8074
getColor((input, canvasContent) => {
8175
const blurredCol = texture(canvasContent, input.texCoord);
8276
const originalCol = texture(preBlur, input.texCoord);
83-
const brightPass = max(originalCol - 0.3, 0.7) * 1.2;
77+
const brightPass = max(originalCol, 0.3) * 1.5;
8478
const bloom = originalCol + blurredCol * brightPass;
8579
return bloom;
8680
});
8781
}
8882

8983
async function setup(){
9084
createCanvas(windowWidth, windowHeight, WEBGL);
91-
stars = buildGeometry(() => sphere(20, 4, 2))
85+
stars = buildGeometry(() => sphere(30, 4, 2))
9286
originalFrameBuffer = createFramebuffer();
9387

94-
// starShader = baseMaterialShader().modify(starShaderCallback);
95-
// starStrokeShader = baseStrokeShader().modify(starShaderCallback)
88+
starShader = baseMaterialShader().modify(starShaderCallback);
89+
starStrokeShader = baseStrokeShader().modify(starShaderCallback)
9690
fresnelShader = baseColorShader().modify(fresnelShaderCallback);
97-
// bloomShader = baseFilterShader().modify(bloomShaderCallback);
98-
// pixellizeShader = baseFilterShader().modify(pixellizeShaderCallback);
91+
bloomShader = baseFilterShader().modify(bloomShaderCallback);
92+
pixellizeShader = baseFilterShader().modify(pixellizeShaderCallback);
9993
}
10094

10195
function draw(){
10296
originalFrameBuffer.begin();
10397
background(0);
104-
orbitControl();
98+
orbitControl();
10599

106-
// push()
107-
// strokeWeight(4)
108-
// stroke(255,0,0)
109-
// rotateX(PI/2 + millis() * 0.0005);
110-
// fill(255,100, 150)
111-
// strokeShader(starStrokeShader)
112-
// shader(starShader);
113-
// model(stars, 5000);
114-
// pop()
100+
push()
101+
strokeWeight(4)
102+
stroke(255,0,0)
103+
rotateX(PI/2 + millis() * 0.0005);
104+
fill(255,100, 150)
105+
strokeShader(starStrokeShader)
106+
shader(starShader);
107+
model(stars, 2000);
108+
pop()
115109

116110
push()
117111
shader(fresnelShader)
118112
noStroke()
119113
sphere(500);
120114
pop()
115+
filter(pixellizeShader);
121116

122-
// filter(pixellizeShader);
123117
originalFrameBuffer.end();
124118

125119
imageMode(CENTER)
126120
image(originalFrameBuffer, 0, 0)
127121

128-
// filter(BLUR, 20)
129-
// filter(bloomShader);
122+
filter(BLUR, 20)
123+
filter(bloomShader);
130124
}

0 commit comments

Comments
 (0)