Search Unity

Help with tex2Dlod texCUBElod

Discussion in 'Shaders' started by AleVerDes, Jul 25, 2014.

  1. AleVerDes

    AleVerDes

    Joined:
    Jun 16, 2014
    Posts:
    40
    Can you please help with the function in shaders? tex2Dlod and texCUBElod work perfectly in the editor even Unity3D enabled emulation OpenGL ES 2.0, but on the mobile phone (Android) refuse to work. Is there any way to fix this situation?

    Thanks in advance.
     
  2. dirtybassett

    dirtybassett

    Joined:
    Oct 3, 2012
    Posts:
    59
    #pragma target 3.0 ?
     
  3. AleVerDes

    AleVerDes

    Joined:
    Jun 16, 2014
    Posts:
    40
    It is already there, of course.
     
  4. Charkes

    Charkes

    Joined:
    Apr 17, 2013
    Posts:
    228
    Hey,

    Did you tried this ?

    Code (CSharp):
    1. #ifdef SHADER_API_OPENGL  
    2. #pragma glsl
    3. #endif
     
  5. AleVerDes

    AleVerDes

    Joined:
    Jun 16, 2014
    Posts:
    40
    Charkes, I'm used Marmoset Skyshop Shaders Pack, it used this fragment of code.
     
  6. Charkes

    Charkes

    Joined:
    Apr 17, 2013
    Posts:
    228
    Then you should explain all this in your first post which might mislead people trying to help you. You could have wrote your own shader.

    Anyway for such an issue try to reach Marmoset guy they will certainly have a clue as you are using their shaders.

    Cheers
     
  7. monkeyscience

    monkeyscience

    Joined:
    Dec 13, 2011
    Posts:
    705
    Unfortunately most Android hardware does not support tex2Dlod or texCUBElod. Those functions require an openGL extension (called EXT_shader_texture_lod) that is not guaranteed support by GLES 2.0. Luckily all iOS devices support it anyway and iOS targets can use mipmapped reflection cubes. But you cannot rely on it for Android builds.

    It looks like GLES 3.0 will have a textureLod function: http://www.khronos.org/opengles/sdk/docs/man3/index.php
    Not sure what it would take to get access to it through Unity though.
     
  8. dirtybassett

    dirtybassett

    Joined:
    Oct 3, 2012
    Posts:
    59
    tex2dbias my work, not tried it on android though.
     
  9. AleVerDes

    AleVerDes

    Joined:
    Jun 16, 2014
    Posts:
    40
    monkeyscience, thank you very much, your answer is most useful!

    dirtybassett, tex2Dbias not suitable due to the many artifacts and textures in the editor and on the phones.
     
  10. monkeyscience

    monkeyscience

    Joined:
    Dec 13, 2011
    Posts:
    705
    tex2Dbias isn't quite enough for mipmapped gloss (and believe me I've tried :p). It can only shift which mip is selected for the fragment but distance and angle of the fragment are still in the equation, creating a lot of gloss map artifacts that change as you move the camera around.

    It's a shame really, EXT_shader_texture_lod is not some exotic new extension or concept...
     
  11. dirtybassett

    dirtybassett

    Joined:
    Oct 3, 2012
    Posts:
    59
    tex2dlod don't seem to work on my nexus 7 and tex2dbias looks crap. Has anyone got an alternative?
     
  12. AleVerDes

    AleVerDes

    Joined:
    Jun 16, 2014
    Posts:
    40
  13. dirtybassett

    dirtybassett

    Joined:
    Oct 3, 2012
    Posts:
    59
    Spherical Gaussian approximation works, seems a bit expensive though.