Gamestudio Links
Zorro Links
Newest Posts
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Trading Journey
by 7th_zorro. 04/27/24 04:42
Help with plotting multiple ZigZag
by M_D. 04/26/24 20:03
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
M1 Oversampling
by jcl. 04/26/24 11:12
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
MT5 bridge not working on MT5 v. 5 build 4160
by EternallyCurious. 04/25/24 20:49
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (Akow, AndrewAMD, Quad), 733 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
pan/roll uv-map/texture via shader? #173595
12/18/07 14:08
12/18/07 14:08
Joined: Jun 2004
Posts: 655
to your left
BoH_Havoc Offline OP
User
BoH_Havoc  Offline OP
User

Joined: Jun 2004
Posts: 655
to your left
Hi,
i was wondering if its possible to pan or tilt an uv-map/texture via shader. I already had a look through the internet but couldn't find a solution. I'd say it should be possible, but i can't think of a way to do it right now.

Any ideas?


Shade-C EVO Lite-C Shader Framework
Re: pan/roll uv-map/texture via shader? [Re: BoH_Havoc] #173596
12/18/07 18:48
12/18/07 18:48
Joined: Oct 2005
Posts: 4,771
Bay City, MI
lostclimate Offline
Expert
lostclimate  Offline
Expert

Joined: Oct 2005
Posts: 4,771
Bay City, MI
well what acutally you'd have to do is do the inverse transformation to the actual map on the texture as far as how to do it, there is some trig involved, but it shouldnt be too hard.

Re: pan/roll uv-map/texture via shader? [Re: lostclimate] #173597
12/18/07 20:41
12/18/07 20:41
Joined: Oct 2002
Posts: 8,939
planet.earth
ello Offline
Senior Expert
ello  Offline
Senior Expert

Joined: Oct 2002
Posts: 8,939
planet.earth
Code:

float4x4 rMat = {
1,a,0,0,
b,1,0,0,
0,0,0,0,
0,0,0,0
};
Out.Tex = mul(inTex,rMat);


where a rotates quite obvious and b does something, too.. i still dont really know how matrixes work, but this should help you

btw, the two "1" entries are tiling factors


www.earthcontrol.de
quoted: We want to maintain a clean, decent, American family suited forum look... which means you may post zombies or chainsaw massacres, but no erotic.
Re: pan/roll uv-map/texture via shader? [Re: ello] #173598
12/19/07 02:20
12/19/07 02:20
Joined: Jun 2004
Posts: 655
to your left
BoH_Havoc Offline OP
User
BoH_Havoc  Offline OP
User

Joined: Jun 2004
Posts: 655
to your left
Duh! I didn't even think about using a matrix. Thanks for the hint, that should do the trick


Shade-C EVO Lite-C Shader Framework
Re: pan/roll uv-map/texture via shader? [Re: BoH_Havoc] #173599
12/19/07 04:13
12/19/07 04:13
Joined: Feb 2003
Posts: 264
Michigan,USA
alienheretic Offline
Member
alienheretic  Offline
Member

Joined: Feb 2003
Posts: 264
Michigan,USA
if anyone succedes with this please fill me in with an example

Re: pan/roll uv-map/texture via shader? [Re: alienheretic] #173600
12/19/07 07:21
12/19/07 07:21
Joined: Oct 2002
Posts: 8,939
planet.earth
ello Offline
Senior Expert
ello  Offline
Senior Expert

Joined: Oct 2002
Posts: 8,939
planet.earth
yes, if you get it done please give feedback, since i tried for the past weeks and didnt a reliable working version

Re: pan/roll uv-map/texture via shader? [Re: ello] #173601
12/19/07 07:35
12/19/07 07:35
Joined: May 2002
Posts: 7,441
ventilator Offline
Senior Expert
ventilator  Offline
Senior Expert

Joined: May 2002
Posts: 7,441
i think just tinkering with the values won't really get you anywhere. you have to create a correct rotation matrix with sin and cos like that:

if you also want to scale or translate then multiply this rotation matrix with a scale or translation matrix before you use it to transform the uvs.

Re: pan/roll uv-map/texture via shader? [Re: ventilator] #173602
12/19/07 07:54
12/19/07 07:54
Joined: Oct 2002
Posts: 8,939
planet.earth
ello Offline
Senior Expert
ello  Offline
Senior Expert

Joined: Oct 2002
Posts: 8,939
planet.earth
thank you very much!

still one proble remains:
Code:

float a = radians(45);
float3x3 matRotate =
{
cos(a) , -sin(a) , 0,
sin(a) , cos(a) , 0,
0 , 0 , 1
};
Out.tex = mul(In.tex,matRotate);



this works perfect, but if i youse entSkill41 instead of 45 and pass it from the entities action via my.skill41 = floatv(45); it does not work correct.. any idea whats wrong?

Last edited by ello; 12/19/07 08:58.
Re: pan/roll uv-map/texture via shader? [Re: ello] #173603
12/19/07 10:57
12/19/07 10:57
Joined: May 2002
Posts: 7,441
ventilator Offline
Senior Expert
ventilator  Offline
Senior Expert

Joined: May 2002
Posts: 7,441
i don't know whats wrong with entskill but i guess it would make sense to calculate sin(a) and cos(a) outside of the shader since the angle stays the same for every vertex anyway.

Re: pan/roll uv-map/texture via shader? [Re: ventilator] #173604
12/19/07 11:25
12/19/07 11:25
Joined: Oct 2002
Posts: 8,939
planet.earth
ello Offline
Senior Expert
ello  Offline
Senior Expert

Joined: Oct 2002
Posts: 8,939
planet.earth
this does not work, too. to bad i cant read out values as text in the shader ... there seems to be some conversion when passing the skill. because the texture gets rotated when passing sin(0) or (90) and so on, and you have to scale the values in the shader by 0.001 , and there are other strange things happening... hmm

ok, got it nearly working:
Code:

float s=entSkill41;
float c=entSkill42;
float3x3 matRotate =
{
c , -s , 0,
s , c , 0,
0 , 0 , 1
};
In.tex += float2(-0.5,-0.5);
Out.tex = mul(In.tex,0.001*matRotate);


where

my.skill41 = sinv(my.pan);
my.skill42 = cosv(my.pan);
but still when the pan is 0 the rotaion matrix produces a slightly rotation, what could that be??



Last edited by ello; 12/19/07 11:34.
Page 1 of 2 1 2

Moderated by  Blink, Hummel, Superku 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1