Is there a way to get the texture size from within shader code?
Using textureSize() calls in shader code in ZGE results in blank textures. It seems it's just not implemented. Same with iChannelResolution[], which is understandable given it's assuming an array of textures. But textureSize() seems feasible if it could be implemented or is implemented somehow.
EDIT: A bit of background. I'm working on a dither effect implemented as a shader. It can use ZGE's Img Src texture as a dither pattern but I need to get the texture's size, otherwise the user would need to specify a size, which is inconvenient since the user won't easily know the size or be able to set it appropriately.
In case it helps, the working shader is unlisted on shadertoy:
https://www.shadertoy.com/view/43VGR1
Is there a way to get textureSize?
Return to “ZGameEditor Visualizer Script Reference”
[You can only see part of this thread as you are not logged in to the forums]
Re: Is there a way to get textureSize?
The textureSize() function is part of the GLSL specification, so it should be available as long as your GPU supports it.revisualizer wrote:Using textureSize() calls in shader code in ZGE results in blank textures. It seems it's just not implemented.
+ Just gave it a quick try for posterity:

Re: Is there a way to get textureSize?
Thanks for looking into this Kjell.
I'm actually trying to use Image Src so the user can utilize any pattern they want for the dither effect. Does ZGE support getting textureSize from an Image Src bitmap?
To clarify, the Image Src parameter: And the code where it's failing: The textures are defined like so:
And iChannel0 and iChannel1 are defined in the shader like so:
The code fails at the textureSize() call:
So maybe it's not possible to call textureSize() for Image Src?
I'm actually trying to use Image Src so the user can utilize any pattern they want for the dither effect. Does ZGE support getting textureSize from an Image Src bitmap?
To clarify, the Image Src parameter: And the code where it's failing: The textures are defined like so:
Code: Select all
<Textures>
<MaterialTexture Name="FeedbackMaterialTexture" TexCoords="1"/>
<MaterialTexture Name="Source1" Texture="Bitmap1"/>
</Textures>
Code: Select all
uniform sampler2D tex1;
uniform sampler2D tex2;
#define iChannel0 tex1
#define iChannel1 tex2
Code: Select all
if (ZGEimgSrc > 0.0) {
ivec2 ts = textureSize(tex1, 0);
s = float(ts.x);
}
You do not have the required permissions to view the files attached to this post.
Re: Is there a way to get textureSize?
Yup, that's supported. Just to make sure i gave it a try in ZGameEditor Visualizer .. works fine on my end:revisualizer wrote: ↑Tue Oct 22, 2024 10:57 pmDoes ZGE support getting textureSize from an Image Src bitmap?

Re: Is there a way to get textureSize?
Thanks so much for your help Kjell, once again.
I was so confused, I asked Claude.ai about it after providing the shader code and Claude mentioned it likely has to do with the glsl version. I changed it from #version 120 to #version 130 and it worked!
Thanks again for your help! Back to trying to get this batch of shaders released.
I was so confused, I asked Claude.ai about it after providing the shader code and Claude mentioned it likely has to do with the glsl version. I changed it from #version 120 to #version 130 and it worked!
Thanks again for your help! Back to trying to get this batch of shaders released.
Re: Is there a way to get textureSize?
Good to hearrevisualizer wrote: ↑Sat Nov 02, 2024 5:11 pmI changed it from #version 120 to #version 130 and it worked!

