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,823
Reaction score
2,162
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

Anyone doing anything for NaNoWriMo this year?
Listening to, "Draum" by Eldrim. If you haven't heard it before, do so. Absolutely lovely, and utterly haunting.
Using Live2D is actually pretty fun once you get familiar with where everything is. :rhappy: And no, I'm not learning because of the Vtuber thing going around, but yes looking at those helps a lot to know what can be done :LZSlol:
[Maybe Sensitive] Personal thoughts on being "cringe".
If I were to say, being a creator also means getting cringe ideas on your project. But why would having one makes the work somehow "being bad"?

Forum statistics

Threads
115,828
Messages
1,093,282
Members
151,018
Latest member
karterAKA
Top