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

[BUG] SKRuntimeEffect compilation is missing build-in functions #1868

Closed
Oribow opened this issue Nov 18, 2021 · 4 comments
Closed

[BUG] SKRuntimeEffect compilation is missing build-in functions #1868

Oribow opened this issue Nov 18, 2021 · 4 comments

Comments

@Oribow
Copy link

Oribow commented Nov 18, 2021

Description

I've been trying out the new SKRuntimeEffect support in 2.88.0-preview.155 . Compilation of shaders using some opengl functions fails. (Tested with step and smoothstep). Not sure if this a skiasharp problem or a skia problem.

Code

uniform float2 iResolution; 
uniform float2 iPos; 

half4 main(float2 fragcoord) {
  float2 uv = (fragcoord - sk_FragCoord.xy) / iResolution.y;
  float d = length(uv);
  float m = 0.03 / d;
  m *= step(0.2, 0.3);
  return half4(m, m, m, m);
}"

Expected Behavior

This should compile. The same code works on the skia-sksl demo https://shaders.skia.org/.

Actual Behavior

Compilation outputs the following error:
error: 9: unknown identifier 'step'
This also happens with 'smoothstep'. Its weird that the 'length' function still works though. I have read that Skia only supports a subset of GL functions, but since it works on the demo site and these being very important shader functions, I doubt that they aren't included.

Basic Information

  • Version with issue: 2.88.0-preview.155
  • Platform Target Frameworks:
    • Android: 11 (API level 21)
    • Xamarin: 5.0.0.2244
@cyraid
Copy link

cyraid commented May 24, 2023

It errors with 'round' or 'mod' as well.. I'm wondering if it's 'cause it's a bit older of Skia? It kinda hampers the simple 'checkerboard' pattern shader I was gonna make. Not even 'coord.x % 32.0' works.

@LFLumirithmic
Copy link

Can confirm it fails with 'mod' as well. I'm using version 2.88.3 of SkiaSharp inside a .NET MAUI application. It would be great if support for these basic shader functions was added, especially since they work perfectly in the skia shader playground

@mattleibow
Copy link
Contributor

Updating skia to the latest makes most of the functions work, however, the sk_FragCoord uniform is not actually available in the public spec. That is just for internal use by skia.

@mattleibow
Copy link
Contributor

Duplicate of #2543

@mattleibow mattleibow marked this as a duplicate of #2543 Aug 5, 2023
@mono mono locked as resolved and limited conversation to collaborators Sep 4, 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

4 participants