Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (AndrewAMD, chsmac85, dr_panther, TedMar), 939 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 3 of 3 1 2 3
Re: Gaussian Blur PP Pixel Shader [Re: TSG_Torsten] #350543
12/16/10 21:53
12/16/10 21:53
Joined: Oct 2004
Posts: 4,134
Netherlands
Joozey Offline
Expert
Joozey  Offline
Expert

Joined: Oct 2004
Posts: 4,134
Netherlands
Although mine wasn't yet working good, for some reason your version is very laggy for me. Whatever setting I use I barely get over 10fps, and the game lags a whole lot even for 10fps. This is weird.


Click and join the 3dgs irc community!
Room: #3dgs
Re: Gaussian Blur PP Pixel Shader [Re: Joozey] #350548
12/16/10 22:22
12/16/10 22:22
Joined: May 2005
Posts: 2,713
Lübeck
Slin Offline
Expert
Slin  Offline
Expert

Joined: May 2005
Posts: 2,713
Lübeck
Blurring in different directions in several passes will always be faster with better result.
The if statements in shaders are also something one has to be very carefull with, as they will always be executed, when using a shader model below 3.0. 3.0 and above uses dynamic branching, which means that the shader kinda compiles to several mutuations, which are than choosen at runtime. While dynamic branching can be a great thing when used wisely, it can cause the shader compiling to take endlessly long and the execution can be very slow, especially if used much.
Another thing which can be very bad are loops. It most cases it is faster to unroll them, which can basicly done by the compiler, but can offer some more freedom when doing it yourself.
When using shaders, there are instruction limits as well as some other limits. I don´t see a way to check a shader for being within those limits, when using loops with a varying counter. Especially, as this has to happen at compile time.
The reason for all these restriction I guess, is basicly that they are meant to run extremely parallel for the best performance possible.

Re: Gaussian Blur PP Pixel Shader [Re: Joozey] #350637
12/17/10 19:56
12/17/10 19:56
Joined: Mar 2005
Posts: 564
/www/europe/ germany/index.php
TSG_Torsten Offline OP

User
TSG_Torsten  Offline OP

User

Joined: Mar 2005
Posts: 564
/www/europe/ germany/index.php
Originally Posted By: Joozey
Although mine wasn't yet working good, for some reason your version is very laggy for me. Whatever setting I use I barely get over 10fps, and the game lags a whole lot even for 10fps. This is weird.


Does it also lag if you use the STATIC_VALUES var? Or just when using dynamic settings?

@Slin:
The dynamic branching since PS 3.0 sounds interesting, didn't hear about it before. Are there any basic things a shader developer has to do to use it "wisely" as you said?

Regards
TSGames

Re: Gaussian Blur PP Pixel Shader [Re: TSG_Torsten] #350651
12/17/10 21:48
12/17/10 21:48
Joined: Mar 2006
Posts: 2,252
Hummel Offline
Expert
Hummel  Offline
Expert

Joined: Mar 2006
Posts: 2,252
A short passage from an ATI paper:
Quote:

Dynamic branching
The ATI Radeon HD 2000 hardware has excellent dynamic branching performance for all three shader
stages. Using dynamic branching you can reduce the workload in e.g. a pixel shader by skipping past
instructions that don’t need to be executed. In a lighting situation, if the pixel is in shadow you don’t
need to compute the whole lighting equation but may return zero or the ambient value immediately.
Same thing if the pixel is beyond the light radius. It can be beneficial to rearrange your code so that you
can do some large scale culling early in the shader. For instance attenuation is usually cheap to compute,
so it makes sense to do that first in the shader. Depending on how your shader looks you may sometimes
see better performance if you stick to a small set of branches instead of several branches shortly after
each other. Thus it may be faster to multiply the attenuation with the shadow factor and check that value
against zero, rather than checking attenuation first and then shadow in a separate branch. This varies a
lot with the situation, so it’s recommended that you try both approaches and see which one comes out
faster in your application.
One thing to keep in mind though is that branches need to be coherent to achieve top performance. If
pixels within the same thread take different branches the hardware will have to execute both sides of the
branch and just select the results for each pixel. So for branches that generally are not coherent you will
probably see a performance loss compared to code without branching. For the ATI Radeon HD 2000 you need a coherency of at least 64 pixels or vertices. Anything that varies in smaller units than that in
general should not use dynamic branching. For example you may have the following code:

Code:
float diffuse = dot(lightVec, normal);
if (diffuse > 0.0)
{
// Compute lighting ...
}



If the normal is an interpolated normal across the surface this branch is fine. But if the normal comes out
of a high-frequency normal map this code may result in a performance loss. This is because normals
from a high-requency normal map can typically vary a lot from pixel to pixel. As a result, in most cases
the hardware will not be able to skip past the code within the if-statement, so there is no performance
gain to be had, but you incur a small performance hit from doing the actual branch test and possible
additional register pressure.


Better you google for more information. If you find something interesting let us know. We are as willing to learn as you. wink

Re: Gaussian Blur PP Pixel Shader [Re: Hummel] #350995
12/20/10 21:34
12/20/10 21:34
Joined: Oct 2004
Posts: 4,134
Netherlands
Joozey Offline
Expert
Joozey  Offline
Expert

Joined: Oct 2004
Posts: 4,134
Netherlands
Yes it still lags. Do you still have the previous version? I can't make it not lagging anymore.

EDIT: nevermind, without the ifdef's it seems to work lag-less.

Last edited by Joozey; 12/20/10 21:50.

Click and join the 3dgs irc community!
Room: #3dgs
Re: Gaussian Blur PP Pixel Shader [Re: Joozey] #351239
12/22/10 22:58
12/22/10 22:58
Joined: Mar 2005
Posts: 564
/www/europe/ germany/index.php
TSG_Torsten Offline OP

User
TSG_Torsten  Offline OP

User

Joined: Mar 2005
Posts: 564
/www/europe/ germany/index.php
Strange thing, for me it works... But anyway, you got it work, so everything seems okay now?! wink

Regards
TSGames

Re: Gaussian Blur PP Pixel Shader [Re: TSG_Torsten] #351246
12/22/10 23:42
12/22/10 23:42
Joined: Oct 2004
Posts: 4,134
Netherlands
Joozey Offline
Expert
Joozey  Offline
Expert

Joined: Oct 2004
Posts: 4,134
Netherlands
Well only with defines, not with skills tongue


Click and join the 3dgs irc community!
Room: #3dgs
Page 3 of 3 1 2 3

Moderated by  adoado, checkbutton, mk_1, Perro 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1