Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411425 Posts in 69363 Topics- by 58416 Members - Latest Member: JamesAGreen

April 19, 2024, 08:26:09 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)The happy programmer room
Pages: 1 ... 209 210 [211] 212 213 ... 279
Print
Author Topic: The happy programmer room  (Read 677758 times)
ProgramGamer
Administrator
Level 10
******


aka Mireille


View Profile
« Reply #4200 on: October 28, 2015, 08:11:33 PM »



 Screamy
Logged

gimymblert
Level 10
*****


The archivest master, leader of all documents


View Profile
« Reply #4201 on: October 28, 2015, 08:38:45 PM »

@Princessa
Convolution can do a lot of neat visual trick, a lot of filter are just data in the grid
Logged

InfiniteStateMachine
Level 10
*****



View Profile
« Reply #4202 on: October 28, 2015, 08:40:04 PM »

I recognize that method. The one where you separate on each axis in 2 passes. Saved my bacon at a previous job where I was doing a naive neighbor sampling method that killed the video card once I went up to 15 samples.
Logged

oahda
Level 10
*****



View Profile
« Reply #4203 on: October 28, 2015, 11:44:45 PM »

It was nice to do this in the GLSL fragment shader since I didn't really have to manually handle two images to copy between. Every fragment reads from the original texture which is passed to the shader anyway and then updates itself immediately without affecting the original texture which would break the algorithm, like the video says. Didn't have to set anything new up to achieve this. Just a few new lines of GLSL in my existing fragment shader.
Logged

InfiniteStateMachine
Level 10
*****



View Profile
« Reply #4204 on: October 29, 2015, 07:22:03 AM »

I've never seen a method that didn't do it in the fragment shader.


EDIT: Oh maybe my comment about 2 pass implied it. I just meant you sample the x and then then y and split them.

Of course this method completely breaks down into more of a ghosting effect than a blur after you go anywhere past the slightest blur (you can see it at the extremes of the fish animation posted).
Logged

oahda
Level 10
*****



View Profile
« Reply #4205 on: October 29, 2015, 08:15:37 AM »

Yeah, but I noticed it gets blurrier without having to move the sample distance from the pixel of interest if you make the edge numbers of the kernel greater than the numbers nearer to and on the pixel of interest.

I'll show some screenshots the next time I'm on the computer.
Logged

InfiniteStateMachine
Level 10
*****



View Profile
« Reply #4206 on: October 29, 2015, 10:39:25 AM »

Cool Smiley It would be great to see your findings. If there's a way I can increase the blur without causing that separation effect that would be awesome. IIRC my version crapped out somewhere between an equivalent gaussian blur of 9-15 samples. Maybe if I have better incoming params I can push it further.

I don't know much about blurring algorithms for real time graphics. Does anyone know of any other fast methods to achieve blur?

Logged

oahda
Level 10
*****



View Profile
« Reply #4207 on: October 31, 2015, 02:42:20 AM »

Here we go. The non-blurred original plus four variations on a 3x3 kernel. Each image showing a blurred result is cut in half with the original below the red line for comparison.

The ugly border around the sprite is just because I put the blur code in a weird place and it's fighting against some other shaders in my game, so don't worry about that. It has nothing to do with the blur.

« Last Edit: October 31, 2015, 07:36:19 AM by Prinsessa » Logged

BorisTheBrave
Level 10
*****


View Profile WWW
« Reply #4208 on: November 01, 2015, 03:23:16 AM »

I recognize that method. The one where you separate on each axis in 2 passes.
Of course this method completely breaks down into more of a ghosting effect than a blur after you go anywhere past the slightest blur (you can see it at the extremes of the fish animation posted).
If there's a way I can increase the blur without causing that separation effect that would be awesome.
The 2 pass approach for separable filters doesn't produce a separation effect. It should look identical to the equivalent 2d filter (e.g. gaussian or box blur). Are you implementing it right?

What's causing ghosting is the fact you are sampling with a separation distance other than 1 pixel. If you want a larger filter radius but keep a high quality blur, you need to use a larger filter kernel (or for Gaussian blur, repeat the blur).

NB: You are probably reducing the speed of your blur by using a separation distance other than 1 pixel. When sampling the input texture at a non-pixel co-ordinate, the graphics card blends the 4 nearest pixels. If you use texelFetch instead, then it doesn't perform this unnecessary blending. Also, use the texelFetchOffset rather than texelFetch - some graphics cards have optimizations activated for offsets, precisely because blurs are so common.
Logged
InfiniteStateMachine
Level 10
*****



View Profile
« Reply #4209 on: November 03, 2015, 11:56:34 AM »

I recognize that method. The one where you separate on each axis in 2 passes.
Of course this method completely breaks down into more of a ghosting effect than a blur after you go anywhere past the slightest blur (you can see it at the extremes of the fish animation posted).
If there's a way I can increase the blur without causing that separation effect that would be awesome.
The 2 pass approach for separable filters doesn't produce a separation effect. It should look identical to the equivalent 2d filter (e.g. gaussian or box blur). Are you implementing it right?

What's causing ghosting is the fact you are sampling with a separation distance other than 1 pixel. If you want a larger filter radius but keep a high quality blur, you need to use a larger filter kernel (or for Gaussian blur, repeat the blur).

NB: You are probably reducing the speed of your blur by using a separation distance other than 1 pixel. When sampling the input texture at a non-pixel co-ordinate, the graphics card blends the 4 nearest pixels. If you use texelFetch instead, then it doesn't perform this unnecessary blending. Also, use the texelFetchOffset rather than texelFetch - some graphics cards have optimizations activated for offsets, precisely because blurs are so common.

Implementing it wrong is a high possibility. It was 7 years ago and I hadn't done a lot of shader/graphics programming. 

Then again the level of blur I was trying to do was crazy high.
Logged

darkhog
Level 7
**


Dragon Agent


View Profile
« Reply #4210 on: November 03, 2015, 12:49:26 PM »

Redid the way my engine works with scripts a bit. It has, well, become a whole lot more like Unity yet again

Why don't use Unity then? Since in 5 restrictions of Unity Free are gone I don't see why you can't use it instead and do away with headaches (well, at lest those related to writing core engine Wink)
Logged


Be a computer virus!


I cannot C well, so I stick with simpler languages.

There are no impossible things, there is only lack of skill.
oahda
Level 10
*****



View Profile
« Reply #4211 on: November 03, 2015, 11:03:19 PM »

Just because my scripts now use a class like Unity's scripts doesn't mean it suddenly is Unity. Tongue

And there's no "switch" to be made. I use Unity too for a bunch of stuff. But making my own engine as well because it's fun and I learn a lot. Different tools for different purposes!

And every experience feeds into the other. Sometimes I learn stuff while working on the engine that I can take with me to Unity and sometimes it's the other way around.

I would mostly agree with the old mantra of "make games, not engines" if your main goal is to just make a game and something like Unity doesn't restrict your vision, but I don't just want to make a game. I want to excel in programming in general and have the freedom to mess around any way I like. General programming and software design is just as much of a hobby of mine as making games. That's why I use Unity sometimes too. And in the past a bunch of games without really making a wholesale engine, but not using much more than something like SFML or an HTML5 canvas with JS either. There's lots of ways!

But I am making a game alongside the engine, so I'm not just hacking away at something and hoping that it'll end up being useful. Making the engine is making a game as well, which is testing the engine in practice along the way. It's just that I put anything that could be used for any game in a code base that's separate from the main game, so that I'll be able to reüse it in the future if I want. But it's also true that some days I'll be in a hardcore programming mood rather than a gamedev mood, and I might experiment with some neat engine system just for the fun of it as well.
« Last Edit: November 03, 2015, 11:15:39 PM by Prinsessa » Logged

oahda
Level 10
*****



View Profile
« Reply #4212 on: November 04, 2015, 01:38:35 PM »

All right. Update on above blur posts.

Reading this info on gaussian function/distribution and nagging the code from the reply with 16 votes (so not the top reply) from this post on StackOverflow I understood the basic workings of a legit gaussian blur based on an actual gaussian distribution and used the code I nagged to generate a kernel of any size with a sigma of any value (higher sigma = more blur, but it shows more the bigger the kernel is).

If I really crammed it up (I think this was an 11x11 kernel with a sigma of 10) I got a very nice, big blur:



Applying a bit of the "ghosting" effect discussed earlier by doubling the distance between the samples, it gets really nice and mushy:



However, both of these completely killed the FPS (might be because I generated the kernels every frame for every fragment…). Here's a bit of a compromise combining a 5x5 kernel with the ghosting effect:



As a bonus, I randomly stumbled across a contrast effect by making the biggest number negative in my original 3x3 (not proper gaussian) kernel:

Logged

J-Snake
Level 10
*****


A fool with a tool is still a fool.


View Profile WWW
« Reply #4213 on: November 04, 2015, 02:50:33 PM »

Why don't use Unity then? Since in 5 restrictions of Unity Free are gone I don't see why you can't use it instead and do away with headaches (well, at lest those related to writing core engine Wink)
It's funny because the reason I am writing my own engine "from scratch" is to avoid problems. It is the only way to ensure my engine is working perfectly and exactly to my needs.

For instance I have seen even industry veterans teaching flawed implementations of game loops, ignoring numerical stability. And that is what most newcomers are eating up without questioning.
Logged

Independent game developer with an elaborate focus on interesting gameplay, rewarding depth of play and technical quality.<br /><br />Trap Them: http://store.steampowered.com/app/375930
ProgramGamer
Administrator
Level 10
******


aka Mireille


View Profile
« Reply #4214 on: November 04, 2015, 05:02:13 PM »

J-Snake this is completely unrelated, but your avatar is broken. Just thought I'd mention it.
Logged

InfiniteStateMachine
Level 10
*****



View Profile
« Reply #4215 on: November 04, 2015, 05:38:15 PM »

All right. Update on above blur posts.

Reading this info on gaussian function/distribution and nagging the code from the reply with 16 votes (so not the top reply) from this post on StackOverflow I understood the basic workings of a legit gaussian blur based on an actual gaussian distribution and used the code I nagged to generate a kernel of any size with a sigma of any value (higher sigma = more blur, but it shows more the bigger the kernel is).

If I really crammed it up (I think this was an 11x11 kernel with a sigma of 10) I got a very nice, big blur:



Applying a bit of the "ghosting" effect discussed earlier by doubling the distance between the samples, it gets really nice and mushy:



However, both of these completely killed the FPS (might be because I generated the kernels every frame for every fragment…). Here's a bit of a compromise combining a 5x5 kernel with the ghosting effect:



As a bonus, I randomly stumbled across a contrast effect by making the biggest number negative in my original 3x3 (not proper gaussian) kernel:



Very cool Smiley
Logged

gimblll
Level 2
**



View Profile WWW
« Reply #4216 on: November 05, 2015, 10:17:34 PM »

I had to use something from Boost (no choice really) and super surprisingly it was trivial to extract just the piece I needed without bringing the whole gigantic monster over to my project. Yeah! Gomez
Logged

Garthy
Level 9
****


Quack, verily


View Profile WWW
« Reply #4217 on: November 05, 2015, 10:51:33 PM »

I had to use something from Boost (no choice really) and super surprisingly it was trivial to extract just the piece I needed without bringing the whole gigantic monster over to my project. Yeah! Gomez

Boost has a surprisingly large quantity of high quality code (NB: I did not say all of it is high quality code!) and IMHO is worth consideration for inclusion in most C++ projects. Having said that, it is reasonably modular, and you're already reaping the benefits of that.

Don't worry, in time you'll become one of us. First a few headers here, then a single library, and next thing you know Boost is basically a prerequisite of your project and you can't imagine working without it.

Resistance is futile.
Logged
gimblll
Level 2
**



View Profile WWW
« Reply #4218 on: November 05, 2015, 10:57:35 PM »

Boost has a surprisingly large quantity of high quality code (NB: I did not say all of it is high quality code!) and IMHO is worth consideration for inclusion in most C++ projects. Having said that, it is reasonably modular, and you're already reaping the benefits of that.

Don't worry, in time you'll become one of us. First a few headers here, then a single library, and next thing you know Boost is basically a prerequisite of your project and you can't imagine working without it.

Heh, yeah. I have nothing against Boost as such and I have used it in the past. It's just that I don't want to introduce the dependecy to complicate building my project right now (multiple platforms etc.). I'm also hoping to keep the compile times to a minimum, which Boost doesn't really help with at all. Smiley
Logged

zilluss
Level 1
*



View Profile
« Reply #4219 on: November 05, 2015, 11:20:46 PM »

However, both of these completely killed the FPS (might be because I generated the kernels every frame for every fragment…

Are you passing the kernel fragments from the vertex shader? I've read that this is faster than accessing them directly in the fragment shader because the driver can optimize the texture access, which is usually a costly operation. Also, applying a 5x5 kernel blur multiple times will have the same results as a one-time blur with a larger kernel and might end up being faster.
Logged

@zilluss | Devlog  Hand Point Right
Pages: 1 ... 209 210 [211] 212 213 ... 279
Print
Jump to:  

Theme orange-lt created by panic