Jump to content

Get complete shader source code on error


Recommended Posts

Hi everybody ! :D

While I was writing my latest shader, I juste came up with annoying errors like this one :

Guess what ? No, my typo is NOT at line 85. :angry:

And I wondered why we couldn't have the real source code. The one after conversion, addition of defines and insertion of includes. Therefore the one where the typo actually IS at line 85.
I know that getVertexShaderSource() function exists but it doesn't work without a successfully compiled program (and on success, no need of debugging).

Guess what ? It's easy to get ! :P
(Open your console)


I would like to know, @Deltakosh , would you be interested in a PR for that or is it already implemented somewhere/useless ?
Because in my PR I had to compute again the migratedVertexCode and migratedFragmentCode values, but these ones are available when entering the Effect.noError callback in the _prepareEffect() function...

If you're interested, I see two options :
- Just returning the two values in the onError callback and let the user make something with that.
- Or printing the source code with numbered lines by default exactly as you print the defines

Just let me know what you think is better. :)


Link to comment
Share on other sites

Ok, done, thank you. :)

Just one question. Since BabylonJS has a backward compatibility policy, can I remove a function ?
Because I replaced _dumpShadersName (which is only used here) by _dumpShadersSource.

Two other things I think about :
- Maybe some developers do NOT want that random users of their site could see the content of their shaders when it fails to compile ?
- It may add a huge amount of text in the console and it may be uncomfortable if you're not debugging this. I tried to order the content as good as I could though.

Anyway, PR is sent.



Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...