@joedad said:
Okay - I must have missed a tutorial note. Why do you have to select local to scene in the inspector when I trying to pass the uniform code to the shader? I made a couple of changes... to my script which is shown in the two pictures; I changed "self.get_material().set_shader_param()" to "self.material.set_shader_param()".
2nd - I simply clicked "local to scene" as true. Then it started updating my parameters real time! If anyone has a quick answer to why the need for local to scene so I understand better I would appreciate it.
EDIT: The local to scene had nothing to do with it. I tried to use "get_material()" and apparently that did not work. I changed back to self.material. and it works.
Unfortunately, can't get my shader to actually darken the screen....
UPDATE: Shader is working! Easily and very well I might add. So my trouble was not passing the uniform to the shader code and it was not finding the "correct shader material". The trouble turned out to be trying to change variables within the shader incorrectly. I simply changed my method of updating the shader to be based on the global position and ocean depth instead of trying to get each screen line to have a different depth factor. I feed the Depth Factor from the gd_script into the shader. Turns out this is a LOT simpler and looks more realistic in my opinion. Final Shader code below....
shader_type canvas_item;
uniform vec4 deep_color : hint_color = vec4(0.0, 0.0, 0.0, 1.0);
uniform float depth_factor;
void fragment() {
vec3 c = textureLod(SCREEN_TEXTURE, SCREEN_UV, 0.0).rgb;
c.rgb = mix(c.rgb, deep_color.rgb, depth_factor);
COLOR.rgb = c;
}