Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[QUESTION] How to convert a SKRuntimeEffect to SKColorFilter? #2519

Closed
dbriard opened this issue Jul 7, 2023 · 3 comments
Closed

[QUESTION] How to convert a SKRuntimeEffect to SKColorFilter? #2519

dbriard opened this issue Jul 7, 2023 · 3 comments

Comments

@dbriard
Copy link

dbriard commented Jul 7, 2023

Hi,
I am using SkiaSharp 2.88.3.
There is a function called ToColorFilter(uniforms, children) however I cannot understand how it is supposed to work.

The only example I found in SKRuntimeEffectTest.cs is not working and cf1 is null.

var src = @"
uniform shader input;
half4 main() {
    return sample(input);
}";

			using var img = SKImage.FromEncodedData(Path.Combine(PathToImages, "baboon.jpg"));
			canvas.DrawImage(img, 0, 0);

			using var effect = SKRuntimeEffect.Create(src, out var errorText);
			Assert.Null(errorText);
			Assert.NotNull(effect);

			var cf1 = effect.ToColorFilter();

I can only get a non-null ColorFilter using this Shader... but it is very useful.

half4 main(float2 p) {
    return half4(0);
}

I suppose there are limitations but what are they?
I need to access to the main image (input?), and possibly to other images to combine them, or textures to use as Look-up tables.
Can I do that using a custom color filter?

Thanks for helping.

@mattleibow
Copy link
Contributor

As of today, SKRuntimeEffect is not supported on a raster/bitmap canvas and only on the GPU.

@mattleibow
Copy link
Contributor

Duplicate of #1822

@mattleibow mattleibow marked this as a duplicate of #1822 Jul 31, 2023
@dbriard
Copy link
Author

dbriard commented Aug 1, 2023

As of today, SKRuntimeEffect is not supported on a raster/bitmap canvas and only on the GPU.

Hi @mattleibow
Thank you for your answer, however this one is not about rendering in bitmap, but how to SKRuntimeEffect's ToColorFilter function.
I implemented Lut3D effect in a shader and I use it with DrawRect, but I would like to convert it to ColorFilter to use it with DrawImage. With shader, as I am using a LUT, I am forced to use Low interpolation (no-mipmap) sampling, instead of Medium (mipmaps) for the drawing image which do not look as great as medium.

@ghost ghost locked as resolved and limited conversation to collaborators Aug 31, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants