跳到主要内容
← Built-In functions

Built-In functions

Mix

要求是从0.25的位置开始算

实时渲染 · 2D 片段 GLSL

第 22 课:Mix

我的解:要求是从0.25的位置开始算

我的解

uniform vec2 iResolution;

void main() {
  // Normalized pixel coordinates (from 0 to 1)
  vec2 uv = gl_FragCoord.xy / iResolution.xy;

  vec3 color2 = vec3(0.38, 0.12, 0.93);
  vec3 color1 = vec3(1.00, 0.30, 0.30);
  vec3 colorMix = mix(color1,color2, uv.x);


  gl_FragColor = vec4(colorMix, 1.0);
}

复盘笔记

  • 要求是从0.25的位置开始算
  • float t = step(0.25, uv.x) * (uv.x - 0.25) / 0.75;
  • 0.25之前是0,之后才开始算uv的值,0-1