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.

DarkBASIC Professional Discussion / "set object filter" for distortion bugged?

Author
Message
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 10th Oct 2010 02:09
As you all may or may not know, I once asked how it would be possible to achieve a distortion effect in this thread:

http://forum.thegamecreators.com/?m=forum_view&t=172964&b=1

In the end I went for the solution where the game is rendered to an image, and textured to a subdivided plain object which is placed in front of the camera. The distortions were easy to program using vertexdata, and it proved itself to be a very fast method.

For those that know the thread, jump to here:

Later on in that thread I noticed the plain was a little blurred, and VanB suggested I use set object filter obj,0. This worked perfectly, but not long ago I noticed two perpendicular lines across the subdivided plain. One on the x axis, the other on the y axis. This image shows it exaggerated, and in case you don't see anything wrong, I drew in with red where the two distorted lines occur.





It's quite hard to explain, and it is even harder to capture in an image or video. You'd have to play it to notice it.

The dimensions of this plain are 40x30. It is divided into a 50x50 grid, and it is locked on to the camera with the following code:

lock object on obj,0,0,25

25 is the perfect distance from the camera at those dimensions for the plain to fully cover the screen.

Any help greatly appreciated, if you need a demo to test the problem, I'll happily upload one.

TheComet

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 10th Oct 2010 03:07
Could you post the images both before and after you apply the first to the subdivided plain? It would be nice to know where to look for the problem.

At first sight there seems to be a change in the lighting not just a bad join - the horizontal red line happens to obscure what I mean but you can see it if you look at that part of the first image.
Scorpyo
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: italy
Posted: 10th Oct 2010 11:39
the red line mark is not in the correct position if you look few millimiters to the right of it you will see that there is a floor tiles mismatch.
But no idea what's causing that
Quel
17
Years of Service
User Offline
Joined: 13th Mar 2009
Location:
Posted: 10th Oct 2010 12:18
I think this idea is genius, however poorly optimized, and the fact it even causes this error, now that's not cool.

What i would do with all what i have got already,

...1. is that to make the distortion plane only visible when needed.
2. Leave the filter on it.
3. Size it down to fit the area only necessary for the effect (this way a much lower resolution is enough, which requires much less calculation).
4. You should modify the UV data as well, so it shows only the required part of the screen according to its position.
5. And with blend mapping, texture it with only the required part of the screen, plus a B&W radial gradient map as alpha.

(6. ..and a not technical advice, yepp, make it slower!)
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 10th Oct 2010 13:17
Quote: "the red line mark is not in the correct position "


Surely he did that deliberately so you could see the lines he was talking about?

Quote: "if you look few millimiters to the right of it you will see that there is a floor tiles mismatch"


My point exactly. Lighting perhaps, since we don't know about the geometry?
Scorpyo
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: italy
Posted: 10th Oct 2010 13:52 Edited at: 10th Oct 2010 13:54
Ahh right,
then it's mismatched UV texturing, if you will notice, the vertical side of the floor on the right has the UV coords unset as opposed to the part at the left
see image attached
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 10th Oct 2010 14:00
Yes, I think that's the problem too.
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 10th Oct 2010 14:34
Maybe it wasn't a good idea to exaggerate the problem I am having with paint

Quote: "Could you post the images both before and after you apply the first to the subdivided plain? It would be nice to know where to look for the problem."


I took two pictures of before and after, and the results are astounding. It seems the plain squishes the scene together by one pixel. Here are the two images.

Without plain:



With plain:



You will probably have to download the images and switch between them a few times to see the problem.

Quote: "...1. is that to make the distortion plane only visible when needed."


It will be used a lot, and with this method I am using it becomes difficult to switch between distortion and non-distortion mode.

Quote: "2. Leave the filter on it."


That's how I had it in the beginning, and it does eliminate the current problem I am having, but then the whole game becomes blurred/not focused, and I didn't like the look of it then

Quote: "3. Size it down to fit the area only necessary for the effect (this way a much lower resolution is enough, which requires much less calculation)."


Quote: "4. You should modify the UV data as well, so it shows only the required part of the screen according to its position."


Quote: "5. And with blend mapping, texture it with only the required part of the screen, plus a B&W radial gradient map as alpha."


That I also considered, but a usual game can have up to 20 distortions at one time, which will slow down the whole game if I had 20 plains then (Or do you mean just stretch the plain over the area I require at the moment?).

Quote: "(6. ..and a not technical advice, yepp, make it slower!) "


Hehe xD Everyone said that, so I made it slower now

Thanks a lot for your advice Quel!

TheComet

Quel
17
Years of Service
User Offline
Joined: 13th Mar 2009
Location:
Posted: 10th Oct 2010 15:01
Well, i told you all of those with one or two effect at once in mind.

Though playing with the blending idea, you could have up to 7 effects i guess (if i remember correctly 8 textures can be blended onto an object, and 1 out of this is the screen capture texture) at once.

Leave the filter on, and do everything the same way how you do right now, except for the thing that you'd place radial gradients everywhere with blend mapping where the effect is present. The picture will be a little blurry where the effect is present, but in my opinion that just adds onto the awesomeness. Imagine how you'd have to manually and costly blur the image, and instead it automatically does it for you without asking...

This, or of course somehow fix the current situation. Though I think my solution would be better, since some way or an other, the picture is going to be distorted... (what resolution do you capture the screen in?)
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 10th Oct 2010 16:37
I see your idea with the blend mapping, but rendering a distorted ring and blending it with the scene at real-time is going to be an incredible fps killer. Especially when rendering 7 of them. With the current method I have, I can render an infinite amount of these distortions, and it is very fast. Even faster than a distortion shader.

I capture the screen at the currently set resolution (it's variable). Currently it's at 640x480.

TheComet

swissolo
16
Years of Service
User Offline
Joined: 9th Jan 2010
Location:
Posted: 10th Oct 2010 16:45
I'm not totally aware when the plain is used but...
If the plain is just used for blurring can't you just hide it when uneeded? Also, is the plain lined up correctly or is it just a tad off?

swis
Quel
17
Years of Service
User Offline
Joined: 13th Mar 2009
Location:
Posted: 10th Oct 2010 17:00
TheComet it may not be really clear to you, because nothing would change from what it is right now, only there would be a 'mask', an alpha channel what hides the rest of the ONE BIG plain which isn't involved at the moment.

Just came into my mind, you wouldn't necessary need to rely on the available blend channels, cuz if you real time edited a low-res memblock (it really wouldn't need to be large, 32*32, or 64*64 maybe), you could make the alpha dynamically, and so being able to pull off as many effect as you want.

How do you capture in such an aspect ratio? You can use anything other than the power of two again?
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 10th Oct 2010 17:26
Quote: "If the plain is just used for blurring can't you just hide it when uneeded?"


The plain is textured with the rendered scene, and then deformed using vertexdata to distort the scene. The blur is an unwanted side-effect which I got rid of with set object filter obj,0, but is now causing distorted lines through the scene, one on the x axis, the other on the y axis.

Quote: "Also, is the plain lined up correctly or is it just a tad off?"


That's exactly my problem. The plain is 40x30 large, and is positioned at 0,0,25 from the camera. Is that lined up correctly?

@ Quel

I'm getting a little lost now, because I don't quite understand what you are explaining to me... What I understand is you want me to render a mask for the expanding ring, and blend that with the scene onto the plain instead of using vertexdata commands. Is that right, or am I totally lost?

Quote: "How do you capture in such an aspect ratio? You can use anything other than the power of two again?"


I used:

set camera to image camera,image,res x,res y

TheComet

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 10th Oct 2010 18:13
TheComet

What's happening at the seam? Is it a boundary between two limbs or objects or something else?
Math89
22
Years of Service
User Offline
Joined: 23rd Jan 2004
Location: UK
Posted: 10th Oct 2010 18:16
You should keep in mind that the screen pixels are aligned according to their top-left corner, while texture pixels are actually centred. This means that if you texture a fullscreen quad, you have to shift the texture by half a pixel to the bottom right.
Quel
17
Years of Service
User Offline
Joined: 13th Mar 2009
Location:
Posted: 10th Oct 2010 19:19
No.

The problem is that in the case of you are unable to fix the current look of it, the unfiltered plain is distorted. Filtered it is blurry.

All i'm saying is that you could hide the plain's parts currently not affected by the vertex manipulation, SO who cares if it is a little blurry since it all happens only on a part of the screen, for a half sec.

Blending an alpha onto the screen capture texture results in hiding parts that you wouldn't like to be visible.

You would create an alpha image real time by placing a radial gradient... "sprite" if you will, at the coordinates where the effect is taking place. The alpha is not animated at all.

Illustration attached.
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 10th Oct 2010 19:23 Edited at: 10th Oct 2010 19:27
!! YAY IT IS SOLVED! Thanks Math89, I didn't know about the centered pixels. It appears the pixels in the top left part of the plain were rounded down a pixel, where the bottom right part of the plain was rounded up a pixel, causing a seem on the plain. Shifting the plain up half a pixel, and left half a pixel solved it

@ Green Gandalf

Above explains it all, it was just a slight misalignment of the plain object that caused the seem

Thanks everyone for helping!

EDIT :

@ Quel

Oooohh, I see what you mean now! I'll give it a go! Only problem is, won't that slow down the process even more? Oh well, I'll see...

TheComet

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 10th Oct 2010 20:51
Quote: "Above explains it all, it was just a slight misalignment of the plain object that caused the seem "


Yes, I suspected that had something to do with it but hadn't checked the details of your project so wasn't sure. Math89 put his finger on it fortunately.

Login to post a reply

Server time is: 2026-07-22 03:51:15
Your offset time is: 2026-07-22 03:51:15