Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Shader Working on Simulator and Playground But Not on Device
Started by sakib.farid Oct 18 2015 04:14 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

sakib.farid

[GLOBAL: userInfoPane.html]
sakib.farid
  • Observer

  • 27 posts
  • Corona SDK

Hi

 

I created a shader which works fine on the simulator and on the playground but not working on device. It shows the gradient background but not the stars...

 

Tested on a Samsung Galaxy S5 and Galaxy Mega.

Anybody know what the problem could be ?

 

Link to the shader on playground.

https://goo.gl/kcYiBh



[TOPIC: post.html]
#2

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 26,697 posts
  • Enterprise

It's possible if this is a high precision shader your device may not support it. Use this call:

local supportHPS = system.getInfo( "gpuSupportsHighPrecisionFragmentShaders" )

to see if your device supports your shader.



[TOPIC: post.html]
#3

StarCrunch

[GLOBAL: userInfoPane.html]
StarCrunch
  • Contributor

  • 848 posts
  • Corona SDK

Hi.

 

As Rob says, you're probably low on precision. If so, then those 415 values are probably getting snapped to 256 and you'll never get a fraction, much less two that sum to .97 or more.

 

Try something like

P_UV float Hash(P_UV float n) {
  #ifdef GL_FRAGMENT_PRECISION_HIGH
    return fract( (1.0 + cos(n)) * 415.92653);
  #else
    return fract( (1.0 + cos(n)) * 41.592653); // or 4.1592563...
  #endif
}

in the hash function.

 

You might need similar adjustments to threshold. (If everything's a number < 1 you'll have quite a lot of precision, actually.)



[TOPIC: post.html]
#4

sakib.farid

[GLOBAL: userInfoPane.html]
sakib.farid
  • Observer

  • 27 posts
  • Corona SDK

Thanks. I'll try that when I get a chance and post the feedback...


[topic_controls]
[/topic_controls]