4 {
10 if (!shader) {
11 return nullptr;
12 }
14 paint.setShader(std::move(shader));
17 return surface->makeImageSnapshot();
18}
19
21
24 vec4 main(vec2 p) {
25 p = (p / 128) * 2 - 1;
26 float len2 = dot(p, p);
27 vec3 v = (len2 > 1) ? vec3(0, 0, 1) : vec3(p, sqrt(1 - len2));
28 return (v * 0.5 + 0.5).xyz1;
30 auto normalImage =
make_image(imageShader, imageInfo);
31
32
34 uniform shader normals;
35 vec4 main(vec2 p) {
36 vec3 n = normalize(normals.eval(p).xyz * 2 - 1);
37 vec3 l = normalize(vec3(-1, -1, 0.5));
38 return saturate(dot(n, l)).xxx1;
42
43
44
48
49
55
56
57
60
61
62
67}}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
static sk_sp< SkColorSpace > rec2020()
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
@ kRGBA_F16_SkColorType
pixel with half floats for red, green, blue, alpha;
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
static sk_sp< SkImage > make_image(SkCanvas *destCanvas)
void drawRect(const SkRect &rect, const SkPaint &paint)
void drawPaint(const SkPaint &paint)
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
static sk_sp< SkColorSpace > MakeRGB(const skcms_TransferFunction &transferFn, const skcms_Matrix3x3 &toXYZ)
sk_sp< SkShader > makeShader(sk_sp< const SkData > uniforms, sk_sp< SkShader > children[], size_t childCount, const SkMatrix *localMatrix=nullptr) const
static Result MakeForShader(SkString sksl, const Options &)
static constexpr skcms_Matrix3x3 kRec2020
static constexpr skcms_TransferFunction kSRGB
SK_API sk_sp< SkSurface > Raster(const SkImageInfo &imageInfo, size_t rowBytes, const SkSurfaceProps *surfaceProps)
static SkImageInfo MakeN32Premul(int width, int height)
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)
sk_sp< SkRuntimeEffect > effect