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.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

WebGL mipmaps on cumbemap issue

Discussion in 'WebGL' started by Diomede, Dec 22, 2015.

  1. Diomede

    Diomede

    Joined:
    Mar 10, 2015
    Posts:
    31
    Hi all,

    I have made simple scene with skybox and a custom reflection cube, if I compile it for WebGL i have a noise into textures,and artifact in the model.



    The only way that i found, is disable mipmaps into cube map



    But, in this way ,i lose Smoothness material parameter(i see reflection even if Smoothness =0)


    Any ideas ?

    Thanks.
     

    Attached Files:

    Last edited: Dec 23, 2015
  2. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,666
    The underlying reason for this issue is probably that WebGL does not support rendering into individual mipmap levels of a texture (which is needed to have different reflection mipmaps for different levels of smoothness). This is a restriction in the WebGL spec (https://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf, section 4.4.3).

    I believe this restriction will be lifted in WebGL 2.0.
     
  3. Diomede

    Diomede

    Joined:
    Mar 10, 2015
    Posts:
    31
    HI jonas echterhoff

    First of all thanks for reply!!.
    Only for test, I have modified standard shader at this point :

    #if (SHADER_TARGET < 30)
    # define UNITY_SAMPLE_TEXCUBE_LOD(tex,coord,lod) texCUBEbias(tex, half4(coord, lod))
    #else
    # define UNITY_SAMPLE_TEXCUBE_LOD(tex,coord,lod) texCUBElod (tex, half4(coord, lod))
    #endif

    And I have forced to use texCUBElod insetad of texCUBEbias , and whith my suprise .. WORKS!. In webgl I have
    perfect reflections like standalone .


    But i don't think that is correct way :).
     
  4. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,666
    Oh, I see. I thought you were talking about *realtime* reflection probes.

    Which version of Unity are you on?
     
  5. Diomede

    Diomede

    Joined:
    Mar 10, 2015
    Posts:
    31
    5.2.2f1 , i have tried with 5.3.1 but i have same effects

    My lighting settings, I don't have any other type of lights in scene.
     

    Attached Files:

    Last edited: Dec 22, 2015
  6. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,666
    FYI, in 5.4 we will use the Shader Target 3.0 Standard Shaders in WebGL, so your shader modification should then no longer be needed.
     
  7. Diomede

    Diomede

    Joined:
    Mar 10, 2015
    Posts:
    31
    Thanks jonas,

    Do you know if my modification may have some problems in WebGL, waiting for the 5.4? I think there is a reason, if actually shader uses texCUBEbias for webgl.
     
    kenshin likes this.
  8. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,666
    Your modification should work. Or, more simply, you can create a copy of the standard shader, and remove all lines which say "#exclude_renderers gles".

    Explanation: The WebGL graphics API matches the functionality of OpenGL ES 2.0. Some mobile devices using OpenGL ES 2.0 cannot handle the complexity of the standard shader and need to use a simpler version. Shader code is tied to graphics APIs, so we use the same code on WebGL then on all other OpenGL ES 2.0 platforms (this is no longer completely true in 5.3 where the standard shader already looks much better then in 5.2, but still applies in some cases). By removing the line "#exclude_renderers gles", you make all OpenGL ES 2.0 platforms (including WebGL) use the advanced shader version. This may make the shader fail or perform bad on some low end mobiles, but makes it look better on WebGL. In 5.4, we will have the ability to use completely different versions per target, independent of the rendering API used, which will fix this issue.
     
    tteneder, Diomede and kenshin like this.
  9. Diomede

    Diomede

    Joined:
    Mar 10, 2015
    Posts:
    31
    HI jonas echterhoff,

    I have modified standard shader by removing "#exclude_renderers gles", and result is very good :).

    Adding my modified shader in webgl build, the file gallery_viewer.datagz grows up from 2.5 to about 8 mb. Is there any kind of modification that I can do for reducing size ?
     
    kenshin likes this.