Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / [SOLVED] SetVSync with Shader pack

Author
Message
Game_Code_here
4
Years of Service
User Offline
Joined: 2nd Jun 2020
Location:
Posted: 8th May 2023 06:00
Ok so here is something to look out for.

If you want to make a 3d game with good looking water that reflects and are looking into the shader pack?

You will learn that if you use SetVSync for screen tearing your frames will drop unexpectedly all over the place.

When set to a regular sync rate like 60 it works perfect with no slow downs at all with a great looking water effect.

But as soon as you put SetVSync(1) and you have a refresh rate at 60 HZ You will get messed up drops.

I wonder if you use SetVSync with more ram if this will fix the issue?

Or is there a better way to stop screen tearing?

The author of this post has marked a post as an answer.

Go to answer

James H
17
Years of Service
User Offline
Joined: 21st Apr 2007
Location: St Helens
Posted: 8th May 2023 12:40
I don't quite recall but fairly sure that using setsyncrate is still needed beforehand so that the second parameter regarding cpu can be changed for the accurate mode(obviously using vsync after this overrides the first parameter). Then I have to make sure my laptop power mode is set for performance.
Win 10 Home 64, Intel(R) Core(TM) i5-10300H, 8GB DDR4, NVidia GeForce GTX 1650 4GB GDDR6
Game_Code_here
4
Years of Service
User Offline
Joined: 2nd Jun 2020
Location:
Posted: 8th May 2023 21:38
Yes I tried this same thing and there is not difference so I guess using vsync is a no go.
James H
17
Years of Service
User Offline
Joined: 21st Apr 2007
Location: St Helens
Posted: 8th May 2023 23:17 Edited at: 8th May 2023 23:19
Depends on hardware performance perhaps, some things to perhaps consider;
Without vsync on - if at any point your fps drops below the vsync frame rate, then vsync will not help tearing but MAY hinder performance. If you happen to be in a particular area of your level that slows performance greatly, vsync MAY hinder performance at that time. Basically you do not want to have vsync if performance is not always above the frame rate you would get with vsync.
With multiple renders per frame, for example depth of field plus water reflection plus water refraction, AppGameKit MIGHT behave similar to DBP in as much that in DBP using vsync or even capping the frame rate manually, then performance was significantly less - each render is basically a whole new frame, so for every 1 frame of game loop time, the graphics frames are being rendered several times. To gain the best performance setting sync rate 0 and using vsync as well was best. This meant your game loop ran as fast as possible while having a stable frame rate, again hardware dependent and application demand dependent. If it was set to 100 fps and vsync was on then the game loop was at 100 fps and the app would be capped by the vsync. If it was set to 100 fps and vsync off then both game loop and graphics would run at 100 fps.
You might need to set vsync on in your graphics properties in windows, for example with nvidia that would be the nvidia control panel.
I haven't played with it but there are commands for "present mode" options. According to help files it has immediate and delayed modes. As vysnc can delay frames, then maybe exploring this option is a good idea.
You should also bear in mind that if the game loop is significantly demanding at any point it will affect the frame rate just as dramatically with just a cube in the scene, as graphical fps should be different to the main loop fps.
When uncapped or capped you will need timer based code to deal with frame rates that are fluctuating. Even with this the visuals can be terrible especially when the frame rate fluctuations are dramatic.
It is best to ensure your game/app runs faster than what the vsync cap might be in any single game loop. So if you have a scene of boxes that gets 100fps, but render it twice in 1 frame of game loop so that you can have depth of field for example, then that is going to drop below 60 fps. With vsyc on it it going to attempt to resolve that and in attempting to do so(as it is not possible to resolve) will impact performance further, I think in essence vsync does nothing to to smooth out frame rates, it attempts to synchronize the game frame rate and the monitors refresh rate, I would say it really requires a certain level of performance/stability in the first place.
Outside of that I am out of ideas - oh I forgot to mention having the laptop plugged in while using max performance for power setting made a difference to. Bare in mind I am no authority on this, however you might get somewhere with the info provided. I have watched your videos recently posted here and saw nothing that seemed remotely demanding on the hardware of today, so if it is in relation to that project then either the hardware specs are extremely low, settings are not set correctly somewhere, drivers might need updating, or your game loops are incredibly taxing.
Win 10 Home 64, Intel(R) Core(TM) i5-10300H, 8GB DDR4, NVidia GeForce GTX 1650 4GB GDDR6
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 8th May 2023 23:36
Have you tried SetVsync(2)?
Game_Code_here
4
Years of Service
User Offline
Joined: 2nd Jun 2020
Location:
Posted: 9th May 2023 02:26
but a mode value of 2 would skip every other refresh which would limit the app to 30fps.

I want a refresh rate of at least 60 frames as this is a computer game not for a phone.

James H

I will work on that and let you know what happens.
Game_Code_here
4
Years of Service
User Offline
Joined: 2nd Jun 2020
Location:
Posted: 9th May 2023 04:38 Edited at: 9th May 2023 04:42
Ok after testing , and testing there is no problems or slow downs with setting a regular v-sync with out the shader sync. As soon as I use the shader packs sync v-sync has problems.

There are no real big loop problems any where in the map Unless I use the shader packs sync.

So after test after test I will conclude that you can not use v-sync with the shader pack and get proper frames.

I get over 60 constant frames per sec with out setting the shader packs sync and 30 to under 30 at times when I do.
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 9th May 2023 09:17
What sort of video card do you have?
Game_Code_here
4
Years of Service
User Offline
Joined: 2nd Jun 2020
Location:
Posted: 9th May 2023 20:41
Quote: "What sort of video card do you have?"


It is pretty decent but not the best in the world but it pushes just about everything.

AMD Ryzen 5 5500U with Radeon Graphics 2.10 GHz hp laptop.

So it could be ram or the Graphics , and if this is the case I will still finish this with the same options and that will make me fell great.

I say this as there are millions of people who upgrade there computers and might be able to play this with water and full shaders with no slow down.

But I must know, is it the coding in the shader pack, or is it my pc?
Game_Code_here
4
Years of Service
User Offline
Joined: 2nd Jun 2020
Location:
Posted: 9th May 2023 20:41 Edited at: 9th May 2023 20:42
Double post somehow? lol
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 10th May 2023 07:47
Do the examples that come with the shader pack run slowly?
Game_Code_here
4
Years of Service
User Offline
Joined: 2nd Jun 2020
Location:
Posted: 10th May 2023 07:55 Edited at: 10th May 2023 07:57
Quote: "Do the examples that come with the shader pack run slowly?"


The only problem like I said was the water, Everything else runs like it should, With no problems at all that i can point a finger at.

But like in my original post, water, well, no. Not with v sync turned on. But also when i do not use v sync, there are little slow down, but then it jumps back real fast.

I'm guessing it is the rendering back and forth that has something to do with it.

But I can not have tearing in my game.
James H
17
Years of Service
User Offline
Joined: 21st Apr 2007
Location: St Helens
Posted: 11th May 2023 17:35 Edited at: 11th May 2023 17:37
So did a bit of reading last night, based on what you have said your graphics is integrated - Vega 7. It is supposed to be half decent. Is this correct?

So you said the water demo - this is the name of the indoor water demo, however what you describe with performance is more like the collection demo which has the ocean or the terrain demo which also has water. For the water demo I get around 6 or 7 hundred fps whereas the other 2 I get around 2 hundred fps. Can you clarify which demo?

I have guessed its the terrain demo water based on your game project appears to have terrain? In any case using largish terrains might be whats causing the poor performance no matter which of any of the water demos if you set them up with a terrain.
For example, with the terrain demo uses a 1024 * 1024 image - that means the terrain itself is over 2 million triangles - 2 triangles per square tile, 1024*1024 point heights is 1023 rows/columns ie 1023*1023 tiles- over a million, so twice that as its 2 triangles per tile.
It also only has a split of 4 * 4 which is just 16 meshes so AppGameKit screen culling is not culling as many as it would if it had a 8 or 16 split size. I want to point out though that I may have changed my demo's so it may be less than a 1024 * 1024 size or more than 4 * 4 split when installed, you would have to check your own install. So over 2 million tri's per render - DOF enabled plus reflect and refract, well thats a whole lot of tris! Even if the height map was 512 * 512 it is still a lot of tris.

I have GTX750 card on my desktop PC with a dual core amd APU cpu.(I don't use it a lot my lappy specs are in my sig). First thing I noticed about your cpu is that it also is APU? A mate once told me they are more suited to office work than games. How true or relevant that actually is is up for debate! That said yours will poop on mine and then some lol! But the GPU according to benchmarks is comparable to a degree. From my attempt at "research" which is just google lol, well your integrated card is a rough equivalence to the nvidia mx250, when I looked at benchmark comparisons between that and my GTX750 mine did better on some things but not others, but which sites to trust info from I don't know.
Overall though I kept reading your machine is for good light gaming.

I mention the comparison because I can tell you I remember when I first tried the terrain/water demo with the GTX750 it too had fairly high frames overall but with drops as low as 45 fps at times. But it also did not surprise me because I know that terrains even slightly large that do not have culling or LOD optimizations are very expensive on performance because of the triangle total, especially when a full screen render is required more than once per frame.
There are things that can be done though for example ensuring my laptop power plan is set for performance, having the accuracy value in the sync rate command set on with the frame rate uncapped, changing the split value to either 8 or 16 - just these things alone gets me from 190 to 200 fps all the way up to 245 to 255 fps.
Now your terrain in the project you posted has a short view distance always? If so you can hide all those terrain meshes in the distance that you don't see. Potentially that will give you massive performance increase. When I applied just a basic level of it to the terrain/water demo I found it was a large boost, obviously dependent on how far the view distance is set. Here is a crude version from when I first picked up AGK(just use images from shader pack):

Win 10 Home 64, Intel(R) Core(TM) i5-10300H, 8GB DDR4, NVidia GeForce GTX 1650 4GB GDDR6
Game_Code_here
4
Years of Service
User Offline
Joined: 2nd Jun 2020
Location:
Posted: 11th May 2023 22:24
Quote: "largish terrains might be what's causing the poor performance no matter which of any of the water demos if you set them up with a terrain."


perfect fames per sec with no slow down at all with out v-sync set, So i do not begive it is from a large terrain, But could it be from the camera angles?

I noticed I get no slow down till I turn my camera the other direction from the water while standing in the water. And when i return my cameras back the other way, I get my speeds back.

Here is my water set up.

Also i made the water real small, The same size as the demo, And still had a slow down, nothing changed. I am loading my water first like said and image for it first for Camera clipping.

My laptop is a gamming laptop that runs just about anything like I said. If this was my graphics Then it would have to be the memory on my graphics card and I believe it could be. But when I run a stress test on my pc I get a real high passing number.

Also we must remember that when I do not use v-sync it runs fine so unless v-sync forces my graphics card over the top then I can not answer and do not know.

And this is what makes this strange. My pc runs fine till v-sync is applied.





James H
17
Years of Service
User Offline
Joined: 21st Apr 2007
Location: St Helens
Posted: 11th May 2023 23:36
Ah ok you know best, just a mere few poly's, glad I now know the answer to the questions, good talk though.
Win 10 Home 64, Intel(R) Core(TM) i5-10300H, 8GB DDR4, NVidia GeForce GTX 1650 4GB GDDR6
Game_Code_here
4
Years of Service
User Offline
Joined: 2nd Jun 2020
Location:
Posted: 12th May 2023 00:38 Edited at: 12th May 2023 00:38
Quote: "Ah ok you know best"


If that was true I would not be here asking lol. Silly.

I do think but not to sure if it has something to so with the water shaders coded for frames and not v-sync?

I would love to know.
Game_Code_here
4
Years of Service
User Offline
Joined: 2nd Jun 2020
Location:
Posted: 12th May 2023 13:29
So building this game in studio on Vulcan solved all my problems.

Open gl runs it ok, but hardly no slow downs with Vulcan.

problem solved.
Game_Code_here
4
Years of Service
User Offline
Joined: 2nd Jun 2020
Location:
Posted: 14th May 2023 00:58 Edited at: 14th May 2023 00:59
This post has been marked by the post author as the answer.
I have finely figured out what was wrong and it had nothing to do with the shaders or water or anything like this.

It had to do with my camera far view set to high and rendering everything all at once.


I was setting my camera view to 50000 with the shaders command as suggested in another post and to be honest I do not know why anyone would do this.

Now I set my view to 2000 and no frame drops at all.

Now my only problem is my sky box hiding everything lol, but one problem at a time.

I am so happy to find the problem.

I will mark my own answer as the answer lol.

Thank you all for any help you tried.

So good advice? Do not set your view to far away.
Blendman
10
Years of Service
User Offline
Joined: 17th Feb 2014
Location: Arkeos
Posted: 16th May 2023 09:32
HI

I have the same matter when I used shadows with sun. If the camera range is to far, the fps slow down or I have shadow "flickerings" (In agk classic, in studio, it seems that work better).
It's the same if I use to much object (more than 400 or 500 objects in my level for exemple).
I don't know if it can help, because I think you don't use shadows in your video
AGK2 tier1 - http://www.dracaena-studio.com
Game_Code_here
4
Years of Service
User Offline
Joined: 2nd Jun 2020
Location:
Posted: 16th May 2023 11:04
Quote: "because I think you don't use shadows in your video"


I am just using reflections that give the look of shadows, and my shadows are set to very small for better performance.

I also depend on the sun for depth of shading, it gives the whole world a more nature look.

Look at my recent video and you will see a lot of depth now, I am still not finished, i am blending in all the detail together for lighting.

Login to post a reply

Server time is: 2024-11-21 13:07:14
Your offset time is: 2024-11-21 13:07:14