Shader Working on Simulator and Playground But Not on Device

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

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.

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.)

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

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.

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.)

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