|
Re: terrain multitexturing shader
[Re: Darkstorm]
#17345
01/30/04 00:40
01/30/04 00:40
|
Joined: May 2002
Posts: 7,441
ventilator
OP
Senior Expert
|
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: Darkstorm]
#17347
01/30/04 01:36
01/30/04 01:36
|
Joined: May 2002
Posts: 7,441
ventilator
OP
Senior Expert
|
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: Darkstorm]
#17351
01/30/04 02:20
01/30/04 02:20
|
Joined: Jun 2001
Posts: 2,006 USA
Darkstorm
Senior Expert
|
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
OP
Senior Expert
|
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
|
|
|
|