Yes I have, that is the reason I am asking here, once again.
I am simply trying to access the shader variables defined in the Shader Globals Project Settings in a GLSL Compute Buffer.
Right now I am using push constants which work, however, I feel as if there is a better way.
I have read pretty much all the documentation concerning Godot’s usage of GLSL, I have even dug into the Godot Source Code, However I cannot find any example of getting global shader variables in a Compute Shader in a similar way to using
global uniform
in GDShader.
To put it bluntly, I am trying to be lazy and avoid pushing the variables manually every time I want to use them in a Compute Shader.
For example, if I create new Shader Globals and want to use them in the Compute Shader, I have to manually add them like this:
float[] computePushConstant = [
renderSize.X, renderSize.Y, 0, 0,
waterColor.R, waterColor.G, waterColor.B, 0,
];
byte[] computePushConstantBytes = new byte[computePushConstant.Length * sizeof(float)];
Buffer.BlockCopy(computePushConstant, 0, computePushConstantBytes, 0, computePushConstantBytes.Length);
RenderingDevice.DrawCommandBeginLabel("Render Underwater Effect", new Color(1f, 1f, 1f));
long computeList = RenderingDevice.ComputeListBegin();
RenderingDevice.ComputeListBindComputePipeline(computeList, computePipeline);
RenderingDevice.ComputeListBindColor(computeList, computeShader, sceneBuffers, view, 0);
RenderingDevice.ComputeListBindDepth(computeList, computeShader, sceneBuffers, view, nearestSampler, 1);
RenderingDevice.ComputeListBindImage(computeList, computeShader, waterMap, 2);
RenderingDevice.ComputeListSetPushConstant(computeList, computePushConstantBytes, (uint)computePushConstantBytes.Length);
RenderingDevice.ComputeListDispatch(computeList, xGroups, yGroups, 1);
RenderingDevice.ComputeListEnd();
RenderingDevice.DrawCommandEndLabel();
And Getting them in the shader like this:
layout(push_constant, std430) uniform Params {
vec2 render_size; // Size of the Screen
vec3 water_color; // Color of the Water
} params;
However, I want to try and avoid doing that as it adds a potential for Human Error if I end up doing this again later.
Is it possible yes or no?