zoukankan      html  css  js  c++  java
  • WARNING: Calls to any function that may require a gradient calculation inside a conditional block may return undefined results

    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.

    1 //like this
    2 if( test )
    3     color = texture2D(sampler,UV);
    4 else
    5    color = vec4(0,0,0,0);

    One workaround is use mix() or step() instead of conditional test. 

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

  • 相关阅读:
    10-vue自定义指令
    09-vue过滤器的基本使用
    vue总结
    07-vue的v-if和v-show
    06-循环数组v-for
    Java通过JNA调用dll或so
    Centos7安装FRP内网穿透工具进行远程连接
    centos7检查Java项目存活与否并重启
    centos7中Java项目重启
    Ubuntu 19.04: Connect to GNOME desktop environment via XRDP
  • 原文地址:https://www.cnblogs.com/crazii/p/3734545.html
Copyright © 2011-2022 走看看