WARNING: Calls to any function that may require a gradient calculation inside a conditional block may return undefined results
2014-05-17 21:21
2061 查看
GLES2.0:
Some device will give a warning on compling shaders(yet the compling will succeed), and the rendering result is incorrect with blink & artifacts.
the problems is gradient calculation(interpolation) relies on the neighbor pixels,
if the neighbor pixels are not in the same conditional branch, the gradient will be invalid and result may be undifed.
I guess it is an un-defined behavior, so some devices/drivers works good, some don't.
One workaround is use mix() or step() instead of conditional test.
When using conditional branch, the texture sampling may be not actually executed, which will increase graphics performance.
One draw back on using mix/step is that the sampling is always performed, then interpolated/multiplied.
udpate:
Actually to many conditonal test & branch blocks(even without texture sampling in it) in fragment shader will case rendering halt, no response, and even system restart.
this result is based on testing on Galaxy S4 (PowerVR SGX544), compared to testing on iPad Air(PowerVR G6430, no such problems).
maybe it's only a driver issue, since both graphics chips are PowerVR family.
Some device will give a warning on compling shaders(yet the compling will succeed), and the rendering result is incorrect with blink & artifacts.
the problems is gradient calculation(interpolation) relies on the neighbor pixels,
if the neighbor pixels are not in the same conditional branch, the gradient will be invalid and result may be undifed.
I guess it is an un-defined behavior, so some devices/drivers works good, some don't.
//like this if( test ) color = texture2D(sampler,UV); else color = vec4(0,0,0,0);
One workaround is use mix() or step() instead of conditional test.
color = mix(vec4(0,0,0,0), texture2D(...), testVal);
When using conditional branch, the texture sampling may be not actually executed, which will increase graphics performance.
One draw back on using mix/step is that the sampling is always performed, then interpolated/multiplied.
udpate:
Actually to many conditonal test & branch blocks(even without texture sampling in it) in fragment shader will case rendering halt, no response, and even system restart.
this result is based on testing on Galaxy S4 (PowerVR SGX544), compared to testing on iPad Air(PowerVR G6430, no such problems).
maybe it's only a driver issue, since both graphics chips are PowerVR family.
相关文章推荐
- Warning: To avoid potential deadlock, operations that may block...
- Warning: To avoid potential deadlock, operations that may block, such as
- error C4996: Function call with parameters that may be unsafe – this call relies on the caller to ch
- Warning: require_once(../models/Message.php) [function.require-once]: failed to open stream: No such
- error C4996: Function call with parameters that may be unsafe - this call relies on the caller to check that the passed values are correct
- Call to undefined function mcrypt_get_block_size
- Fatal error: Call to undefined function mcrypt_get_block_size()
- (转)Call to undefined function mb_convert_encoding()
- Fatal error: Call to undefined function mysql_connect()
- PHP连接mysql数据库报错:Call to undefined function mysql_connect()
- Warning not all local changes may be shown due to an error(IDEA Bug) IDEA不能检查到代码变化
- Fatal error: Call to undefined function mysql_connect()
- PHP发生Call to undefined function imagecreate()错误的解决办法
- Call to undefined function set_magic_quotes_runtime() in /opt/app/apache/install/index.php:12 Stack
- Call to undefined function openssl_encrypt(),安装laravel报错问题
- 从根本解决“Call to undefined function Think\imagecreate()”
- exif_imagetype函数遇到Call to undefined function exif_imagetype问题
- php连接mysql错误:Call to undefined function mysql_connect()
- iis+php+mysql 错误 ---Call to undefined function mysql_connect()的解决办法
- Fatal error: Call to undefined function session_is_registered() 函数已废弃