MCPcopy Index your code
hub / github.com/processing/p5.js / fresnelShaderCallback

Function fresnelShaderCallback

test/unit/visual/cases/webgpu.js:204–218  ·  view source on GitHub ↗
({ p5 })

Source from the content-addressed store, hash-verified

202 const originalImage = p5.createFramebuffer();
203
204 function fresnelShaderCallback({ p5 }) {
205 const fresnelPower = p5.uniformFloat(2);
206 const fresnelBias = p5.uniformFloat(-0.1);
207 const fresnelScale = p5.uniformFloat(2);
208
209 p5.getCameraInputs((inputs) => {
210 let n = p5.normalize(inputs.normal);
211 let v = p5.normalize(-inputs.position);
212 let base = 1.0 - p5.dot(n, v);
213 let fresnel = fresnelScale * p5.pow(base, fresnelPower) + fresnelBias;
214 let col = p5.mix([0, 0, 0], [1, .5, .7], fresnel);
215 inputs.color = [col, 1];
216 return inputs;
217 });
218 }
219
220 const starShader = p5.baseMaterialShader().modify(starShaderCallback, { p5 });
221 const starStrokeShader = p5.baseStrokeShader().modify(starShaderCallback, { p5 })

Callers

nothing calls this directly

Calls 2

dotMethod · 0.80
normalizeMethod · 0.45

Tested by

no test coverage detected