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 / Need help with Render Targets - Urgent!

Author
Message
ShellfishGames
13
Years of Service
User Offline
Joined: 6th Feb 2013
Location:
Posted: 16th Dec 2013 01:26 Edited at: 16th Dec 2013 01:29
Hey!

I'm currently participating at Ludum Dare. The contest ends in 90 minutes, so some quick replies would be really helpful.

Everything worked fine the whole time but now suddenly a problem appeared that I can't solve, although it SHOULD be a matter of seconds.

I created a render target with Image Kit (ik create render target img,w,h). Now I want to set it to transparent. My first solution was to create an image with alpha = 0 on all pixels of the same size as my render target, and paste it onto it using ik paste image on image. This worked, but not anymore apparently. Hence I tried the ik set image channel command to set the alpha channel, but it doesn't do anything. I used it like this:

ik set image channel myRenderTarget, 0xFF000000, 0

No effect.

Furthermore there's the command "ik copy image to render target" listed in the help file, which sounds as if it could do what I want, but the command doesn't actually exist for some reason...

Any idea how I could achieve the desired effect of setting the alpha channel of a render target to 0 for all pixels?

Thanks in advance!

mr Handy
18
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 16th Dec 2013 01:43 Edited at: 16th Dec 2013 01:45
Write a shader for render target quad... if you have time.

edit:
Quote: "alpha channel of a render target to 0 for all pixels?"

Wait, what? Just hide the image...

ShellfishGames
13
Years of Service
User Offline
Joined: 6th Feb 2013
Location:
Posted: 16th Dec 2013 01:49
I want to "clear" the render target before pasting text into it. That's why I want to set the alpha value to 0 initially.

Quote: "Write a shader for render target quad... if you have time."


A shader can only be used for pasting the image though, and not to change it's data.. right?

Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 16th Dec 2013 01:54 Edited at: 16th Dec 2013 02:15
The best way to do this would be to create a pixel shader for an IK effect and apply it to the render target. The pixel shader will handle the alpha!

EDIT: Example Attached

"Get in the Van!" - Van B
ShellfishGames
13
Years of Service
User Offline
Joined: 6th Feb 2013
Location:
Posted: 16th Dec 2013 03:22
Thanks for your help! Doesn't really solve the problem though, the way I see it. I probably didn't make the purpose of the whole thing clear enough: I want to change the actual data of the image, and not the way it is rendered.

Ludum Dare is now over and my game uploaded - I managed to fix the issue, somehow. I don't know why it works now, but as it turned out repeating the operations I already had implemented several times resulted in the desired behaviour.

In case anybody is interested in what exactly I did, here's a screenshot:



I use render targets for the text rendering. At first I print the text to a render target, then I use a sprite which uses this render target as source image to be able to draw the text into the level with any scale, coloring and rotation.

The level is actually 2D, I use a kind of displacement mapping to achieve the 3D effect. So the text sprites are simply drawn to another render target, which represents the whole ground. And that's basically it.

Rudolpho
20
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 16th Dec 2013 10:11
If it is an actual render target, just change the backdrop colour of the camera rendering it - setting it to 0x00000000 will indeed clear the alpha channel as well, provided you have ensured that the image actually has an alpha channel.
I don't know how Image Kit works though, so maybe this wouldn't be applicable.

Anyway, looks pretty nice


"Why do programmers get Halloween and Christmas mixed up?"
Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 16th Dec 2013 13:06 Edited at: 16th Dec 2013 13:08
Ahhh now I get what you were doing!

Damn, it's simple really.
1. You set all drawing commands to the render target
2. CLS 0 to clear it
3. Draw text - That's it!

Example:


Good to see you achieved what you wanted and it's looking good

"Get in the Van!" - Van B

Login to post a reply

Server time is: 2026-07-06 10:36:43
Your offset time is: 2026-07-06 10:36:43