variable
- Diffuse is the color value entered by the user
- Map is diffuseMap is the map of the model
Color manipulation in Shader
- Color values entered by the diffuse user (including alpha)
- Contains user input gradient maps
vec4 diffuseColor = vec4( diffuse, opacity );
#ifndef USE_MAP
diffuseColor.rgb = pow(diffuseColor.rgb, vec3(2.2));
#ifdef USE_GRADIENT
#ifdef VERSION_1_3_0
#ifndef STANDARD_SG
#else
diffuseColor.rgb = colorGradient();
#endif
#else
diffuseColor.rgb = colorGradient();
#endif
#endif
#endif
Copy the code
- The color in the texture
- Standard case diffuseColor and map color calculation method
- Need to judge the input color level and input good order NEED_ADJUST_COLOR
- USE_GRADIENT needs to be judged
- Non-standard (ThreeJS) default calculation
- Standard case diffuseColor and map color calculation method
#ifdef USE_MAP
vec4 texelColor = texture2D( map, vUv );
texelColor = mapTexelToLinear( texelColor );
#ifdef DECOLOR // grayscale
float gray = texelColor.r * 0.3 + texelColor.g * 0.59 + texelColor.b * 0.11;
texelColor.r = gray;
texelColor.g = gray;
texelColor.b = gray;
#endif
// Tips:
// 1. All color modifiers only affect RGB
// 2. The diffuseColor function gamma
#ifdef STANDARD
#ifdef VERSION_1_3_0
#ifdef NEED_ADJUST_COLOR
diffuseColor.rgb = changeColorV130(texelColor, gradationInputBlack, gradationInputWhite, gradationGamma, gradationOutputBlack, gradationOutputWhite, diffuseColor).rgb;
#else
#ifndef STANDARD_SG // Color change is not supported
diffuseColor.rgb = pow(diffuseColor.rgb, vec3(2.2));
diffuseColor.rgb *= texelColor.rgb;
#else
#ifdef USE_GRADIENT
diffuseColor.rgb = colorGradient();
diffuseColor.rgb = changeColorV130(texelColor, gradationInputBlack, gradationInputWhite, gradationGamma, gradationOutputBlack, gradationOutputWhite, diffuseColor).rgb;
#else
diffuseColor.rgb = texelColor.rgb;
#endif
#endif
#endif
#else
#ifdef NEED_ADJUST_COLOR
diffuseColor.rgb = changeColorV130(texelColor, gradationInputBlack, gradationInputWhite, gradationGamma, gradationOutputBlack, gradationOutputWhite, diffuseColor).rgb;
#else
#ifdef USE_GRADIENT
diffuseColor.rgb = colorGradient();
diffuseColor.rgb = changeColorV130(texelColor, gradationInputBlack, gradationInputWhite, gradationGamma, gradationOutputBlack, gradationOutputWhite, diffuseColor).rgb;
#else
diffuseColor.rgb = texelColor.rgb;
#endif
#endif
#endif
diffuseColor.a *= texelColor.a;
#ifdef MAP_CLAMP_TO_EDGE
if (vUv.x >= 0.0 && vUv.x <= 1.0 && vUv.y >= 0.0 && vUv.y <= 1.0) {}else {
diffuseColor.a = 0.0;
}
#endif
#ifdef DISCARD_MAP_ALPHA
if(texelColor.a<0.001) discard;
#endif
#else
diffuseColor *= texelColor; // The color multiplier
#endif
#endif
Copy the code