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 / Shader - rotating images from an objects zenith

Author
Message
Daryn Alsup
18
Years of Service
User Offline
Joined: 5th Jul 2008
Location: In your head... dun dun DUN!!!!!!!!
Posted: 1st Apr 2011 20:28
Hey there... I need some simple command help with Dark Shader at the moment. I'm trying to rotate (not swirl... but whole rotation) images. I've lerp'ed them so that the black portions of them are removed and the background image is seen instead. I need the objects zenith (say the center of a plain/plane) to be the center of rotation. How would I simulate the object rotating but in actuality only rotate the texture?

Jack and Jill went up a hill to fetch a pale of water... but Jill got tired of his s#%& so she shot him.
pictionaryjr
17
Years of Service
User Offline
Joined: 12th Mar 2009
Location:
Posted: 1st Apr 2011 22:05
could rotate the texture in a memblock like so. this is a function made by latch for dark basic classic, i'm not sure if it will work in dark basic pro. when you do the matting where it resizes the image to fit the whole rotated image, you might want to calculate a true size, by the cornders, that way you don't have a nasty random black area.




Daryn Alsup
18
Years of Service
User Offline
Joined: 5th Jul 2008
Location: In your head... dun dun DUN!!!!!!!!
Posted: 1st Apr 2011 23:07
Well this is good, very good - but I actually need to do this in the shader. So if anyone (GG!!!!!!) lol knows enough to tell me whether it can be done and can explain I would be forever grateful.

Jack and Jill went up a hill to fetch a pale of water... but Jill got tired of his s#%& so she shot him.
Duke E
17
Years of Service
User Offline
Joined: 10th Mar 2009
Location:
Posted: 4th Apr 2011 13:24
Here is a implementation i made when making my first particle system (I use pointsprites now though so the rotation has to be done half and half in the PS/VS, not any problem here though as we assume a fully UV mapped object).

It rotates the texture in the VS. The shader code is somewhat documented.

Best uses are for planes and uniformly UV mapped objects. The "seconds" variable in the shader can be set as a standard DBPro shader injection variable if you want to provide your own timings.

Also note the 45 degree compensation, it is necessary to shrink the texture or else the edges will be drawn "cut" off (the demo program however expands the texture). Also this means any non full alpha edge pixels will bleed.

Regards
Duke
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 4th Apr 2011 22:48
Quote: "So if anyone (GG!!!!!!) lol knows enough to tell me whether it can be done and can explain I would be forever grateful."


Duke E has beaten me to it.

Very nice demo.

Login to post a reply

Server time is: 2026-07-11 14:56:26
Your offset time is: 2026-07-11 14:56:26