Hi there, I have a rather technical question regarding love.graphics.newShader():
I have the same shader code running in a dozen different variations (with different parameters, configured on each shader instance using shader:send). I wonder if I need to call love.graphics.newShader() every time I need a new shader instance. This seems to recompile the shader each time (telling from the time it takes).
I wonder if I can just compile the shader code once and then use it to build 20 shader instances from that shader (without recompiling)?
love.graphics.newShader and instances
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: love.graphics.newShader and instances
Short answer is that you can't. You need to individually compile each instance. Do not use if-else statements within shader to do this - that will be slower.
Re: love.graphics.newShader and instances
If the shader code is the same and the parameters are "configured" using shader:send, you only need one shader instance.
Re: love.graphics.newShader and instances
Yes and switching parameters using "send" will be slower than switching shaders - as I said.
Re: love.graphics.newShader and instances
As you said where exactly?
If recompiling each with different parameters is really the best option (I'd check first), you could as well recompile the shaders with the parameters built into them, and save the sends.
Re: love.graphics.newShader and instances
That was implied. Excluding backwards approaches that drop performance to zero, your only way of doing this is through "send".As you said where exactly?
You'll be changing shaders anyway, so changing it to the right shader is free, compared to changing shader and then sending a bunch of data on top of that. Additionally, the if statement in shaders isn't free, on uniforms its cost normally minimal but not necessarily, it could still result in heavy performance penalties for just having it there. Every GPU programming book and programming manual says not to have if statements in the shader code unless absolutely necessary - and for good reason. Lastly, fewer milliseconds of one-time loading screen duration comes nowhere close to competing with fewer milliseconds of rendering time per frame, that's sort of a no-brainer.
- zorg
- Party member
- Posts: 3470
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: love.graphics.newShader and instances
Just tell me this, when exactly does shader:send imply that the sent data will necessarily correlate to the code having a branch in it? Because from what i saw, this was the source of the miscommunication.
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Re: love.graphics.newShader and instances
Because if code branches at anything other than a uniform (which you put there through "send"), performance will suffer badly. Which is what I also said.
That's not to mention, OP specifically says he's using "send" to control "variations", presumably by if statement - because making it a different size or color is hardly a "variation" and it wouldn't make sense to bake few specific values rather than leave it as variable.
I'm being intellectually charitable here, I assume that you have high intelligence - not the opposite. And so if that's not the case and you need me to spell out everything in one post so there's no further questions, you'll have to ask me. But I'd rather you don't, I hate the idea of being surrounded by idiots, so please flex your brain muscle, nothing I say is arcane or cryptic, and it all well follows basic logic.
That's not to mention, OP specifically says he's using "send" to control "variations", presumably by if statement - because making it a different size or color is hardly a "variation" and it wouldn't make sense to bake few specific values rather than leave it as variable.
I'm being intellectually charitable here, I assume that you have high intelligence - not the opposite. And so if that's not the case and you need me to spell out everything in one post so there's no further questions, you'll have to ask me. But I'd rather you don't, I hate the idea of being surrounded by idiots, so please flex your brain muscle, nothing I say is arcane or cryptic, and it all well follows basic logic.
- zorg
- Party member
- Posts: 3470
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: love.graphics.newShader and instances
To me, variations can also imply that he's sending one number, for example, through :send, and does no if-like branches in the shader code at all, is all i'm saying. In that case, the thread ended with Pgimeno's first reply, after yours.
And to be perfectly honest, i'd rather not quote all previous posts and highlight the meaning i parsed out of each of them. : 3
And to be perfectly honest, i'd rather not quote all previous posts and highlight the meaning i parsed out of each of them. : 3
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Re: love.graphics.newShader and instances
Well as I said, baking few specific values would make no sense there, so I assume that's not the purpose.
Who is online
Users browsing this forum: Bing [Bot] and 15 guests