Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (Akow), 1,403 guests, and 9 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19055 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Shadowmap für Terrainmultitexturingshader?!? #27425
05/15/04 18:35
05/15/04 18:35
Joined: Jan 2002
Posts: 750
Deutschland/Baden-Würtemberg
Stefan Offline OP
User
Stefan  Offline OP
User

Joined: Jan 2002
Posts: 750
Deutschland/Baden-Würtemberg
Hi,
ich benutze den untenstehenden Shader für mein Terrain. Jetzt versuche ich schon seit mehreren Tagen verzweifelt, ein Shadowmap einzufügen. Das heißt, eine TGA-file mit Alphakanal als oberste Ebene, die nicht gekachelt wird, sondern nur einmal über das ganze Terrain gelegt wird, um statische Schatten von, zB. Bäumen und Gebäuden darzustellen. Ich wär sehr froh, wenn mir jemand helfen könnte.

Stefan

Code:
 

bmap alphamap = <blendmap3.tga>;

material mat_terrain_multitexture
{

Skin1 = alphamap;


effect=
"

texture entSkin1;//grass
texture entSkin2;//dreck
texture entSkin3;//stein
texture mtlSkin1;//alphamap

matrix matWorldViewProj;
matrix matWorld;
matrix matWorldView;

vector vecSunDir;
vector vecDiffuse;
vector vecAmbient;
vector vecLight;
vector vecFog;
vector vecSkill41;





technique multitextureps11
{
pass p0
{
texture[0]=<entSkin1>;
texture[1]=<entSkin2>;
texture[2]=<entSkin3>;
texture[3]=<mtlSkin1>;


magFilter[0]=linear;
minFilter[0]=linear;
mipFilter[0]=linear;

magFilter[1]=linear;
minFilter[1]=linear;
mipFilter[1]=linear;

magFilter[2]=linear;
minFilter[2]=linear;
mipFilter[2]=linear;

magFilter[3]=linear;
minFilter[3]=linear;
mipFilter[3]=linear;



zWriteEnable=true;

vertexShaderConstant[0]=<matWorldViewProj>;
vertexShaderConstant[4]=<matWorld>;
vertexShaderConstant[8]=<matWorldView>;

vertexShaderConstant[16]=<vecSunDir>;
vertexShaderConstant[17]=<vecDiffuse>;
vertexShaderConstant[18]=<vecAmbient>;
vertexShaderConstant[19]=<vecLight>;
vertexShaderConstant[20]=<vecFog>;

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

vertexShaderConstant[95]=(0.0f,0.0f,0.0f,0.0f);

vertexShader=
decl
{
stream 0;
float v0[3]; //position
float v3[3]; //normal
float v7[2]; //uv
}
asm
{
vs.1.0
m4x4 oPos,v0,c0 // transform position to clip space

mul oT0.xy,v7.xy,c64.xy // output scaled uvs - stage 0
mul oT1.xy,v7.xy,c64.zw
mul oT2.xy,v7.xy,c65.xy // output scaled uvs - stage 1
mov oT3.xy,v7.xy // output uvs - stage 2

m3x3 r0,v3,c4 // transform normal to world space
dp3 r0.w,r0,r0 // renormalize it
rsq r0.w,r0.w
mul r0,r0,r0.w

dp3 r0,r0,-c16 // normal.light -> lighting constant
mul r0.xyz,r0,c17 // modulate against material diffuse color
add oD0.xyz,r0,c19 // add environment light

mov r1.w,c20.w // r1.w=1
dp4 r0,v0,c10 // distance to camera position
add r0,r0,-c20.x // distance-fog_start
mad r0.x,-r0.x,c20.z,r1.w // 1-(distance-fog_start)*(1/(fog_end-fog_start))
max oFog.x,r0.x,c95.w // clamp with custom max value
};

pixelShader=
asm
{
ps.1.1
def c0,1,1,1,1
tex t0 // grass
tex t1 // sand
tex t2 // cracked ground
tex t3 // blending map

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

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

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

};
}




}

action Shader_Terrain
{
my.skill41=float(40); //set the U tiling size of Tex 0
my.skill42=float(40); //set the V tiling size of Tex 0
my.skill43=float(10); //Set the U tiling size of Tex 1
my.skill44=float(10); //Set the V tiling size of Tex 1

my.flare = off;
my.transparent = off;
my.albedo = 0;
my.material = mat_terrain_multitexture;
}




Re: Shadowmap für Terrainmultitexturingshader?!? [Re: Stefan] #27426
05/16/04 00:41
05/16/04 00:41
Joined: Dec 2003
Posts: 1,097
Maryland, USA
Steempipe Offline
Serious User
Steempipe  Offline
Serious User

Joined: Dec 2003
Posts: 1,097
Maryland, USA
If someone could give a brief translation, if needed:

I have had little luck with doing that in a pixelshader v1.1. However, I could give you code to do it in the fixed-function pipe.
The code has multi-pass, using 3 textures, 2 blending maps, and 1 shadowmap.

Here's a bad example:


Re: Shadowmap für Terrainmultitexturingshader?!? [Re: Steempipe] #27427
05/16/04 01:33
05/16/04 01:33
Joined: Jan 2002
Posts: 750
Deutschland/Baden-Würtemberg
Stefan Offline OP
User
Stefan  Offline OP
User

Joined: Jan 2002
Posts: 750
Deutschland/Baden-Würtemberg
It would be really nice if you could send me the code stefan-elitz@web.de.

Re: Shadowmap für Terrainmultitexturingshader?!? [Re: Stefan] #27428
05/16/04 13:14
05/16/04 13:14
Joined: Dec 2003
Posts: 1,097
Maryland, USA
Steempipe Offline
Serious User
Steempipe  Offline
Serious User

Joined: Dec 2003
Posts: 1,097
Maryland, USA
I sent you the WDL that is in this thread:
web page

Re: Shadowmap für Terrainmultitexturingshader?!? [Re: Stefan] #27429
05/16/04 18:07
05/16/04 18:07
Joined: Jan 2002
Posts: 750
Deutschland/Baden-Würtemberg
Stefan Offline OP
User
Stefan  Offline OP
User

Joined: Jan 2002
Posts: 750
Deutschland/Baden-Würtemberg
Thanks, you really helped me!!!

Stefan


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