GLSL - OpenGL - WebGL

Hey Guys,

i have another issue and i need some guidance or advice. I have been thinking about getting my feet wet with some of these shader languages. I see most of them (the ones i mentioned) are some sort of subset of OpenGL. I have seen some cool stuff like shadertoy and similar websites, which are basically some sort of a creative playground for some shader effects stuff.

Now i am really trying to find a good sweet spot on what to learn now. I think if i would learn OpenGL at some point it would be sweet. But i really dont want to go off the deep end now and mainly i want to use Unreal. But do some of you guys use a lot of HLSL, OpenGL etc. or similar stuff to enhance your toolset for VFX.

I really, really enjoy coding in Processing. That kind of coding i really like. But i guess OpenGL is a different kind of beast. Thats why i am curious about these subsets. I know you can get GLSL or OpenGL running in Processing. But it should fit into a pipeline workflow so that i could use my results in something like Unreal easily. In general i would like to get some opinions from you guys.

Cheers!

Take what I say with a grain of salt as I don’t have much production experience myself but I use glsl in shadertoy for all my prototyping, I typically prototype my shader in shadertoy before I create it in Unreal,nodes can get annoying sometimes when your trying to solve a tricky bit of math. I know there are also a bunch of standalone apps like shadertoy that use hlsl or similar languages to create shaders with the added option of dumping the buffer into texture, so you can use them elsewhere.

I think it’s a good idea to get familiar with these languages as you get exposed to some of the fundamental Computer Graphics concepts which serve really well when making materials/shaders, it will also give you a better understanding of how to optimize content. I highly recommend https://www.scratchapixel.com/ , it’s a great place to learn some of the fundamental concepts of CG.

cheers,

2 Likes

Hey DeepSpaceBanana,

thank you - great answer. And gives me good ideas. I think my short term end game would be something similar.
Also i so far enjoy doing math - as long as i am comfortable with the subject. But willing to grow of course.

So do you use WebGL? I think Shadertoy is in WebGL.

Because that is another thing i have to think about. I want to still keep it as “artistic” as possible (i know there will be technical stuff involved).
And then slowly getting into more advanced technical and mathematical subjects.

By the way, the thing about the nodes being hard to work with when it comes to math is what made me look into this stuff.

Yes, shadertoy makes use of the WebGL API, and the code you write is in GLSL or a simpler version of it. I haven’t looked into it too much

Completely agree about the nodes thing.

1 Like

Unity is using Shader Lab which is their extension of CG (CG is old version of HLSL). It’s almost the same as HLSL.
UE4 is using HLSL, so does Cryengine.

OpenGL/GLSL is reaaaaaly similar to HLSL/CG.

I only learned Unity’s CG but I can read HLSL and OpenGL code easily. Writing custom UE4 nodes wastn’t a problem at all.

I would start with either Unity and CG since it is probably the easiest way of learning shader programming. Unity also handles some low-level things for you. You can focus on pure shader writing and some scripting. After that, you can get dirty and jump into UE4 which gives you more flexibility but it takes a lot more knowledge to do simple things.

1 Like

CG is not an old version of HLSL, it’s a shader language by Nvidia that’s almost identical to DX9 era HLSL but has compilers that could output DX9 HLSL or OpenGL 3.0 GLSL shaders.

Current ShaderLab is no longer Cg, and is essentially straight HLSL inside the CGPROGRAM blocks, with some minor “magic” mixed in (mostly in the form of defines in cginc files) for cross platform compiling, and their own fork of hlsl2glsl, an open source project that started as AMD’s version of the same problem Nvidia was trying to solve with Cg.

Obviously things like CGPROGRAM, the .cginc file extension, and using “fragment” shaders instead if “pixel” shaders are a hold over from being Cg, but the actual shader code is all HLSL to the point of there being a few commands that Cg has that HLSL doesn’t which will not compile anymore.

ShaderToy is great for getting an idea of what can be done within a fragment shader, but because it doesn’t offer any way to render meshes or use vertex shaders you’re missing a large set of tools you would actual want to use for real time work. The vast majority of really impressive ShaderToys can’t run anywhere close to 60fps at full screen for example. It’s still a great utility for playing with ideas and brushing up on your math skills though.

As for GLSL / HLSL, there are of course minor differences that don’t overlap, but you usually have to get pretty far in before you hit those. Most of the time you can take any basic chunk of GLSL and translate it into HLSL by just searching for any use of “vec” and replacing it with “float”.

2 Likes

Hey guys,
thanks for your answers really good stuff. Its nice to hear that getting into it isnt too hard. But as i have mentioned i only use Processing so far. So my plan for now is to get down som basic C - before i go into OpenGL as well as GLSL and somehow just wing it in the begging. I think GLSL is so similar to HLSL that it auto converts the GLSL code to HLSL or something like that when using it in Unreal.

I think i wont dive into Unity though. Its just that i really want to keep my tools as limited as possible.^^

bgolus - what you mentioned is great as well. Yeah, i see these things seperate. I dont plan to get any output from something like shadertoy, to use somehwere is in a different app or anything like. Its really about getting solid with math and maybe learning new workflows that could lead to some cool ideas. :slight_smile:

Really happy with the info you guys gave me. There isnt much on all of this on google - especially not realtimeVFX related. Cool that i can make some good educational use of it. And especially the math stuff as well as stuff like dealing with position etc. I need to get creative with that as well.

One thing i really dont like though. I setting up my IDE and Compiler etc.
I want to start with C and as an IDE i use Code::Blocks and setting it up with a compiler and whatnot is a pain. -.-
I hope i manage to get i to work tonight.