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. Dismiss Notice

Resolved Shader not working in WebGL

Discussion in 'Shader Graph' started by Camille_Gobled, Sep 3, 2020.

  1. Camille_Gobled

    Camille_Gobled

    Joined:
    Sep 3, 2020
    Posts:
    9
    Hi everyone !

    I'm quite new to Unity so don't hesitate to ask me more details if it can help. I create a scene on which I need to display 3D structures. These structures are STL files imported as Meshes in Unity. I apply on them a material and a shader.
    This works perfectly in Unity (left picture) but not in WebGL (right picture).

    Capture_unity.PNG Capture_webgl.PNG

    I've had look on several forums and the solutions proposed were :
    -Put the shader is the Resources folder: already done
    -Put the shader in "Always Included Shaders" in Project Settings/graphics : I can't do it, I have an error because it has too many variants

    When I click on "Compile and show code" in the inspector I have these issues : Capture_errors.PNG
    But the file is in the folder.
    Does it means it can't be open for WebGL building ?

    Does anyone has an idea why I can't display this shader in WebGL?

    Thank you !!

    (I'm French, sorry for my English)
     
  2. neoshaman

    neoshaman

    Joined:
    Feb 11, 2011
    Posts:
    6,469
    Le fichier est dans le même dossier et pas dans un sous dossier? Tu es sur? Vérifie le chemin d'accès du "material" et du "shader" pour voir si ils sont vraiment équivalent...
     
  3. Camille_Gobled

    Camille_Gobled

    Joined:
    Sep 3, 2020
    Posts:
    9
    Merci beaucoup pour ta réponse ! Effectivement le shader était dans un sous dossier... Mais j'ai toujours un problème puisque cette fois-ci je n'ai plus rien qui s'affiche...
     
  4. neoshaman

    neoshaman

    Joined:
    Feb 11, 2011
    Posts:
    6,469
    Explique?

    Peut être un problem de compatibilité open gl, il me semble que web gl est basé sur la version 2.0 (à vérifier), donc si ton shader utilise des fonctions des versions ultérieur, ils va pas fonctionné.
     
  5. Camille_Gobled

    Camille_Gobled

    Joined:
    Sep 3, 2020
    Posts:
    9
    Ma structure 3D ne s'affiche pas du tout, comme si elle n'existait pas.

    Comment est-ce que je peux savoir si mon shader utilise de telles fonctions?

    Merci
     
  6. neoshaman

    neoshaman

    Joined:
    Feb 11, 2011
    Posts:
    6,469
    Bon va falloir aller old school, faire un projet de test, reduire le shader a une forme que tu sais compile et est visible (par example un applat de couleur) puis itéré en ajoutant a chaque fois une fonction de plus jusqu'a ce que tu identifie le coupable.
     
  7. Camille_Gobled

    Camille_Gobled

    Joined:
    Sep 3, 2020
    Posts:
    9
    Ok super!

    Je travaille là dessus dès que j'ai un peu de temps, je reviens vers toi au plus vite !

    Merci beaucoup !
     
  8. Camille_Gobled

    Camille_Gobled

    Joined:
    Sep 3, 2020
    Posts:
    9
    Du coup j'ai identifié le problème, j'ai des fonctions qui utilisent la géométrie de ma forme. J'ai lu sur le forum que les "geometry shader" n'étaient pas supportés par WebGL. Je vais essayer de me débrouiller autrement pour avoir le rendu "flat" du shader. Merci pour ton aide !
     
  9. Lastcall

    Lastcall

    Joined:
    Jun 9, 2021
    Posts:
    1
    [QUOTE = "Camille_Gobled, post: 6297004, member: 5779697"] So I identified the problem, I have functions that use the geometry of my shape. I read on the forum that the "geometry shader" is not supported by WebGL. I will try to manage differently to have the "flat" rendering of the shader. Thanks for your help! [/ QUOTE]

    Can you please tell me how exactly you solve your problem?
    I am facing a similar issue my shader is working properly in offline device but not working in WebGL, I have tried many solutions available on internet but none working.