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] SKGLSurfaceView - Cannot stop Motion Blur Effect #2766

Open
1 task done
najak3d opened this issue Feb 26, 2024 · 2 comments
Open
1 task done

[BUG] SKGLSurfaceView - Cannot stop Motion Blur Effect #2766

najak3d opened this issue Feb 26, 2024 · 2 comments
Labels

Comments

@najak3d
Copy link

najak3d commented Feb 26, 2024

Description

We are using our SKGLSurfaceView to render a map that can be panned smoothly.

The issue we're having here is what is rendered is a blending of the previous 2-3 frames! Nothing we do seems to be able to stop this. I even tried "RenderMode = WhenDirty", to see if that stopped it (it did not).

So as we're rendering here at 60 FPS, a simple Animation of a Circle being drawn each frame (onPaint)... and moving it from Left to Right. As you can see below, there are two copies of this circle showing at the same time. This is NOT what we want to be seeing here. This is an unwanted MotionBlur effect, essentially.

image

Is there any trick to make SKGLSurfaceView ONLY render the most recently drawn Canvas output?

Note, for the paint, I tried various BlendModes: Src, SrcIn, SrcOver, SrcATop. All produced the same blurred double-images.

Code

private int _xOfs;
private SKPaint _paint = new SKPaint() { Color = SKColors.DarkRed, StrokeWidth = 3, 
                                                                Style = SKPaintStyle.Stroke, BlendMode = SKBlendMode.SrcOver };

private void _sImgView_PaintSurface(object sender, SKPaintGLSurfaceEventArgs e)
{
				SKPoint pt = new SKPoint(180 + _xOfs, 200);
				_xOfs += 20;
				if (_xOfs > 500)
					_xOfs = 0;

				e.Surface.Canvas.DrawCircle(pt, 77, _paint);
}

Expected Behavior

Single solid-line Circle.

Actual Behavior

Two-Blurred Circles!

Version of SkiaSharp

2.88.3 (Current)

Last Known Good Version of SkiaSharp

Other (Please indicate in the description)

IDE / Editor

Visual Studio (Windows)

Platform / Operating System

Android

Platform / Operating System Version

Android 12

Devices

All of my devices.

Relevant Screenshots

image

It should look more like this one (but solid, not blurred):
image

Relevant Log Output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@nor0x
Copy link

nor0x commented Feb 26, 2024

have you tried clearing the canvas inside of PaintSurface ?
this should ensure a clean canvas for each render frame

private void _sImgView_PaintSurface(object sender, SKPaintGLSurfaceEventArgs e)
{
     // this ⬇️
    e.Surface.Canvas.Clear(SKColors.White);
    SKPoint pt = new SKPoint(180 + _xOfs, 200);
    _xOfs += 20;
    if (_xOfs > 500)
	    _xOfs = 0;
    
    e.Surface.Canvas.DrawCircle(pt, 77, _paint);
}

@najak3d
Copy link
Author

najak3d commented Feb 26, 2024

@nor0x - thank you for your help. I did try that several different ways. In the end, it might help, but doesn't resolve it.

It's difficult to parse out the contributing factors of this double image, which are:

  1. I'm taking a picture -- so shutter speed might be slow enough to capture two frames.
  2. The screen itself has a bit of "memory too"
  3. My eyes have memory.

Since clearing it first with White does seem to help (maybe it's the placebo effect) - It's still looking blurred to me.

I posted here, hoping to hear some advice regarding some hidden "blend mode" effect purposefully done with the SKGLSurfaceView itself -- like it was a "feature" (which for some cases, is true - you want subtle blur).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Ready For Work
Development

No branches or pull requests

2 participants