Skip to content
Merged
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
544 changes: 273 additions & 271 deletions packages/use-shader-fx/build/use-shader-fx.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/use-shader-fx/build/use-shader-fx.js.map

Large diffs are not rendered by default.

112 changes: 56 additions & 56 deletions packages/use-shader-fx/build/use-shader-fx.umd.cjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/use-shader-fx/build/use-shader-fx.umd.cjs.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions packages/use-shader-fx/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/use-shader-fx/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@funtech-inc/use-shader-fx",
"version": "1.1.35",
"version": "1.1.36",
"description": "⚡️ More FXs, Less GLSL",
"main": "./build/use-shader-fx.umd.cjs",
"module": "./build/use-shader-fx.js",
Expand Down
18 changes: 2 additions & 16 deletions packages/use-shader-fx/src/fxs/utils/useHSV/shader/main.frag
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,9 @@ uniform sampler2D u_texture;
uniform float u_brightness;
uniform float u_saturation;

vec3 rgb2hsv(vec3 c)
{
vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));
vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));
#usf <rgb2hsv>

float d = q.x - min(q.w, q.y);
float e = 1.0e-10;
return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
}

vec3 hsv2rgb(vec3 c)
{
vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
}
#usf <hsv2rgb>

void main() {
vec4 tex = texture2D(u_texture, vUv);
Expand Down
8 changes: 7 additions & 1 deletion packages/use-shader-fx/src/libs/shaders/ShaderChunk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@ import coverTexture from "./shaderChunk/coverTexture.glsl";
import fxBlending from "./shaderChunk/fxBlending.glsl";
import planeVertex from "./shaderChunk/planeVertex.glsl";
import defaultVertex from "./shaderChunk/defaultVertex.glsl";
import hsv2rgb from "./shaderChunk/hsv2rgb.glsl";
import rgb2hsv from "./shaderChunk/rgb2hsv.glsl";

export type ShaderChunkTypes =
| "wobble3D"
| "snoise"
| "coverTexture"
| "fxBlending"
| "planeVertex"
| "defaultVertex";
| "defaultVertex"
| "hsv2rgb"
| "rgb2hsv";

export const ShaderChunk: { [K in ShaderChunkTypes]: string } = Object.freeze({
wobble3D,
Expand All @@ -20,4 +24,6 @@ export const ShaderChunk: { [K in ShaderChunkTypes]: string } = Object.freeze({
fxBlending,
planeVertex,
defaultVertex,
hsv2rgb,
rgb2hsv,
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
vec3 hsv2rgb(vec3 c)
{
vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
}
10 changes: 10 additions & 0 deletions packages/use-shader-fx/src/libs/shaders/shaderChunk/rgb2hsv.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
vec3 rgb2hsv(vec3 c)
{
vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));
vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));

float d = q.x - min(q.w, q.y);
float e = 1.0e-10;
return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
}
2 changes: 1 addition & 1 deletion packages/use-shader-fx/types/libs/shaders/ShaderChunk.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export type ShaderChunkTypes = "wobble3D" | "snoise" | "coverTexture" | "fxBlending" | "planeVertex" | "defaultVertex";
export type ShaderChunkTypes = "wobble3D" | "snoise" | "coverTexture" | "fxBlending" | "planeVertex" | "defaultVertex" | "hsv2rgb" | "rgb2hsv";
export declare const ShaderChunk: {
[K in ShaderChunkTypes]: string;
};
2 changes: 1 addition & 1 deletion packages/use-shader-fx/types/utils/useResolution.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as THREE from "three";
import { Size } from "@react-three/fiber";
/**0
/**
* @params dpr if dpr is set, it returns the resolution which is size multiplied by dpr.
*/
export declare const useResolution: (size: Size, dpr?: number | false) => THREE.Vector2;