I am on the precipice of something very cool and exciting for me, I figured out Regex enough to parse through all the uniforms of any supplied shader, created a universal GLSL class and am on the last critical element of the puzzle before this comes together as a beta.
So my current snag that I have been at for a few days now off and on, is that I cant seem to figure out how to make a connection from the slider class I made for controlling uniform floats, (and works fine in a bunch of my other programs when I connect the vales directly through each literal “m.shader.uniformName = slider.val” manually,
but the whole point of what I am doing now is automating and removing the absurd amount of tedium I am facing in trying to experiment fluidly with fragment shaders passing images around for processing in a node based visual network.
to boil down the question:
here is my regex string find for the uniforms:
sliders = {}
-------------- uniforms ----------------
function shaderall:parseUniforms()
local NUM = 0
local pattern = 'uniform%s(%a.-)%s(%a.-);'
for TYPE, NAME in string.gmatch(self.m.shader.fragmentProgram, pattern) do
NUM = NUM + 1
print(NUM, TYPE, NAME)
self:addUniform(NUM, TYPE, NAME)
end
end
function shaderall:addUniform(NUM, TYPE, NAME)
if TYPE == 'float' then --------------------------------
sliders[NAME] = Slider(ww, hh+50*NUM, NAME)
sliders[NAME]:link(self.m.shader[NAME]) ---- CURRENTLY LINK SIMPLY RETURNS THE SLIDERVAL-----
self.m.shader[NAME] = sliders[NAME]:value() ---- THIS IS WHERE IM STUCK -----
-------LOOKS LIKE IT PASSES THE INITIAL VALUE
---------BUT NOT ANY CHANGES TO IT
…
_ and so on for vec2s sampler2Ds etc… supplying them with different widgets etc… and then I just need to connect my folder lister and make a sort of visual chaining method… but my point being most of what I need and want is not far out of grasp yet this eludes me and I have a feeling it is heavily due to something that I actually LOVE about lua, the flexibility of table obect and auto type conversion…
my best guess and what I am trying now is that I maybe need to make the slider value changes “link” to the uniform so that the updated values get passed to the self.m.shader[NAME] uniform values whenever they are updated… as it appears to get the initialized value of 0.5 from the slider in my test but when I change the slider it doesn’t update the uniform…
but this goes against what I thought I understood about the way lua deals with “referencing” tables and variables… so maybe I misunderstood, but I know why this wouldn’t work in cpp, becuase I certainly would need to send any change of value to the other variable manually… or use pointers, which is what I got the impression lua made; a sort of pointer reference when a table value passed in an = it was like making a pointer rather than copying the literal value.
in most of the scenarios I am presenting that wouldn’t they be pointing to the same memory space? or did I misread or misremember my lua manual read from the other day.
At any rate… it doesn’t seem like it should be hard and seems like a fundimental thing that is part of any complex code scenario, yet ive been searching the forum for hours and nothing is helping me get there??
if its worth anything, here are a bunch of lines of things Ive been tryign that did not work out (at least yet)
--table.insert(self.uniforms, NAME)
-- self.m.shader[NUM] = NAME
--parameter.number(NAME,0.0,1.0,0.5)
-- namer = string.format(NAME) --(self.m.shader[NAME])
-- parameter.number(self.m.shader[NAME],0.0,1.0,0.5)
-- self.m.shader[NAME] = parameter.number(NAME,0.0,1.0,0.5) -- 0.25