4REG_FIDDLE(SkSL_RawImageShaders, 384, 128,
false, 0) {
14 paint.setShader(std::move(shader));
17 return surface->makeImageSnapshot();
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);
34 uniform shader normals;
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;
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;
REG_FIDDLE(SkSL_RawImageShaders, 384, 128, false, 0)
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