need help with terrain multitexturing

Posted By: salem

need help with terrain multitexturing - 01/28/04 08:03

if anyone could help me please, i have absolutely nooooooooo idea how to get ventilator's shader script to work...

ive read through several of the posts on it and have done the following thus far:

created a 512 x 512 heightmap
put it in med
created 2 diff 256 x 256 tga's and set them as skins for the terrain
created 1 512 x 512 32 bit tga with alpha mapping and set it as the third skin in med...

when i run the level all i see is the third, alpha map texture that i applied...

at this point i am totally clueless- this is the first time ive ever even touched a shader sooo...

if im doing this completely wrong?? could someone please direct me in the correct procedure...im using the source code given here:

http://www.inode.at/baop/wiki/index.php?TerrainMultitexturing

any and all help will be greatly appreciated!!!
Posted By: Darkstorm

Re: need help with terrain multitexturing - 01/28/04 08:15

I'm just going to start spouting random ideas that you likely have thought of already. Did you include the wdl script with the action and shader in your level's wdl script? Did you assign the "terrain" action to your terrain?

We'll start simple and go from there .
Posted By: salem

Re: need help with terrain multitexturing - 01/28/04 08:21

yes, i applied the terrain action to the terrain and did an include<>; for the separate wdl for the shader in my main script
Posted By: Darkstorm

Re: need help with terrain multitexturing - 01/28/04 08:35

Man, I was hoping that was it because I know next to nothing when it come to shaders (and most other things come to think of it). Okay, another one. When you added the third skin with the alpha channel, did you uncheck the box that asks about adapting skin points?
Posted By: salem

Re: need help with terrain multitexturing - 01/28/04 08:40

it doesn't allow for me to uncheck the box...?
Posted By: Darkstorm

Re: need help with terrain multitexturing - 01/28/04 08:44

Most likely due to the fact that that skin is the same size as your hmp (512x512). That should be okay. Hmmm. Have to think about this a bit. If you a place where you could upload the level I could take a look. I'm more of a "hands on" type of person.
Posted By: salem

Re: need help with terrain multitexturing - 01/28/04 08:48

okay i will make a quick and dirty level for u to play with as the one im working on is currently my big project, check back in about 10 min
Posted By: salem

Re: need help with terrain multitexturing - 01/28/04 09:00

heres the demo- just a camera and terrain, thx!
Posted By: Darkstorm

Re: need help with terrain multitexturing - 01/28/04 09:09

From looking at your hmp, it looks like you put the skin with the alpha channel first instead of third. If so, that needs to be changed. Also, when I pasted the code that I'm using over yours it worked. Here is what I'm using:

Code:

material mat_terrain_multitexture
{
effect=
"
texture entSkin1;
texture entSkin2;
texture entSkin3;

matrix matWorldViewProj;
matrix matWorld;
matrix matWorldView;

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

technique multitexture
{
pass p
{
texture[0]=<entSkin1>;
texture[1]=<entSkin2>;
texture[2]=<entSkin3>;

magFilter[2]=linear;
minFilter[2]=linear;
mipFilter[2]=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[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.1
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 // output scaled uvs - stage 1
mov oT2.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,0,0,0,1
tex t0 // sample t0
tex t1 // sample t1
tex t2 // sample t2
/* lrp r0.rgb,t2.a,t0,t1 // blend t0 with t1 using the alpha channel of t2 */
mov r1,t1
lrp r0.rgb,t2.a,t0,r1 // blend t0 with t1 using the alpha channel of t2
+mov r0.a,c0
//add r0.rgb,r0,t2_bias // add(signed) rgb of t2
mul r0.rgb,r0,v0 // modulate with diffuse vertex lighting
};
}
}
";
}

action terrain
{
my.skill41=float(10);
my.skill42=float(20);
my.skill43=float(5);
my.skill44=float(10);

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


Posted By: salem

Re: need help with terrain multitexturing - 01/28/04 09:18

thank you soo much! this has really helped me out, i appreciate ur patience, maybe now i can start to analyze what all this seemingly mumbojumbo code is supposed to do
Posted By: Darkstorm

Re: need help with terrain multitexturing - 01/28/04 09:42

Not a problem. Good luck with the code.
Posted By: salem

Re: need help with terrain multitexturing - 01/28/04 10:39

ooookay hahah...still having problems here guys, thought it was all worked out but apparently not...ive got it to the point that there is one section of the map transparent (where the alpha map is obviously) but the two other maps arent showing up at all...<extremely confused>

if anyone has any suggestions or anything, reply please or IM me on AIM @ enigmaticpundit thanks in advance!
Posted By: Darkstorm

Re: need help with terrain multitexturing - 01/28/04 12:50

Did you check to make sure that the skin with the alpha channel is the third skin in the HMP?
Posted By: salem

Re: need help with terrain multitexturing - 01/29/04 03:15

yes...but just to be sure! by third u mean that in the skin window it is #3 from 3 (shown on the bottom rim of the window.)

does it matter what file type the other two skins are? what do you usually use for them?

also, do i need any textrues on the third (alpha mapped one) besides the alpha map? (right now i have it black all black in rbg mode, but the alpha channel still has its black and white)

would you happen to have a sample hmp that actually works that i can play with?
Posted By: Darkstorm

Re: need help with terrain multitexturing - 01/29/04 06:12

To get to the third skin, click the down arrow when in MEDs skin editor. Clicking twice should bring you to the third skin. I know in the version of your terrain that I downloaded, you had the skin with the alpha channel as the first.

I usually use BMP for my skins but I'm not sure if it matters or not. You don't need a texture for the skin with the alpha channel. I usually just fill it with a color that is in my texturres for my own peace of mind.

I don't have any HMP that I could send but if you zip up your terrain and all three skins, I'll fix it up for you.

-Jeff
Posted By: salem

Re: need help with terrain multitexturing - 01/29/04 06:54

okay...im going to upload the textures and the heightmap for you...and the one hmp that i just did...perhaps im missing something in my hardware or software to allow for it to render correctly? if so is it downloadable anywhere...??

check back in 10
Posted By: salem

Re: need help with terrain multitexturing - 01/29/04 07:01

textures, heightmap, hmp

if you get it to work, could u show me a screenshot of what it looks like?

again- any software needed?

thanks!
Posted By: Darkstorm

Re: need help with terrain multitexturing - 01/29/04 07:26

The terrain works fine other than being hard to look at . Here is the shot:



What version of 3DGS are you using?
Posted By: salem

Re: need help with terrain multitexturing - 01/29/04 07:33

commercial 6.20.2 it looks nothing like that in mine...just a totally green terrain... even on a nvidia geforce 4
Posted By: Steempipe

Re: need help with terrain multitexturing - 01/29/04 07:34

I have a test terrain I have been using.

For you have I done this:
entSkin1 = a green texture (24bpp BMP, 256x256)
entSkin2 = a brown texture (24bpp BMP, 256x256)
entSkin3 = a TGA Alpha channel. It it is a gradient fill to blend from the low to the high point. It is a 32bpp and 512x512.

I used the unmodified multitexturing shader that ventilator posted. So it should wotk for you if you add the Terrain action to your the HMP.

http://steempipe.technicalfoundry.com/testskins.zip


Good luck!!

Posted By: Steempipe

Re: need help with terrain multitexturing - 01/29/04 07:38

What video card are you using??
Posted By: Darkstorm

Re: need help with terrain multitexturing - 01/29/04 07:40

Here is the "level" that the shot was taken from... script and all. See if that works for you.

Terrain Test

Could be your card I suppose. The GeForce4 MX will not run this as far as I know. Do you get any errors about effect unsupported by hardware?
Posted By: salem

Re: need help with terrain multitexturing - 01/29/04 08:13

i am using a nvidia geforce 4 and its still not working for me...perhaps i theres some interference with the drivers from one of my other pieces of hardware... im sure if i can fix it this will rock out, thanks a lot guys for all your help- i really appreciate it (and if it is my graphics card i apologize for wasting ur time lol i prolly wouldve had this right a couple posts ago)
Posted By: ventilator

Re: need help with terrain multitexturing - 01/29/04 17:09

i haven't read the whole thread but i use a geforce4 too and sometimes shaders don't seem to work for me if i don't add an empty fallback.

so try to add

technique fallback { pass p0 { } }

after the multitexture technique. i know this is strange but maybe it helps!
Posted By: salem

Re: need help with terrain multitexturing - 01/31/04 05:32

could you show me exactly where in the code is belongs? that was successful in removing the effect not supported by hardware error, but it still isnt rendering correctly...
Posted By: Steempipe

Re: need help with terrain multitexturing - 01/31/04 12:21

Goto ventilators "wiki" site and you can find where the fallback goes in the 2nd multitexture code posted there.

I would look at what Jeff says about your card too... If it is the MX you are out of luck as far as I know. And if it does support those, you need to know what versions of PS and VS.

A war story
I bought the Geforce4 MX 440 and found it does not support the pixel and vertex shaders and it has directx 7 on the card. I took the hit and then bought a freaking Radeon 9200 128mb so that I could at least run PS 1.4 and VS 1.1. It was not too expensive and more than enough to get my feet wet with these shaders. This only after spending many hours, if not days, as you are with the shader code.

Find out in your devices what your card is and let us know or find the specs on it online.


Posted By: Templar

Re: need help with terrain multitexturing - 03/12/04 04:59

well, here comes a true newbie question:

Would it be possible to use more than 2 textures?


Posted By: Steempipe

Re: need help with terrain multitexturing - 03/12/04 19:09

Yes, more than 2 textures are possible. It will depend on what version of pixelshader your card supports as to how you will accomplish this.

You always have the option of making multiple rendering passes too, but that may come with a cost on your FPS.

I would look over the following threads to begin with:
thread

and

thread

Eric

Posted By: Migueljb01

Re: need help with terrain multitexturing - 03/16/04 16:19

I made a test level with a 512x512 terrain I made in photoshop. 3 textures first one is colored green called entSkin1. Second is colored Brown called entSkin2. The 3rd is a 512x512 32bit Tga with alpha. The terrain in wed has the action terrain which is ventilator's script that was posted here by Jeff Frazer. They are all added in Med accordindly with the alpha being labeled 3 of 3. When I run my level in Wed I only see the green texture. So my question is this. How do I get the 2nd texture to blend in better with the 1st texture. I can only see the first texture. What settings in the code make the 2nd texture stand out more. Thanks for your help anyone.

-miguel

Lead Level Designer- ULS and Realspawn Productions
Posted By: Steempipe

Re: need help with terrain multitexturing - 03/16/04 18:45

Using the code snippet from above; the alpha channel in your TGA file is what will determine the blending amounts and where. You need to more or less paint that info on the alpha channel. If you open up your TGA in photoshop or whatever, and the alphachannel is all black then just paint some white stripes or something on the alpha channel and see what happens.

Did you add a fallback technique that was posted by ventilator in this thread?? Reason I ask, if your card does not support the PS/VS or there is in error in the pass it will drop to the fallback technique. Which will just show the entSkin1 texture on the terrain.

What is the card you are using??

Eric




Posted By: Migueljb01

Re: need help with terrain multitexturing - 03/17/04 07:41

I have a nvidia geforce 5200 128 mb video card. Here is what the terrain looks like for me its still just showing the green and not the brown texture. I dont get any errors from the script and everything runs fine it just wont show the brown texture thru the green. For the alpha im just painting white on top and saving it as a 32 bit tga. Is that the correct way to use the alpha texture.
Any help would be great.

-miguel
Lead Level Designer- Ultra Line Software and Realspawn Productions



Here's the 32 bit tga alpha im using



Posted By: Steempipe

Re: need help with terrain multitexturing - 03/17/04 08:28

I could not get access to view your images.

I am not too clear on how you are painting the alpha. If you are painting on the RGB channels then no, there will be no information in the alpha channel for blending.
you have to make sure you add an alpha channel, then paint on that channel, then make sure to save it as the 32 bit.

I guess, for starters, download a test TGA of mine, if you see some sort of blending when using it then you know that it is in your method of creating the alpha channel.

alphamap test

Let me know what happens and what version of Photoshop you use. I cannot recall, but there were TGA problems with one flavor of it and a file format fix is out there somewhere. Try the above map first.

Eric

© 2024 lite-C Forums