Jump to content

Porting ShaderToy shaders to UUSL


photo

Recommended Posts

Shader Toy has lots of great WebGL shaders. As a test, I ported this one https://www.shadertoy.com/view/llK3RR to UUSL. It's a barrel distortion with chromatic abberation.

 

post-2023-0-36034700-1483977589_thumb.png

 

 

Lessons learned;

  • Use shaders_reload
  • Use EXPORT_SHADER(foobar) to dump out the preprocessed shader in to foobar.hlsl or foobar.glsl so you can match up the error line numbers
  • Search+Replace of vec3 etc gets you surprisingly far.
  • Valid GLSL things like foo = float3(0.0) break when using HLSL. Expand them as foo = float3(0.0, 0.0, 0.0) and they'll work for both
  • Virtually all maths in ShaderToy code comes over without changes.

 

I have attached the material XML, vertex and fragment shaders to this message. Note that if you're adding this to your project you'll need to edit the materials XML to correct the path to the shaders.

 

 

post.frag

shader_dev.mat

post.vert

Link to comment

Hi Angus,

 

That's very useful, thank you for sharing :)

 

Btw, we have similar post processing effect available out of the box in post_color_correction material (located in unigine_post.mat library). Fragment shader is located at <SDK>/data/core/shaders/screen_space/fragment/color_correction.frag

How to submit a good bug report
---
FTP server for test scenes and user uploads:

Link to comment
×
×
  • Create New...