Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Shader fails on iOS only
Started by SGS May 17 2018 01:56 AM

3 replies to this topic
[TOPIC CONTROLS]
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

SGS

[GLOBAL: userInfoPane.html]
SGS
  • Corona Geek

  • 2,219 posts
  • Corona SDK

Hi

 

I have a simple shader that works in the shader playground, Android, WIndows and Mac but not iOS.

 

The error is

An error occurred in the fragment kernel

Qualification of arguments in redeclared function 'FragmentKernel' differs from previous declaration

ERROR: One or more attached shaders not successfully compiled

The shader is

 

  highp vec2 getWaveSource(int ws) {
    highp vec2 outp;
    if (ws == 0)
    {
      outp = vec2(-100,-100);
    }
    else if (ws == 1)
    {
      outp = vec2(-100,500);
    }
    else
    {
      outp = vec2(400,-500);
    }
    return outp;
  }

  highp float distanceSq(highp vec2 a, highp vec2 b) {
    highp vec2 diff = a - b;
    return dot(diff, diff);
  }   

  highp vec4 FragmentKernel( highp vec2 uv) {
    const int wsCount = 3;
    
    highp float wavePower = 0.0;
    for(int i=0; i<wsCount; i++)
    {
      highp vec2 src = getWaveSource(i);
      highp float dist = distanceSq(src, uv) / 200.0;
      wavePower += sin((dist + CoronaTotalTime));
    }

    return vec4(
      0.5 + 0.5 * sin(wavePower),
      0.5 + 0.5 * cos(wavePower),
      0.5 + 0.5 * sin(CoronaTotalTime),
      1
    );
  }
I am checking for system.getInfo( "gpuSupportsHighPrecisionFragmentShaders" ) == true before running the shader.
 
Any ideas?


[TOPIC: post.html]
#2

StarCrunch

[GLOBAL: userInfoPane.html]
StarCrunch
  • Contributor

  • 848 posts
  • Corona SDK

"Qualification of arguments in redeclared function 'FragmentKernel' differs from previous declaration" sounds like there must be a line like

P_COLOR vec4 FragmentKernel (P_UV vec2 uv);

prepended to every shader, and in the case of iOS it's asserting this more strongly. Try replacing those two highps and see if you have better luck.



[TOPIC: post.html]
#3

SGS

[GLOBAL: userInfoPane.html]
SGS
  • Corona Geek

  • 2,219 posts
  • Corona SDK

Thanks that works... but performance degrades too much on many devices :(

 

Literally can just watch the fps drop a frame or 2 every 10 seconds.  Not sure why this would be?



[TOPIC: post.html]
#4

mmihajlovic

[GLOBAL: userInfoPane.html]
mmihajlovic
  • Observer

  • 26 posts
  • Corona SDK


[topic_controls]
[/topic_controls]