Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

bitfieldExtract on GLES3.0

Discussion in 'Shaders' started by saberice, Dec 5, 2019.

  1. saberice

    saberice

    Joined:
    Mar 10, 2018
    Posts:
    2
    The generated shader code (gles3.0) may have some problem.
    Shader Code like this:
    (value>>8)&8 ;

    will generate:
    bitfieldExtract(value,8,8);

    But the problem is bitfieldExtract is not supported by gles3.0.
    I want to know is there any good method to solve this problem?
    Thanks!
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,266
    Are you using something like this line somewhere in your shader?
    #pragma target es3.0
     
  3. saberice

    saberice

    Joined:
    Mar 10, 2018
    Posts:
    2
    Thanks for your reply.
    I have try:
    #pragma target es3.0
    #pragma target 3.0
    #pragma target 3.5
    But make no sense.
    Error will output:
    0(33) : error C7532: global function bitfieldExtract requires "#version 400" or later
    0(33) : error C0000: ... or #extension GL_ARB_gpu_shader5 : enable

    I think maybe it's a bug on gles platform of unity.
    Actually,if unity do nothing with the >>&,the shader will work well...
     
    Last edited: Dec 6, 2019
  4. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,266
    You might need to report it as a big then. A cursory internet search showed the same bug happening in some non-Unity projects, so it might be some library Unity uses that’s behaving badly.
     
  5. neoshaman

    neoshaman

    Joined:
    Feb 11, 2011
    Posts:
    6,472
    What are you trying to do?

    If you want to read a bit, you can do it with a divide and a modulo:
    (number / (2^bit position) %2