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 / underwater shader?

Author
Message
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 10th May 2011 10:31
Ok, I'm not even going to pretend to really know much about shaders. For the most part, you apply a shader to an object. But are their "camera" shaders that can affect an entire scene? I'd like to apply a slight underwater morphing effect to the screen for a 2D game.

baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 10th May 2011 10:49 Edited at: 10th May 2011 10:52
I managed to get this working a while ago using the image kit!

Here is a link to the thread:
http://forum.thegamecreators.com/?m=forum_view&t=178800&b=1

Here is some code:


Hope that helps!

Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 10th May 2011 12:36 Edited at: 10th May 2011 12:49
Looks like IK create target image is now just called IK create image.

Your code pops up the window for a second then just closes without error.

baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 10th May 2011 12:41
Quote: "Looks like IK create target image is now just called IK create image"

You could be right I think it's been updated since I wrote that.

Quote: "Now I just gotta get ImageKit to work. Keeps giving me an error about d3d9_43.dll missing"

Attached. Just put it in the game directory or in your system directory.

Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 10th May 2011 12:50 Edited at: 10th May 2011 13:00
I updated DX, that fixed the issue.


You need to change IK create target image to IK create render target then your demo works. However, I'm still trying to figure out how this makes an underwater effect. It looks static, no movement.

Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 10th May 2011 13:03
Great, now after updating, my game no longer works, just closes without warning.

baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 10th May 2011 13:06
I'll try to take another look ASAP. I haven't used it for a while but trust me it worked and was not static. Looked pretty cool actually.

Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 10th May 2011 13:19
I just drew boxes on the screen in a weird manner.


This stupid DBP IDE is really starting to annoy me tonight.

baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 10th May 2011 15:26
I have this working now.

Attached is the full test project.

Enjoy!


Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 10th May 2011 19:09
Nice work, much appreciated. Now just gotta tweak the values. And I figured out that INK isn't the same as INC

I had to use CLS 0xFF000000 instead of just CLS to clear the image, otherwise trails were left behind since I didn't have a background image being repasted.

Before doing that, I noticed that whatever trails were left behind and not cleared out, were still present after I closed my program and reran it subsequent times! As if the drawing image isn't destroyed from memory when the program closes.

baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 10th May 2011 19:21
Quote: "Nice work, much appreciated. Now just gotta tweak the values."

Glad to help!

Quote: "Before doing that, I noticed that whatever trails were left behind and not cleared out, were still present after I closed my program and reran it subsequent times! As if the drawing image isn't destroyed from memory when the program closes."

I didn't know that

Diggsey
20
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 10th May 2011 19:35
The image is destroyed from memory, it's just that the memory is not reset to zero. When you next run the program, the exact same conditions apply (since you're the only one using graphics memory) and so the image just happens to be created at the same memory address.

[b]
Duffer
23
Years of Service
User Offline
Joined: 9th Feb 2003
Location: chair
Posted: 10th May 2011 20:48
this is fantastic - think the underwater effect looks best with uspeed# set at increments of 0.04 or 0.05 but that's just me - thanks baxslash and Phaelax - v useful....

a long time dabbler with DBC and DBPro with no actual talent but lots of enthusiasm...
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 10th May 2011 22:30
Quote: "this is fantastic - think the underwater effect looks best with uspeed# set at increments of 0.04 or 0.05 but that's just me - thanks baxslash and Phaelax - v useful.... "

Glad you like it @Duffer

I was really pleased with the effect when I finally got it working.

Green Gandalf and SvenB should also be thanked for their input, particularly for SvenB's Image Kit which really makes this effect possible!

Login to post a reply

Server time is: 2026-07-11 02:36:49
Your offset time is: 2026-07-11 02:36:49