cambios postproduccion

This commit is contained in:
2026-09-21 11:08:17 -03:00
parent e36ec1e8ca
commit 3b38b9b760
20 changed files with 128 additions and 123 deletions
+26 -26
View File
@@ -1,6 +1,6 @@
"use strict";
// ===== CONFIGURACIÓN DEL EFECTO (Idéntica a fluid - copia.js) =====
// ===== CONFIGURACIÓN DEL EFECTO (Parámetros calibrados de fluid - copia.js) =====
const config = {
TEXTURE_DOWNSAMPLE: 1,
DENSITY_DISSIPATION: 0.975,
@@ -16,15 +16,15 @@ function getBrandColors() {
const isDark = document.documentElement.getAttribute('data-theme') === 'dark';
if (isDark) {
return [
[0.920, 0.120, 0.420], // Carmesí / Fucsia luminoso (#EA1E6B)
[0.080, 0.650, 0.780], // Teal cian luminoso (#14A6C7)
[0.850, 0.500, 0.720] // Rosa suave (#D980B8)
[0.850, 0.080, 0.380], // Carmesí / Fucsia vivo de marca
[0.050, 0.450, 0.550], // Teal profundo
[0.650, 0.200, 0.450] // Plum medio
];
} else {
return [
[0.729, 0.071, 0.302], // Bordo de marca (#BA124D)
[0.000, 0.247, 0.322], // Teal de marca (#003F52)
[0.780, 0.280, 0.420] // Carmesí (#C7476B)
[0.550, 0.150, 0.280] // Plum suave
];
}
}
@@ -35,7 +35,7 @@ let targetColor = brandColors[1];
let transitionProgress = 0;
const transitionSpeed = 0.008;
// Observador para detectar el switch de tema en tiempo real
// Observador para detectar cambios en data-theme
const themeObserver = new MutationObserver(() => {
brandColors = getBrandColors();
currentColor = brandColors[0];
@@ -66,7 +66,7 @@ let pointers = [];
function getWebGLContext(canvas) {
let params = {
alpha: true, // Transparente para respetar el fondo CSS
premultipliedAlpha: false, // Clave para composición limpia sobre el fondo
premultipliedAlpha: false, // Clave para evitar bordes oscuros o quemados
depth: false,
stencil: false,
antialias: false
@@ -120,7 +120,7 @@ function pointerPrototype() {
}
pointers.push(new pointerPrototype());
// ===== SHADERS BASE =====
// ===== SHADERS =====
let GLProgram = (function () {
function GLProgram(vertexShader, fragmentShader) {
if (!(this instanceof GLProgram)) throw new TypeError("Cannot call a class as a function");
@@ -160,7 +160,7 @@ let clearShader = compileShader(
"precision highp float; precision mediump sampler2D; varying vec2 vUv; uniform sampler2D uTexture; uniform float value; void main () { gl_FragColor = value * texture2D(uTexture, vUv); }"
);
// SHADER DE VISUALIZACIÓN ADAPTATIVO AL FONDO Y TEMA
// SHADER DE VISUALIZACIÓN: compatible con GLSL ES 1.0 y libre de blanqueo
let displayShader = compileShader(
gl.FRAGMENT_SHADER,
`precision highp float;
@@ -171,22 +171,25 @@ let displayShader = compileShader(
void main () {
vec4 c = texture2D(uTexture, vUv);
float density = max(c.r, max(c.g, c.b));
float len = length(c.rgb);
if (density < 0.001) {
gl_FragColor = vec4(0.0);
// Sintaxis 100% compatible con WebGL 1 y 2 (4 componentes)
if (len < 0.001) {
gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);
return;
}
// Normalización cromática: conserva el matiz puro de la marca y previene el blanco
vec3 pureColor = c.rgb / len;
if (uIsDark > 0.5) {
// MODO OSCURO: Núcleo luminoso y bordes de humo orgánico
float alpha = clamp(density * 2.2, 0.0, 0.90);
vec3 rgb = c.rgb * (1.15 + density * 1.3);
gl_FragColor = vec4(clamp(rgb, 0.0, 1.0), alpha);
// MODO OSCURO: color rico con presencia viva sin deslumbrar
float alpha = clamp(len * 1.8, 0.0, 0.80);
gl_FragColor = vec4(pureColor, alpha);
} else {
// MODO CLARO: Tinte de acuarela suave que no ensucia el fondo claro
float alpha = clamp(density * 1.35, 0.0, 0.45);
gl_FragColor = vec4(c.rgb, alpha);
// MODO CLARO: tinte traslúcido tipo acuarela
float alpha = clamp(len * 1.2, 0.0, 0.38);
gl_FragColor = vec4(pureColor, alpha);
}
}`
);
@@ -211,7 +214,6 @@ let divergenceShader = compileShader(
"precision highp float; precision mediump sampler2D; varying vec2 vUv; varying vec2 vL; varying vec2 vR; varying vec2 vT; varying vec2 vB; uniform sampler2D uVelocity; vec2 sampleVelocity (in vec2 uv) { vec2 multiplier = vec2(1.0, 1.0); if (uv.x < 0.0) { uv.x = 0.0; multiplier.x = -1.0; } if (uv.x > 1.0) { uv.x = 1.0; multiplier.x = -1.0; } if (uv.y < 0.0) { uv.y = 0.0; multiplier.y = -1.0; } if (uv.y > 1.0) { uv.y = 1.0; multiplier.y = -1.0; } return multiplier * texture2D(uVelocity, uv).xy; } void main () { float L = sampleVelocity(vL).x; float R = sampleVelocity(vR).x; float T = sampleVelocity(vT).y; float B = sampleVelocity(vB).y; float div = 0.5 * (R - L + T - B); gl_FragColor = vec4(div, 0.0, 0.0, 1.0); }"
);
// RESTAURACIÓN EXACTA DE LA FÍSICA DE COPIA (Sin inversión de ejes)
let curlShader = compileShader(
gl.FRAGMENT_SHADER,
"precision highp float; precision mediump sampler2D; varying vec2 vUv; varying vec2 vL; varying vec2 vR; varying vec2 vT; varying vec2 vB; uniform sampler2D uVelocity; void main () { float L = texture2D(uVelocity, vL).y; float R = texture2D(uVelocity, vR).y; float T = texture2D(uVelocity, vT).x; float B = texture2D(uVelocity, vB).x; float vorticity = R - L - T + B; gl_FragColor = vec4(vorticity, 0.0, 0.0, 1.0); }"
@@ -316,12 +318,13 @@ function splat(x, y, dx, dy, color) {
velocity.swap();
gl.uniform1i(splatProgram.uniforms.uTarget, density.first[2]);
gl.uniform3f(splatProgram.uniforms.color, color[0] * 0.35, color[1] * 0.35, color[2] * 0.35);
// Inyección equilibrada
gl.uniform3f(splatProgram.uniforms.color, color[0] * 0.28, color[1] * 0.28, color[2] * 0.28);
blit(density.second[1]);
density.swap();
}
// ===== RESIZE SIN DESFASES =====
// ===== RESIZE =====
function resizeCanvas() {
if (canvas.width !== canvas.clientWidth || canvas.height !== canvas.clientHeight) {
canvas.width = canvas.clientWidth;
@@ -345,7 +348,7 @@ function isMouseOverTextElement(target) {
return false;
}
// ===== CONTROL DE MOUSE CENTRADO Y SIMÉTRICO =====
// ===== CAPTURA DE MOUSE SIMÉTRICA Y CENTRADA =====
let isFirstMove = true;
document.addEventListener("mousemove", function (e) {
@@ -353,7 +356,6 @@ document.addEventListener("mousemove", function (e) {
const currentX = e.clientX - rect.left;
const currentY = e.clientY - rect.top;
// Evita el salto o raya diagonal al entrar por primera vez
if (isFirstMove) {
pointers[0].x = currentX;
pointers[0].y = currentY;
@@ -381,7 +383,6 @@ document.addEventListener("mousemove", function (e) {
pointers[0].color = colorArr;
pointers[0].moved = true;
// Multiplicador simétrico de fluid - copia.js (10.0 en fondo, 8.0 en texto)
const multiplier = overText ? 8.0 : 10.0;
pointers[0].dx = (currentX - pointers[0].x) * multiplier;
@@ -513,7 +514,6 @@ function update() {
displayProgram.bind();
gl.uniform1i(displayProgram.uniforms.uTexture, density.first[2]);
// Informar al shader si estamos en modo oscuro
const isDarkTheme = document.documentElement.getAttribute('data-theme') === 'dark';
if (displayProgram.uniforms.uIsDark !== undefined) {
gl.uniform1f(displayProgram.uniforms.uIsDark, isDarkTheme ? 1.0 : 0.0);