michaelbrusegard / WebGL-Fluid-Enhanced

WebGL Fluid Simulation for modern webpages (works even on mobile).
https://michaelbrusegard.github.io/WebGL-Fluid-Enhanced/
MIT License
40 stars 7 forks source link

Not able to use black in COLOR_PALETTE #12

Open shaun-visser opened 2 months ago

shaun-visser commented 2 months ago

Love the work! Setting canvas to a white background - I'm not able to set black in the color pallet e.g. useEffect(() => { webGLFluidEnhanced.simulation(canvasRef.current!, { SIM_RESOLUTION: 128, // Resolution of the simulation grid DYE_RESOLUTION: 1024, // Resolution of the dye grid CAPTURE_RESOLUTION: 512, // Resolution of captured frames DENSITY_DISSIPATION: 1, // Rate at which density dissipates VELOCITY_DISSIPATION: 0.2, // Rate at which velocity dissipates PRESSURE: 0.8, // Pressure value used in the simulation PRESSURE_ITERATIONS: 20, // Number of pressure iterations CURL: 10, // Curl value used in the simulation INITIAL: false, // Enables splats on initial load SPLAT_AMOUNT: 5, // Number of initial splats (Random number between n and n * 5) SPLAT_RADIUS: 0.25, // Radius of the splats SPLAT_FORCE: 6000, // Force applied by the splats SPLAT_KEY: '', // Keyboard key to spawn new splats (empty to disable) SHADING: false, // Enables shading in the visualization COLORFUL: true, // Enables rapid changing of colors COLOR_UPDATE_SPEED: 10, // Speed of color update COLOR_PALETTE: ['#000000', '#000000', '#000000', '#000000', '#000000'], // Custom color palette (empty by default, uses hex colors) HOVER: true, // Enables interaction on hover BACK_COLOR: '#ffffff', // Background color of the canvas TRANSPARENT: false, // Makes the canvas transparent if true BRIGHTNESS: 1, // Color brightness (Recommend lower than 1.0 if BLOOM is true) BLOOM: false, // Enables bloom effect BLOOM_ITERATIONS: 8, // Number of bloom effect iterations BLOOM_RESOLUTION: 256, // Resolution of the bloom effect BLOOM_INTENSITY: 0.8, // Intensity of the bloom effect BLOOM_THRESHOLD: 0.6, // Threshold for the bloom effect BLOOM_SOFT_KNEE: 0.7, // Soft knee value for the bloom effect SUNRAYS: false, // Enables sunrays effect SUNRAYS_RESOLUTION: 196, // Resolution of the sunrays effect SUNRAYS_WEIGHT: 1.0, // Weight of the sunrays effect }); }, []);

michaelbrusegard commented 2 weeks ago

I think that is a limitation of how the library calculates colors. I will take a look at a feature to fix it when I have time