Hello, this's my first post.
Ok, so the problem is:
I try so render a picture with distortion shader. It worked perfectly fine in the desktop version, but not in the android one. Any clue?
[SOLVED] Distortion Shader Doesn't Work on Android Version
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
-
- Prole
- Posts: 7
- Joined: Wed May 04, 2022 8:01 am
[SOLVED] Distortion Shader Doesn't Work on Android Version
- Attachments
-
- distort.love
- (23.64 KiB) Downloaded 90 times
Last edited by PotatoDude on Sun Oct 16, 2022 1:36 pm, edited 1 time in total.
nvm
Re: Distortion Shader Doesn't Work on Android Version
Looks like the u coordinate is always 0 in the shader for some reason. Try returning the uv coordinates.
Maybe try with a different image, possibly with power-of-two dimensions.
Code: Select all
vec4 effect(vec4 color, Image TEXTURE, vec2 uv, vec2 pc) {
return vec4(uv, 0.0, 1.0);
}
Tools: Hot Particles, LuaPreprocess, InputField, (more) Games: Momento Temporis
"If each mistake being made is a new one, then progress is being made."
"If each mistake being made is a new one, then progress is being made."
-
- Prole
- Posts: 7
- Joined: Wed May 04, 2022 8:01 am
Re: Distortion Shader Doesn't Work on Android Version
Hey! Sorry for the late reply.
Yea, I just realized that in android version, it render the most left pixel only (I tried to use an image with a red dot on the mid left). Unfortunately it's not the uv's problem; it's works just normal when I returning the uv coords.ReFreezed wrote: ↑Sat Oct 15, 2022 12:37 pm Looks like the u coordinate is always 0 in the shader for some reason. Try returning the uv coordinates.Code: Select all
vec4 effect(vec4 color, Image TEXTURE, vec2 uv, vec2 pc) { return vec4(uv, 0.0, 1.0); }
Ok, I've changed the image to 256x256 res
nvm
-
- Prole
- Posts: 7
- Joined: Wed May 04, 2022 8:01 am
Re: Distortion Shader Doesn't Work on Android Version
And this's the .love file. Idk but I can't add more than 3 attachments in a single post.
- Attachments
-
- distort2.love
- (29.47 KiB) Downloaded 93 times
nvm
-
- Prole
- Posts: 7
- Joined: Wed May 04, 2022 8:01 am
Re: Distortion Shader Doesn't Work on Android Version
I solved it!
The problem is rather simple tho
Based on the wiki:
For ones whose facing the same problem, here's the solution:
The precision highp float sets the precision to highp, but leave it alone will returns error at the love2d vec4 effect function. Set it and its arguments to mediump will solve it!
The problem is rather simple tho
Based on the wiki:
Basically in mobile device the float precision is set to mediump by default. And it's a problem since the noise generator function needs a highp precision.https://github.com/ashima/webgl-noise/wikiOn mobile devices, variables in pixel shaders use mediump (16 bit float) precision by default instead of 32 bit float, for performance reasons. This may cause numeric instability or visual artifacts for larger numbers. Use the highp qualifier when declaring a variable (for example highp float pos;) to make it use always 32 bit float precision. Furthermore, highp precision is not supported on all devices, particularly GLES2 devices. Use love.graphics.getSupported to check!
You do not need a super fast GPU to use these functions. They are useful even on low end hardware, old hardware and embedded OpenGL ES hardware with low performance. However, they require support for "highp" precision.
For ones whose facing the same problem, here's the solution:
Code: Select all
precision highp float; //on top of the file
mediump vec4 effect(mediump vec4 color, Image TEXTURE, mediump vec2 uv, mediump vec2 pc) {
// your main code here
}
nvm
Re: [SOLVED] Distortion Shader Doesn't Work on Android Version
I feel silly now. I'm using the same noise generator code from that very repo in my current project and I remember reading about the precision requirement. D'oh.
Tools: Hot Particles, LuaPreprocess, InputField, (more) Games: Momento Temporis
"If each mistake being made is a new one, then progress is being made."
"If each mistake being made is a new one, then progress is being made."
-
- Prole
- Posts: 7
- Joined: Wed May 04, 2022 8:01 am
Who is online
Users browsing this forum: Bing [Bot] and 4 guests