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.

AppGameKit Classic Chat / Render to image issues and strategies on usage

Author
Message
Naphier
14
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 7th Nov 2014 20:47
After a bit of struggling with render to image I still can't get it to work for full screen non power of 2 images. Even when doing power of 2 images larger than the screen it seems there are strange culling issues.

MattyH proposes quads as a solution. I'm not sure how this would work and would love to see an example.

Digital Awakening has a great example here of using it as a full screen image for blurring effects.
But I'd like to know more:
How can we do full screen blurring and maintain resolution?
How can we do full screen blurring and have a non-blurred background (or any background other than black)?


I tried using a render image that is larger than the screen and I end up with an image that is much smaller than the screen:


What it should look like:




What it looks like with a 2048x2048 render image size (screen size is 664x1000)


So how do we do this to get the entire screen when the screen is not power of 2 sized?

Ched80
14
Years of Service
User Offline
Joined: 18th Sep 2010
Location: Peterborough, UK
Posted: 7th Nov 2014 21:02
Posting to stay up to date with this one.

Good idea Sean.

Take a look at my dynamic shadows thread. I used multiple render to image events and the quad.

Naphier
14
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 7th Nov 2014 21:12
Ah yes, I see
http://forum.thegamecreators.com/?m=forum_view&t=212525&b=41
I didn't think you were using render to image for that, but I didn't think about it much at all, makes sense that you are.
So just from a cursory glance it looks like this allows a render of separate layers, which is awesome. Does it also solve non-power of 2 screen size issues?

Ched80
14
Years of Service
User Offline
Joined: 18th Sep 2010
Location: Peterborough, UK
Posted: 7th Nov 2014 21:37
Originally it was built around a screen of 1024 x 1024, but I've since updated it to 1280 x 720 with no problems. Even with a power of 2 image, I had to use a 512 x 1 render image with the Quad to produce the shadow map.

CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 7th Nov 2014 21:47
Check the bloom shader example too. That's doing full-screen quad on 1024x768.

Matty H
16
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 7th Nov 2014 22:01 Edited at: 7th Nov 2014 22:03
Drawing to screen fast using quad object and pixel shader. This code allows you to have a background image also.

It's tier 2 so you will need to convert if you are using tier 1.

You will also need to provide backdrop image and a brush image to draw with.

Code:


Shader:


This is tested on an android tablet and the images you draw to the quad never get stretched, they are always in proportion regardless of what the render image size is. The render image size should always be power of two for some devices.

Digital Awakening
AGK Developer
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 7th Nov 2014 23:10
Naphier:
Just out of curiosity, does my code fill the screen on your system? From what I can tell, if you have a tall screen (like a phone) you need to create a tall render-image, like 512x1024. Or it won't work. Also don't do it larger than that. Also make sure that you step by step use the same commands I do for rendering and updating the screen.

Naphier
14
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 7th Nov 2014 23:29
@DA - it does and I just noticed the window size on yours is actually 1024x768 (I thought it was 1024x512).
I'm not using virtual resolution in mine, so it could be part of the problem. But it should work the same.
My code is your code without the virtual resolution and every size I've tried for the render image ends up culled unless I set the screen size to some power of 2 and match the render image size (max 1024).

Here it is if anyone wants to take a look to see what I'm doing wrong.



Paul Johnston
TGC Developer
22
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 9th Nov 2014 21:19
SetRenderToImage has strange interactions with the scissor command that can cause cropping. For now I recommend using SetScissor(0,0,0,0) to turn it off.
Hockeykid
DBPro Tool Maker
17
Years of Service
User Offline
Joined: 26th Sep 2007
Location:
Posted: 9th Nov 2014 21:47
Quote: "Here it is if anyone wants to take a look to see what I'm doing wrong."


Paul's suggestion seemed to help. Using SetScissor(0, 0, 0, 0) fixed it.




Sean

Naphier
14
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 9th Nov 2014 22:33
That did it!
No just to get my background image to show up and overlay sprites to not be rendered in the blur.
This example would have been much better with this blurring

BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 9th Nov 2014 22:44
Watching with interest...last time I used this technique was in DBPro about 3 years ago. The potential is huge...as we have already seen.

Quidquid latine dictum sit, altum sonatur
Blendman
10
Years of Service
User Offline
Joined: 17th Feb 2014
Location: Arkeos
Posted: 15th Nov 2014 10:08 Edited at: 15th Nov 2014 10:11
Hi

I have just a question : is there a way to render a background (with alpha= 255) with that method?

Because, if I add a sprite BG (for example a Grey Plane), I have no more the blur effect (of Digital awakening).

Example With the code of Naphier, I have no more the blur effect :


http://www.dracaena-studio.com
Digital Awakening
AGK Developer
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 16th Nov 2014 15:07
Blendman:
If you draw the background first at alpha 255 and then lower the alpha after the first frame, you should get the trails. You can't draw something with 255 alpha over the screen, that would instantly overwrite everything. If you don't draw it at 255 alpha for 1 frame it will fade in instead.

Login to post a reply

Server time is: 2024-11-25 11:38:35
Your offset time is: 2024-11-25 11:38:35