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 Studio Chat / Issue with custom shader & SetViewPortX()

Author
Message
Richard Stevens
4
Years of Service
User Offline
Joined: 14th Jan 2020
Location:
Posted: 20th Nov 2020 14:24
I'm having a bit of an issue that I've minimised down to the least possible code & was hoping some kind soul could help.

I am using a custom shader (It was from a post by Bengismo on here) that I'm using to blit fast 2d quads.

This works great, but I seem to run into a problem when I move setviewportx(). As soon as it hits 155 my shader seems to stop working. The curious bit is, it seems to be able to go negative without affecting it.

Would appreciate it if anyone could suggest any possible reasons.

Attachments

Login to view attachments
Bengismo
6
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 20th Nov 2020 16:58 Edited at: 20th Nov 2020 17:05
Its because the sprite that is being drawn is not actually on the screen when you move the view offset that far over (its position is 0,0), so it gets culled by AGK. Culled = It never gets drawn since AppGameKit thinks you cant see it, so no point in drawing it.

AGK doesnt really know the sprite is getting repositioned by the shader

You can fix that by moving the sprite into the viewable area....something like this



.....or just make the sprite very very huge

SetSpriteSize(1,5000,5000) <- this will still be seen until you go over to view offset of about 5155). This wont change the size of the sprite at all....It will still be drawn at the right size.

.....or, make the sprite a 3d object and turn off object screen space culling for it.


EDIT:
Lastly, the coordinates you were using for the corners was incorrect (hence why a triangle was being drawn instead of a quad. I fixed that in the example above.
Richard Stevens
4
Years of Service
User Offline
Joined: 14th Jan 2020
Location:
Posted: 20th Nov 2020 20:36 Edited at: 20th Nov 2020 20:38
That's awesome, many thanks. Sticking the setspriteposition() in did it perfectly. My latest AAA title is that one step close ... it's the wobbly floor!

blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 20th Nov 2020 20:43 Edited at: 20th Nov 2020 20:43
That is looking nice!! Great work. A friend and i did that exact game a while back
Richard Stevens
4
Years of Service
User Offline
Joined: 14th Jan 2020
Location:
Posted: 20th Nov 2020 20:55 Edited at: 20th Nov 2020 20:57
I can't take the credit for the looks I'm afraid - I subscribed to craftpix.net, they do a ton of licensed graphics for a small annual fee, great value.

I'm loving agk... it's like blitz basic used to be but with more horsepower than we could even dream of back then!

Your looks super-slick - do you do your own graphics?
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 20th Nov 2020 20:56
In that example i did the graphics and my good friend micky4fun did the code

Login to post a reply

Server time is: 2024-03-28 17:40:56
Your offset time is: 2024-03-28 17:40:56