-
Included here is a shader I use for most of the graphics on screen. @rh101 kindly converted my old shader when I moved to axmol last year. I clone the shader and add it to the sprites (AddTerrainTimeShader). I originally used SimpleShader to wrap the shaders. But I think most of the code has now been removed/ported. I then set the graphics colours and alpha using UpdateTerrainTimeShader What I am noticing is that the alpha is getting applied to pretty much all the sprites that use the shader. As a test I set the alpha to all sprites apart from mountains to 1.0f and mountains were set to 0.25f. The included video is the result of looking around. You can see how the alpha is randomly being applied and on sprites that should be 1.0f Edit: On further inspection it seems all variables are being affected (ie: colours) so I suspect I have something wrong with my shader variable handling. alpha.issue.movAs usual, any help would be much appreciated.
Shader creation:
custom/terrainTimeShader_fs
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 6 replies
-
If the shaders will have different uniform values, then they should have separate batch identifiers, otherwise all sprites using that shader will end up with the same uniform values, which, if I recall correctly, would be the values from the last calls made to the
and
Also, you can simplify the following code a bit:
to
|
Beta Was this translation helpful? Give feedback.
If the shaders will have different uniform values, then they should have separate batch identifiers, otherwise all sprites using that shader will end up with the same uniform values, which, if I recall correctly, would be the values from the last calls made to the
setUniform
method for each uniform.ProgramState::updateBatchId()
would need to be called after setting the uniform values, to ensure the batch ID is updated based on those values. For example, see if the following fixes the issue: