Gamestudio Links
Zorro Links
Newest Posts
Blobsculptor tools and objects download here
by NeoDumont. 03/28/24 03:01
Issue with Multi-Core WFO Training
by aliswee. 03/24/24 20:20
Why Zorro supports up to 72 cores?
by Edgar_Herrera. 03/23/24 21:41
Zorro Trader GPT
by TipmyPip. 03/06/24 09:27
VSCode instead of SED
by 3run. 03/01/24 19:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (degenerate_762, Nymphodora), 1,012 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
sakolin, rajesh7827, juergen_wue, NITRO_FOREVER, jack0roses
19043 Registered Users
Previous Thread
Next Thread
Print Thread
Rating: 4
Page 6 of 11 1 2 4 5 6 7 8 10 11
Re: terrain multitexturing shader [Re: Darkstorm] #17345
01/30/04 00:40
01/30/04 00:40
Joined: May 2002
Posts: 7,441
ventilator Offline OP
Senior Expert
ventilator  Offline OP
Senior Expert

Joined: May 2002
Posts: 7,441
i don't mind the clutter i just could imagine that for an absolute shader beginner it's somewhat tricky to put together all the information of this puzzle!

i looked it up. the blue channel of the macro map could be used to control where the third texture should appear.

i will describe how to add it. what graphics card do you use? geforce3?

Re: terrain multitexturing shader [Re: ventilator] #17346
01/30/04 00:52
01/30/04 00:52
Joined: Jun 2001
Posts: 2,006
USA
Darkstorm Offline
Senior Expert
Darkstorm  Offline
Senior Expert

Joined: Jun 2001
Posts: 2,006
USA
Yep. GeForce3 Ti200. I really appreciate you doing this.

Re: terrain multitexturing shader [Re: Darkstorm] #17347
01/30/04 01:36
01/30/04 01:36
Joined: May 2002
Posts: 7,441
ventilator Offline OP
Senior Expert
ventilator  Offline OP
Senior Expert

Joined: May 2002
Posts: 7,441
the changes for the vertex shader:
Code:

texture entSkin1; // tiled texture 1
texture entSkin2; // tiled texture 2
texture entSkin3; // tiled texture 3
texture entSkin4; // !NEW! -> this is the macro map now! make sure you also assign it that way in med!

...

texture[0]=<entSkin1>;
texture[1]=<entSkin2>;
texture[2]=<entSkin3>;
texture[3]=<entSkin4>; // !NEW!

...

vertexShaderConstant[64]=<vecSkill41>; //(u_scale1, v_scale1, u_scale2, v_scale2)
vertexShaderConstant[65]=(10.0f,10.0f,0.0f,0.0f); // !NEW! -> (u_scale3, v_scale3, 0, 0)

...

mul oT0.xy,v7.xy,c64.xy // output scaled uvs - tiled texture 1
mul oT1.xy,v7.xy,c64.zw // output scaled uvs - tiled texture 2
mul oT2.xy,v7.xy,c65.xy // !NEW! output scaled uvs - tiled texture 3
mov oT3.xy,v7.xy // !NEW! output uvs - macro map



the pixelshader:
Code:

ps.1.1
def c0,1,1,1,1
tex t0 // sample colormap1
tex t1 // sample colormap2
tex t2 // sample colormap3
tex t3 // sample macromap

mov r1,t1
lrp r0.rgb,t3.a,t0,r1 // blend t0 with t1 depending on t3 alpha
+mov r0.a,c0

lrp r0.rgb,t3.b,r0,t2 // blend the result with t2 depending on t3 blue
+mov r0.a,c0

mul r0.rgb,r0,v0 // modulate with diffuse vertex lighting



the blue channel of the macro map defines where the third texture appears. i don't have the time to test it at the moment so probably you will have to experiment a little! i hope it works!

Re: terrain multitexturing shader [Re: ventilator] #17348
01/30/04 01:43
01/30/04 01:43
Joined: Jun 2001
Posts: 2,006
USA
Darkstorm Offline
Senior Expert
Darkstorm  Offline
Senior Expert

Joined: Jun 2001
Posts: 2,006
USA
Thanks. When you say the blue channel, do you mean that I use the blue channel of the RGB for the third texture? Meaning that the third textures "placement" will be independent from the alpha channel?

Re: terrain multitexturing shader [Re: Darkstorm] #17349
01/30/04 01:46
01/30/04 01:46
Joined: May 2002
Posts: 7,441
ventilator Offline OP
Senior Expert
ventilator  Offline OP
Senior Expert

Joined: May 2002
Posts: 7,441
yes! but because the red and green channel aren't used you simply could draw shades of black and white into all color channels...

Re: terrain multitexturing shader [Re: ventilator] #17350
01/30/04 01:50
01/30/04 01:50
Joined: Jun 2001
Posts: 2,006
USA
Darkstorm Offline
Senior Expert
Darkstorm  Offline
Senior Expert

Joined: Jun 2001
Posts: 2,006
USA
Yar! I'll give it a shot and post my results. I owe you a grog or something .

Re: terrain multitexturing shader [Re: Darkstorm] #17351
01/30/04 02:20
01/30/04 02:20
Joined: Jun 2001
Posts: 2,006
USA
Darkstorm Offline
Senior Expert
Darkstorm  Offline
Senior Expert

Joined: Jun 2001
Posts: 2,006
USA
I get the effect unsupported by hardware error. I'll keep playing but I think I'll just make it worse.

Code:
lrp r0.rgb,t3.b,r0,t2 // blend the result with t2 depending on t3 blue

+mov r0.a,c0



That bit is the culprit. Everything runs fine untill I add that.

Re: terrain multitexturing shader [Re: Darkstorm] #17352
01/30/04 02:44
01/30/04 02:44
Joined: May 2002
Posts: 7,441
ventilator Offline OP
Senior Expert
ventilator  Offline OP
Senior Expert

Joined: May 2002
Posts: 7,441
yes, the problem gets caused by invalid swizzling!

try to replace

lrp r0.rgb,t3.b,r0,t2 // blend the result with t2 depending on t3 blue
+mov r0.a,c0

with:

mov r1.a,t3.b
lrp r0.rgb,r1.a,r0,t2 // blend the result with t2 depending on t3 blue
+mov r0.a,c0

Quote:

The .b replicate functionality is available in ps.1.1 - ps.1.3 since the release of DirectX 8.1, but this swizzle is only valid together with an alpha write mask in the destination register of an instruction [...]




http://www.shaderx.com/direct3d.net/tutorials/shader/shader3.html -> swizzling/using selectors

Re: terrain multitexturing shader [Re: ventilator] #17353
01/30/04 03:17
01/30/04 03:17
Joined: Jun 2001
Posts: 2,006
USA
Darkstorm Offline
Senior Expert
Darkstorm  Offline
Senior Expert

Joined: Jun 2001
Posts: 2,006
USA
Beautiful!!!! That change works perfectly. So, go ahead and fax me that paperwork for my first born son and show me where to sign!

Re: terrain multitexturing shader [Re: Darkstorm] #17354
01/30/04 04:15
01/30/04 04:15
Joined: Jun 2001
Posts: 2,006
USA
Darkstorm Offline
Senior Expert
Darkstorm  Offline
Senior Expert

Joined: Jun 2001
Posts: 2,006
USA
Here's a question. I will only need three textures on a few on the HMPs. Since this seems to slow the FPS quite a bit, is it possible to have an if statement that checks to see how many skins the HMP has and, depending on that number, assigns the approproate shader to the terrain? Seems like it should be but I thought that I would ask the master coder before I tried hacking out some code .

Page 6 of 11 1 2 4 5 6 7 8 10 11

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