Page 1 of 2

A Shader Que.

Posted: Thu May 16, 2019 2:29 am
by keprast
hi,guy. :)

There is a problem with pixel shaders.
I code extern number time,
I called the function shader: send (“time”,x) to send the value.

error:
a common error is not define but not use the variable. :|
why?

Re: A Shader Que.

Posted: Thu May 16, 2019 5:24 am
by raidho36
You never used the variable in the code so it got pruned away during shader compilation. After that, you're trying to use it but it doesn't exist.

Re: A Shader Que.

Posted: Thu May 16, 2019 9:55 am
by keprast
raidho36 wrote: Thu May 16, 2019 5:24 am You never used the variable in the code so it got pruned away during shader compilation. After that, you're trying to use it but it doesn't exist.
So I should write code like that, right?
extern number time = 0;

Re: A Shader Que.

Posted: Thu May 16, 2019 10:32 am
by keprast
raidho36 wrote: Thu May 16, 2019 5:24 am You never used the variable in the code so it got pruned away during shader compilation. After that, you're trying to use it but it doesn't exist.
I think that's wrong, obviously I need an init value to maintain this variable, right?
in love.load?

Re: A Shader Que.

Posted: Thu May 16, 2019 11:05 am
by grump
You have to actually use the variable in the shader. Not just declare it. It has to be referenced somewhere in the shader code, or else the shader compiler will remove it.

Please use the Support subforum for future help requests.

Re: A Shader Que.

Posted: Thu May 16, 2019 1:15 pm
by keprast
grump wrote: Thu May 16, 2019 11:05 am You have to actually use the variable in the shader. Not just declare it. It has to be referenced somewhere in the shader code, or else the shader compiler will remove it.

Please use the Support subforum for future help requests.
error:
assign:I-value required “time”(can’t modfiy a unifrom )

Re: A Shader Que.

Posted: Thu May 16, 2019 2:47 pm
by pgimeno
Just add this at the beginning of your code:

Code: Select all

do
  local mt = debug.getregistry().Shader
  local old_send = mt.send
  mt.send = function (shader, variable, ...)
    pcall(old_send, shader, variable, ...)
  end  
end
This should be the default behaviour, but the LÖVE developers don't seem to agree.

Re: A Shader Que.

Posted: Thu May 16, 2019 3:33 pm
by keprast
pgimeno wrote: Thu May 16, 2019 2:47 pm Just add this at the beginning of your code:

Code: Select all

do
  local mt = debug.getregistry().Shader
  local old_send = mt.send
  mt.send = function (shader, variable, ...)
    pcall(old_send, shader, variable, ...)
  end  
end
This should be the default behaviour, but the LÖVE developers don't seem to agree.
Thank you, the API manual doesn't say anything about it

Re: A Shader Que.

Posted: Thu May 16, 2019 5:20 pm
by raidho36
All errors should be explicit. The game may choose to ignore errors, but the engine shall never fail silently.

Re: A Shader Que.

Posted: Fri May 17, 2019 12:51 am
by pgimeno
Normally I would agree, but this is why I disagree in this case: viewtopic.php?p=222744#p222744

Full previous discussion with Slime starts here: viewtopic.php?p=207865#p207865

The OpenGL wiki recommends ignoring the error, keeping in mind the possibility of a misspelled name: https://www.khronos.org/opengl/wiki/GLS ... iveUniform