Open diroru opened 6 years ago
@diroru you can set another texture unit by doing shader.set("tex", img) where img is the PImage holding the layer, is this what you tried?
Hey @codeanticode, thanks for the hint; indeed, this was the approach. Alas, it generates following error message:
java.lang.RuntimeException: Cannot validate shader program:
Validation Failed: Sampler error:
Samplers of different types use the same texture image unit.
- or -
A sampler's texture unit is out of range (greater than max allowed or negative).
Made a branch for it: https://github.com/diroru/planetarium/tree/bug_background_sampler.
Many thanks in advance for looking into this!
@diroru this discussion on stack overflow sheds some light on the problem. Because validation in PShader happens before the texture units are bound, the compiler cannot determine if the same unit will be assigned to both the 2D and cube samplers. A hack mentioned in the stack overflow thread is to remove the validation step. I commented the validation() call in PShader, and the modified cube shader with background texture does works You could subclass PShader in planetarium, and overload the init() method.
Seems that they had the same problem with the Allosphere :-)
Thank you very much! Will look into it. Cheers!
In order to implement »layered« rendering, i would like to have a background and a foreground
sampler2D
in the shader. When i do this, the compiler complains that i am trying to use the same texture unit. Even when i try to assign another one, it doesn’t work. Some resources say, the texture unit should be set right after linking. Is this possible with PShader or do i need fallback to JOGL, or is the problem something entirely different?Many thanks in advance for any hints!