Skip to content

refraction => dispersion renaming #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/app/hero/liquid-frag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ uniform float u_time;
uniform float u_ratio;
uniform float u_img_ratio;
uniform float u_patternScale;
uniform float u_refraction;
uniform float u_dispersion;
uniform float u_edge;
uniform float u_patternBlur;
uniform float u_liquid;
Expand Down Expand Up @@ -182,13 +182,13 @@ void main() {
refr_b += (smoothstep(0., .4, uv.y) * smoothstep(.8, .1, uv.y)) * (smoothstep(.4, .6, bulge) * smoothstep(.8, .4, bulge));
refr_b -= .2 * edge;

refr_r *= u_refraction;
refr_b *= u_refraction;
refr_r *= u_dispersion;
refr_b *= u_dispersion;

vec3 w = vec3(thin_strip_1_width, thin_strip_2_width, wide_strip_ratio);
w[1] -= .02 * smoothstep(.0, 1., edge + bulge);
float stripe_r = mod(dir + refr_r, 1.);
float r = get_color_channel(color1.r, color2.r, stripe_r, w, 0.02 + .03 * u_refraction * bulge, bulge);
float r = get_color_channel(color1.r, color2.r, stripe_r, w, 0.02 + .03 * u_dispersion * bulge, bulge);
float stripe_g = mod(dir, 1.);
float g = get_color_channel(color1.g, color2.g, stripe_g, w, 0.01 / (1. - diagonal), bulge);
float stripe_b = mod(dir - refr_b, 1.);
Expand Down
6 changes: 3 additions & 3 deletions src/hero/canvas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { toast } from 'sonner';
// uniform float u_ratio;
// uniform float u_img_ratio;
// uniform float u_patternScale;
// uniform float u_refraction;
// uniform float u_dispersion;
// uniform float u_edge;
// uniform float u_patternBlur;
// uniform float u_liquid;
Expand All @@ -27,7 +27,7 @@ void main() {

export type ShaderParams = {
patternScale: number;
refraction: number;
dispersion: number;
edge: number;
patternBlur: number;
liquid: number;
Expand Down Expand Up @@ -56,7 +56,7 @@ export function Canvas({
gl.uniform1f(uniforms.u_patternBlur, params.patternBlur);
gl.uniform1f(uniforms.u_time, 0);
gl.uniform1f(uniforms.u_patternScale, params.patternScale);
gl.uniform1f(uniforms.u_refraction, params.refraction);
gl.uniform1f(uniforms.u_dispersion, params.dispersion);
gl.uniform1f(uniforms.u_liquid, params.liquid);
}

Expand Down
12 changes: 6 additions & 6 deletions src/hero/hero.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -265,12 +265,12 @@ export function Hero({ imageId }: HeroProps) {
</div>

<Control
label="Refraction"
value={state.refraction}
min={params.refraction.min}
max={params.refraction.max}
step={params.refraction.step}
onValueChange={(value) => setState((state) => ({ ...state, refraction: value }))}
label="dispersion"
value={state.dispersion}
min={params.dispersion.min}
max={params.dispersion.max}
step={params.dispersion.step}
onValueChange={(value) => setState((state) => ({ ...state, dispersion: value }))}
/>
<Control
label="Edge"
Expand Down
4 changes: 2 additions & 2 deletions src/hero/params.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
export type ShaderParams = {
patternScale: number;
refraction: number;
dispersion: number;
edge: number;
patternBlur: number;
liquid: number;
speed: number;
};

export const params = {
refraction: {
dispersion: {
min: 0,
max: 0.06,
step: 0.001,
Expand Down