cocos2d / glsl-optimizer

GLSL optimizer based on Mesa's GLSL compiler. Used in Unity for mobile shader optimization.
Other
10 stars 10 forks source link

No support variables in global scope when converting es shader to msl #6

Open Mee-gu opened 5 years ago

Mee-gu commented 5 years ago

Here is a simple fragment shader:

vec3 redColor = vec3(1.0, 0.0, 0.0);

vec3 getColor()
{
    return redColor;
}
void main(void) {
    vec3 color = getColor();
    gl_FragColor = vec4(color, 1.0);
}

When we use the global variable redColor in getColor() method, after translated it to metal shader language, all variables defined in global scope will be skipped. It will make redColor undefined in getColor() method in msl: float3 getColor () { return redColor; }

It is a bit complicate and will take more time to fix the issues, thus we don't take this into account for the time being.