I am encountering a screen tear issue using OpenGL on Windows 10. . I am doing a ray marching demo (rendering just 2 triangles and ray marching and shading terrain in fragment shader). Rendering with GTX 860M, the app does not have an issue with staying at 60 FPS (at least at lower resolution). A screen tearing is present however (and the following video was rendered at especially low resolution to make sure this has nothing to do with the complexity of the fragment shader code):
Screen tearing video at YouTube.
What I've tried:
I am creating the OpenGL context using the recommended settings.
I have tried manually turning VSync on using (wglSwapIntervalEXT(1)), although that should be the default behavior.
I have tried placing glFinish before the SwapBuffers call, i.e.:
while (isRunning)
{
ProcessMessages(window, &context);
App::Update(&context);
glFinish();
SwapBuffers(windowHandle);
}
I have tried setting VSync to "Always on" in the Nvidia control panel. I have also tried creating the window using GLFW instead of WinApi. I have tried creating the window both in fullscreen and resizable mode.
I haven't seen any improvement though.
Related
Does it make sense to use WS_EX_NOREDIRECTIONBITMAP window style when rendering with Vulkan?
From MSDN:
WS_EX_NOREDIRECTIONBITMAP The window does not render to a redirection surface. This is for windows that do not have visible content or that use mechanisms other than surfaces to provide their visual.
It would be reasonable to assume that as we create our own surface with vkCreateWin32SurfaceKHR and swapchain with buffers with vkCreateSwapchainKHR we do not need any intermediate surface to render to.
When setting WS_EX_NOREDIRECTIONBITMAP it does work as expected on NVidia GPU (content is rendered, didn't measure a performance benefit though), however it doesn't work on Intel GPU (content is not visible, window is completely transparent).
I use Gaussian blur to achieve the lighting effect.
On android, after rotating the screen, the first half of the screen is normal, and the second half of the screen is jagged.
This problem has also appeared on some iOS phones.
I don't know what the problem is.
I used fbo, texture buffering, depth buffering, and stencil buffering, and I recreated them with new dimensions each time I rotated the screen.
Ask what is the problem?
I'm trying to create a short opener for a clip by using a plane and an animated texture. I created the animated texture sheet, frame by frame, in photoshop. It's a large texture, 12x12 frames. When I try playing it in unity, while it works, it is of a significantly lower quality.
I have seen posts about tweaking my import settings, but these are the only ones I see (no max size etc)
I did have to use an older version of unity to make it work with the rest of the project I was working on - is that the problem? I feel like even older versions should be capable of generating good quality
Disable mipmaps. Mipmaps are downsized versions of your texture used for rendering at different distances. If the distance you have your image from the camera is far enough, Unity will use one of those smaller versions, making it blurry.
Disable blend mode (set it to 'Point'). Bilinear Filtering slightly blurs textures so that they scale better or render at sub-pixel positioning better. However, this makes them less crisp.
You may want to set the texture mode from 'Default' to 'Sprite 2D' or 'GUI', I'm not sure what version of Unity you're on (2017?) as I don't recognize the layout of the inspector you have there. Sprite 2D settings tend to optimize for images that are intended to be pixel perfect, same goes for GUI textures.
I'm making a 2d tile level editor (you click a tile on the loaded spritesheet and then can draw it to the main area). Although it performs fine on desktop the mobile performance is staggeringly slow, so I've been testing out various perf tweaks. Monitoring the results with framerate monitor from chrome dev tools (desktop), I noticed something I don't understand. When I click on the menu icon and the overlay menu pops out (visible on the left in the screenshot, uses css transform:translate for the animation) the frame rate skyrockets up to about the monitor refresh sync rate, even when drawing the canvas.
If I haven't touched the menu icon, the framrate is about 40fps on idle and ~15fps when drawing the canvas, but simply triggering the menu animation eliminates the framerate drop. It also seems to have a lasting effect, the idle framerate of 40fps no longer drops on repaints when the menu is closed, and when the menu is open the framerate stays up near 60fps.
So the question is twofold: why does triggering this css animation have such a HUGE effect on canvas drawing perf (15fps vs 60), and is there any way to force a consistent 60fps without having the menu open all the time?
PS* The visibility of the menu is irrelevant, leaving it on the page makes no difference but animating it in seems to affect the framerate greatly. The menu has the 'null transform hack' applied because it was triggering a repaint of the canvas it overlays, but removing only drops the fps a little at each stage of the process, the relative performance of the different states of the program are similar.
Chrome has this thing where upon using a css transformation it enables hardware acceleration.
It would be easy to verify it by moving the menu position with js instead of using css tranformation.
Regarding the second part of the question, if that's the case, a hidden or off-screen transformation should have the same effect.
I am developing a document based application for Mac OS X. It's a kind of media player, but instead of playing audio or video files it is supposed to open text-files containing meta-data specifying OpenGL animations. I would like to mimic Apples QuickTime X window style. This means, i have to do all the window drawings myself, because Cocoa has no appropriate window style.
There is one thing which gives me headaches: The rounded corners usually to be found on Mac OS X windows. I tried using the borderless window mask and working some CGS magic - there are some private Apple headers which allow window shaping, but they are of course undocumented. I was able to cut rectangular holes in my windows edges, but i couldn't figure out how Apple achieves rounded corners.
Creating a transparent window and drawing the frame myself does not work, because an OpenGL viewport is always rectangular, and the only way to change it is to turn on NSOpenGLCPSurfaceOpacity for alpha transparency and using the stencil buffer or shaders to cut out the edges, which seems like a hell of a lot of overhead.
If i put an OpenGLView into a standard Cocoa window with titlebar, the bottom edges are rounded. It seems this is happening at the NSThemeFrame stage of the view hierarchy. Any ideas how this is done?
Use a layer-backed view, and do your drawing in the CALayer on an invisible window. Layers include automatic handling of rounded corners and borders.
Background for CALayer is in the Core Animation Programming Guide. To create a layer for NSView, you need to call [view setWantsLayer:YES]. You would create a CAOpenGLLayer and assign it to the view using setLayer:.
See CALayerEssentials for sample code demonstrating how to use CAOpenGLLayer among other layer types.
Since Robs suggestion didn't work and no one else contributed to the discussion i settled on using the stencil buffer to crop the windows corners. I did this by creating a texture from the windows background and rendering it into the stencil buffer, discarding all transparent pixels. Looks fine, but is slow when resizing the window :/