subengari

Villager
Member
Joined
Dec 12, 2020
Messages
17
Reaction score
4
First Language
king's english
Primarily Uses
RMMV
Kamusta dudes and dudettes,

I'm taking a look at the ColorFilter class and came across ColorFilter.prototype._fragmentSrc (which contains the GLSL code for the filter):
ColorFilter_fragmentSrc.png

Looking at other GLSL code on the interwebs, I noticed that the code below contains "#" before certain statements...
glsl_example.png

Can anybody explain the difference between the two... why is "#" used in one and not the other? And if I were to use GLSL code similar to the latter in my own RMMZ filter, would I still include the "#"?

Thanks in advance!
 

caethyril

^_^
Global Mod
Joined
Feb 21, 2018
Messages
2,837
Reaction score
2,176
First Language
EN
Primarily Uses
RMMZ
#ifdef and its accompanying #else are C-like preprocessor directives, i.e. instructions for the compiler. This MSDN article explains the use of such directives in C:
Page 3 of these reference cards has a brief summary of available directives for WebGL:
In the example you cited, I think (?) it is checking whether this shader program has already encountered a #define SIMPLE_LINEAR_GAMMA directive: if so, it compiles one shader; if not, it compiles the other one instead.

Note that MV/MZ games use WebGL, a.k.a. OpenGL ES ("Embedded Systems"). This is limited in various ways compared to standard OpenGL, e.g. you can only access vertex and fragment shaders. Here are some technical links for further information:
And a couple more for tutorials/examples:
:kaohi:
 

subengari

Villager
Member
Joined
Dec 12, 2020
Messages
17
Reaction score
4
First Language
king's english
Primarily Uses
RMMV
@caethyril thank you for the clarification and the supporting documents! I have some reading to do after breakfast :)
 

Latest Threads

Latest Posts

Latest Profile Posts

you know, some days you get resentful that game dev is even considered a "fun job" and other days it's like, welp, time to roll up my sleeves and code these molotov cocktails
If you suck at playing trumpets, that is probably why.
Been sick with a stomach virus for seven days now. Not going to work tomorrow because I'm still contagious according to my doctor.
Much as I love my job, I really hate playing "office politics". It would be nice if I didn't have to pretend to be someone else all day long.
I wanna get back into showing off Battlers and other assets I create again. But i'm always haunted by the "It's not good/realistic enough" voices that keep me from doing so.

Maybe I should get back to it, I did enjoy showing off whatever I came up with!

Forum statistics

Threads
115,958
Messages
1,094,382
Members
151,221
Latest member
yayayaayayay
Top