1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| // 全象限 uv.y = 1.0 - uv.y; uv = uv * 2 - 1; // (-5,5) const int uvScale = 5; uv = uv * uvScale; // 绘制坐标轴 half axis = smoothstep(0.01, 0.0, abs(uv.y)) + smoothstep(0.01, 0.0, abs(uv.x)); // 绘制 y=0 x=0 // 绘制坐标网格 half mesh = smoothstep(0.01, -0.01, abs((uv.y - 1) / uvScale)) + smoothstep(0.01, -0.01, abs((uv.y + 1) / uvScale)) + smoothstep(0.01, -0.01, abs((uv.y - 2) / uvScale)) + smoothstep(0.01, -0.01, abs((uv.y + 2) / uvScale)) + smoothstep(0.01, -0.01, abs((uv.y - 3) / uvScale)) + smoothstep(0.01, -0.01, abs((uv.y + 3) / uvScale)) + smoothstep(0.01, -0.01, abs((uv.y - 4) / uvScale)) + smoothstep(0.01, -0.01, abs((uv.y + 4) / uvScale)) + smoothstep(0.01, -0.01, abs((uv.x - 1) / uvScale)) + smoothstep(0.01, -0.01, abs((uv.x + 1) / uvScale)) + smoothstep(0.01, -0.01, abs((uv.x - 2) / uvScale)) + smoothstep(0.01, -0.01, abs((uv.x + 2) / uvScale)) + smoothstep(0.01, -0.01, abs((uv.x - 3) / uvScale)) + smoothstep(0.01, -0.01, abs((uv.x + 3) / uvScale)) + smoothstep(0.01, -0.01, abs((uv.x - 4) / uvScale)) + smoothstep(0.01, -0.01, abs((uv.x + 4) / uvScale));
// 绘制函数 y = x^5 half func = uv.y - pow(uv.x, 5); // 绘制 half plot = smoothstep(lerp(0.001, 0.02, length(uv)), 0.0, abs(func / uvScale)); return half3(axis + mesh, axis + mesh, axis + mesh) + half3(0, plot, 0);
|