A Shader Que.

Show off your games, demos and other (playable) creations.
keprast
Prole
Posts: 6
Joined: Wed Apr 17, 2019 7:31 am

A Shader Que.

Post 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?
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: A Shader Que.

Post 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.
keprast
Prole
Posts: 6
Joined: Wed Apr 17, 2019 7:31 am

Re: A Shader Que.

Post 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;
keprast
Prole
Posts: 6
Joined: Wed Apr 17, 2019 7:31 am

Re: A Shader Que.

Post 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?
grump
Party member
Posts: 947
Joined: Sat Jul 22, 2017 7:43 pm

Re: A Shader Que.

Post 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.
keprast
Prole
Posts: 6
Joined: Wed Apr 17, 2019 7:31 am

Re: A Shader Que.

Post 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 )
User avatar
pgimeno
Party member
Posts: 3544
Joined: Sun Oct 18, 2015 2:58 pm

Re: A Shader Que.

Post 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.
keprast
Prole
Posts: 6
Joined: Wed Apr 17, 2019 7:31 am

Re: A Shader Que.

Post 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
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: A Shader Que.

Post by raidho36 »

All errors should be explicit. The game may choose to ignore errors, but the engine shall never fail silently.
User avatar
pgimeno
Party member
Posts: 3544
Joined: Sun Oct 18, 2015 2:58 pm

Re: A Shader Que.

Post 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
Post Reply

Who is online

Users browsing this forum: No registered users and 46 guests