Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Run out of Shader IDs ?

Author
Message
nz0
AGK Developer
16
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 14th Oct 2017 13:04
I need to apply a custom shader to each dynamically created object, as I am passing specific parameter values to each one.
I only need the shader temporarily, but there's no obvious way to delete shaders, so I will be leaking some memory at the very least.

I am using LoadShaderFromString() for each object and the object which the shader applies to will be removed after a couple of seconds.

puzzler2018
User Banned
Posted: 14th Oct 2017 13:43
Cant we just assign the shaderID to null or 0?perhaps?

D
janbo
15
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 15th Oct 2017 19:58 Edited at: 15th Oct 2017 20:01
Yes I also came across this problem.
The solution is not to load so much different shaders (reuse the shaders with same attributes etc)
Are your shaders very different or can you change the parameters via uniform variable or combine some shaders ?
nz0
AGK Developer
16
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 15th Oct 2017 22:17
It's the same shader with variables.

However, each object has to have it's own shader or the same variable value will affect all objects.
I suppose I could use a shader stack to rotate them...

Paul Johnston
TGC Developer
21
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 16th Oct 2017 16:01
I've added the DeleteShader command to the next version
janbo
15
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 16th Oct 2017 17:45 Edited at: 16th Oct 2017 17:45
@Paul Johnston: Great thanks

Quote: "each object has to have it's own shader or the same variable value will affect all object"

@nz0: Did you consider using: SetObjectShaderConstantByName()
nz0
AGK Developer
16
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 16th Oct 2017 18:45
^ oh yea..

Didn't see that.
It will help me having to keep generating new shaders on the fly.

Login to post a reply

Server time is: 2024-04-19 02:35:45
Your offset time is: 2024-04-19 02:35:45