From 800c6bbf9a43ff5cbbef18640399f8263becdf9f Mon Sep 17 00:00:00 2001 From: Tanasart Date: Fri, 20 Dec 2024 10:36:55 +0700 Subject: [PATCH] [Caustic] Add intensity property. --- scripts/node_caustic/node_caustic.gml | 6 +++++- shaders/sh_water_caustic/sh_water_caustic.fsh | 5 +++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/scripts/node_caustic/node_caustic.gml b/scripts/node_caustic/node_caustic.gml index e663129c0..b259506da 100644 --- a/scripts/node_caustic/node_caustic.gml +++ b/scripts/node_caustic/node_caustic.gml @@ -19,8 +19,12 @@ function Node_Caustic(_x, _y, _group = noone) : Node_Shader_Generator(_x, _y, _g .setDisplay(VALUE_DISPLAY.slider, { range: [ 0, 2, 0.01 ] }); addShaderProp(SHADER_UNIFORM.float, "detail"); + newInput(6, nodeValue_Float("Intensity", self, 1)) + .setDisplay(VALUE_DISPLAY.slider, { range: [ 0, 4, 0.01 ] }); + addShaderProp(SHADER_UNIFORM.float, "intensity"); + input_display_list = [ ["Output", true], 0, - ["Noise", false], 1, 2, 4, 5, + ["Noise", false], 1, 2, 6, 4, 5, ]; } \ No newline at end of file diff --git a/shaders/sh_water_caustic/sh_water_caustic.fsh b/shaders/sh_water_caustic/sh_water_caustic.fsh index 59b9d9393..932e055bb 100644 --- a/shaders/sh_water_caustic/sh_water_caustic.fsh +++ b/shaders/sh_water_caustic/sh_water_caustic.fsh @@ -6,6 +6,7 @@ varying vec4 v_vColour; uniform float seed; uniform float progress; uniform float detail; +uniform float intensity; uniform vec2 dimension; uniform vec2 position; @@ -95,6 +96,6 @@ void main() { n = snoise( pos ); // noise [-1..+1] -> color - float intensity = exp(n.w * 3. - 1.5); - gl_FragColor = vec4(vec3(intensity), 1.); + float i = exp(n.w * 3. - 1.5) * intensity; + gl_FragColor = vec4(vec3(i), 1.); }