Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, Ayumi), 1,405 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Detail Maps - Version 2 - Try adding one to ps1.1 #27542
05/17/04 09:27
05/17/04 09:27
Joined: Dec 2003
Posts: 1,097
Maryland, USA
Steempipe Offline OP
Serious User
Steempipe  Offline OP
Serious User

Joined: Dec 2003
Posts: 1,097
Maryland, USA
Disclaimer: This seemed to work on mine Ha ha.

Decided I wanted to add some noise to the "sterile" looking terrain textures. However, I did not want to lose (1) of the (3) textures for the terrain.
So, made a BW detailmap, put it in the alpha channel of one of the textures.

It takes some experimenting... but what doesn't?

Here is a pic before and after. I made it dark contrast for example.






Code:
 //-----------------------------------------------------
// Ventilator's Terrain Multitexturing Shader
// Pixelshader 1.1-1.3 & Vertexshader 1.0
// Adding a "detailmap" into the alpha channel of a tex

// Modified to add a little detail noise to the rendered textures

// Experiment with the contrast of the "detailmap".
// Adding another MOV to the ps is probably not great, but.....

bmap alphamap = <four.tga>; // Blending map in alpha and blue channels
bmap detailtex = <shaledetail2.tga>; // Tileable tex in RGB and a BW detailmap in Alpha



material mat_terrain_multitexture
{



Skin1 = alphamap;
Skin2 = detailtex;


effect=
"


texture entSkin1;
texture entSkin2;
texture mtlSkin1;
texture mtlSkin2;

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]=<mtlSkin2>;
texture[2]=<entSkin2>;
texture[3]=<mtlSkin1>;

alphablendenable=false;


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,20.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 // Shale tex plus detailmap in alpha
tex t2 // Dirt
tex t3 // blending map

mov r1,t0

lrp r0.rgb,t3.a,r1,t1
+mov r0.a,c0


mov r1.a,t3.b

lrp r0.rgb,r1.a,r0,t2
+mov r0.a,c0

mov t1, t1.a //<<<< Move detail in alpha to rgb
add r0.rgb,r0,t1_bx2 //<<<< Apply "detailmap"

mul r0.rgb,r0,v0

};
}


}


";

}




starter mat_terrain_multitexture_init

{
bmap_to_mipmap(mat_terrain_multitexture.skin1);
bmap_to_mipmap(mat_terrain_multitexture.skin2);

}



action Shader_Terrain
{

my.skill41=float(20); //set the U tiling size of Tex 0
my.skill42=float(20); //set the V tiling size of Tex 0
my.skill43=float(30); //Set the U tiling size of Tex 1
my.skill44=float(30); //Set the V tiling size of Tex 1

///////////////////////////////////////
// Assign a suncolor in Map Properties
// for ex. 255, 255, 128
//

//////////////////////////////////
// Adjust these (4) values to your liking
// whether including Pass P1 or not
//

sun_angle.pan=86;
sun_angle.tilt=20;

my.ambient=40;
my.albedo=40;


my.unlit=on;
my.bright=off;

my.transparent = off;

my.material = mat_terrain_multitexture;

}



Re: Detail Maps - Version 2 - Try adding one to ps1.1 [Re: Steempipe] #27543
05/17/04 12:21
05/17/04 12:21
Joined: Jul 2002
Posts: 5,181
Austria
Blattsalat Offline
Senior Expert
Blattsalat  Offline
Senior Expert

Joined: Jul 2002
Posts: 5,181
Austria
You have officialy gained the "master of all shadings and stuff" ranking in my eyes

trying this technical wonder asap

Ever concidered selling a "shader box" (also the other shader gurus here like ello, venti aso..)?


Re: Detail Maps - Version 2 - Try adding one to ps1.1 [Re: Blattsalat] #27544
05/17/04 22:12
05/17/04 22:12
Joined: Oct 2003
Posts: 23
Shurik Offline
Newbie
Shurik  Offline
Newbie

Joined: Oct 2003
Posts: 23
error:
too many parameters detailmap

Re: Detail Maps - Version 2 - Try adding one to ps1.1 [Re: Shurik] #27545
05/17/04 23:01
05/17/04 23:01
Joined: Jul 2002
Posts: 5,181
Austria
Blattsalat Offline
Senior Expert
Blattsalat  Offline
Senior Expert

Joined: Jul 2002
Posts: 5,181
Austria
nope, works like a charm on my system (winxp, radeon9800pro).

again: thanks a lot!

Re: Detail Maps - Version 2 - Try adding one to ps1.1 [Re: Blattsalat] #27546
05/18/04 06:29
05/18/04 06:29
Joined: Jul 2002
Posts: 2,813
U.S.
Nadester Offline

Expert
Nadester  Offline

Expert

Joined: Jul 2002
Posts: 2,813
U.S.
Looks really neat. If you are interested, I did this simpler effect for Marco Gubert,(someone gave me a hand with it) which can look basically like a carbon copy of the A5/A6 detail mapping. Maybe you can find it somewhat useful...

Code:
/////////////////////////////////////////////
// Give your Terrain 2 Skins
// Skin 1 - The texture (non-tileable)
// Skin 2 - The detail map (tileable)
//
///////////////////////////////////////////////////

function mtl_terraintex_init(){

// Adjust the texture transform to do some tiling of the textures
mtl.matrix11 = float(8); // default u scale
mtl.matrix22 = float(8); // default v scale
}

material mat_terrain_detail
{
event = mtl_terraintex_init;

effect = "

matrix matMtl;

texture entSkin1;
texture entSkin2;

technique t0
{
pass p0
{
Texture[0] = <entSkin1>;
Texture[1] = <entSkin2>;

TextureTransformFlags[1] = Count2;
TextureTransform[1] = <matMtl>;
TexCoordIndex[1] = 1;

ColorOp[0] = Modulate2x;
ColorArg1[0] = Texture;
ColorArg2[0] = Diffuse;

ColorOp[1] = AddSigned;
ColorArg1[1] = Texture;
ColorArg2[1] = Current;

ColorOp[2] = Disable;
AlphaOp[0] = Disable;
}
}";
}


//////////////////////////////
//WED action for Terrain:
//////////////////////////////

action ffp_terr_detail
{
my.transparent=off;
my.material = mat_terrain_detail;
}



cu


--Eric
Re: Detail Maps - Version 2 - Try adding one to ps1.1 [Re: Nadester] #27547
05/18/04 10:27
05/18/04 10:27
Joined: Dec 2003
Posts: 1,097
Maryland, USA
Steempipe Offline OP
Serious User
Steempipe  Offline OP
Serious User

Joined: Dec 2003
Posts: 1,097
Maryland, USA
Thanks, Blattsalat.

@Nadester: I am going to run yours and compare the difference to my version since we use different args. Cool, thanks for sharing.

@Shurik: Can you post your video card details and such??

Re: Detail Maps - Version 2 - Try adding one to ps1.1 [Re: Steempipe] #27548
05/18/04 18:22
05/18/04 18:22
Joined: Oct 2003
Posts: 23
Shurik Offline
Newbie
Shurik  Offline
Newbie

Joined: Oct 2003
Posts: 23
GeForce 4400 128mb

Re: Detail Maps - Version 2 - Try adding one to ps1.1 [Re: Shurik] #27549
05/19/04 03:16
05/19/04 03:16
Joined: Dec 2003
Posts: 1,097
Maryland, USA
Steempipe Offline OP
Serious User
Steempipe  Offline OP
Serious User

Joined: Dec 2003
Posts: 1,097
Maryland, USA
Hmm... I do not recongnize the card, but that means nothing since I know little of those things.

You should try using the DLL that qwerty823 posted to spit out the caps of your card. Then at least you know what ps/vs version you support.

But..... do you get this error in the dialog when the engine starts up or is it a D3D error after level loads??

Make sure you have not accidentally removed/added a bracket or semi-colon. Those are the only times I seem to get a "too many parameters in effect" type of message.

If it drives you nuts looking, PM me with an email address and i'll send you a WDL file.

Re: Detail Maps - Version 2 - Try adding one to ps1.1 [Re: Steempipe] #27550
05/21/04 21:40
05/21/04 21:40
Joined: May 2003
Posts: 44
Romania
master lucas Offline
Newbie
master lucas  Offline
Newbie

Joined: May 2003
Posts: 44
Romania
Steempipe, same problem with MX 440.

The problem indicated by the compiler lies at the ";. Maybe not recognized by my video card?


Pixelrage Member Team
Re: Detail Maps - Version 2 - Try adding one to ps1.1 [Re: master lucas] #27551
05/21/04 22:20
05/21/04 22:20
Joined: Mar 2004
Posts: 102
T
Taros Offline
Member
Taros  Offline
Member
T

Joined: Mar 2004
Posts: 102
Master Lucas your card doesn't support shaders so it doesn't work.

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