Gamestudio Links
Zorro Links
Newest Posts
Trading Journey
by howardR. 04/24/24 20:04
M1 Oversampling
by Petra. 04/24/24 10:34
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Data from CSV not parsed correctly
by EternallyCurious. 04/20/24 21:39
Scripts not found
by juergen_wue. 04/20/24 18:51
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
folder management functions
by VoroneTZ. 04/17/24 06:52
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 642 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Mega_Rod, EternallyCurious, howardR, 11honza11, ccorrea
19048 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
detail map on model + environment mapping #167919
11/17/07 12:26
11/17/07 12:26
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline OP
Senior Expert
HeelX  Offline OP
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
This is a simple shader I needed for my current scene. It is a detail mapping shader, which tiles an entity skin2 over entity skin1. In addition, a cubemap will be projected over it, to make it shiny/icy/whatever.

This is how it looks like in my scene. The white environment is using this shader (it has a shadowmap plus the snow as detailmap plus a cubemap to make it "icy"). The floes use the environmental mapping part without the tiling and the water is Slin's NVidia oceanshader. The water depth are stacked slight transparent planes to simulate water depth. The snow is a particle effect.



Copy this functional code into your shader file (or create a new shader.c/.h file for it):

Code:
void mtl_detailShiny_init();
void mtl_detailShiny_func();

char* MTL_DETAILSHINY_CUBEMAP = "detailShiny+6.tga";

MATERIAL* mtl_detailShiny = {
event = mtl_detailShiny_init;
flags = enable_view;
effect = "detailShiny.fx";
}

void mtl_detailShiny_init ()
{
//load cubemap
mtl.skin1 = bmap_create(MTL_DETAILSHINY_CUBEMAP);
bmap_to_cubemap(mtl.skin1);

mtl.event = mtl_detailShiny_func;
}

void mtl_detailShiny_func ()
{
mat_set(mtl.matrix, matViewInv);

mtl.matrix41 = 0;
mtl.matrix42 = 0;
mtl.matrix43 = 0;
}



Create a new textfile which is called "detailShiny.fx" and paste this code into it:

Code:
extern texture entSkin1;
extern texture entSkin2;
extern texture mtlSkin1;

extern float4x4 matMtl;

technique detailShiny
{
pass p0
{
Lighting = true;

//render model with skin1

Texture[0] = <entSkin1>;
ColorArg1[0] = Texture;
texcoordindex[0] = 0;

//tile skin2 over it

Texture[1] = <entSkin2>;
colorarg1[1] = Texture;
colorarg2[1] = current;
colorop[1] = modulate;
texcoordindex[1] = 0;
texturetransformflags[1] = count2;
texturetransform[1] = { 15.0,0.0,0.0,0.0, // tiles u
0.0,15.0,0.0,0.0, // tiles v
0.0,0.0,0.0,0.0,
0.0,0.0,0.0,0.0};

//apply transparent cubemap

texture[2]=<mtlSkin1>;
colorArg1[2]=Texture;

colorOp[2]=blendFactorAlpha;
textureFactor=0x25FFFFFF; //~15% cubemap alpha
//textureFactor=0x75FFFFFF; //~75%
//textureFactor=0x80FFFFFF; //~50%
//textureFactor=0x40FFFFFF; //~25%

addressU[2]=Clamp;
addressV[2]=Clamp;
texCoordIndex[2]=cameraSpaceReflectionVector;
textureTransformFlags[2]=Count3;
textureTransform[2]=<matMtl>;
}
};



Put into your modelfile (which should be rendered with the shader) the texture into skin1 and the detail texture into skin2. To use another cubemap, replace the char definition.

Because of the usage of both detail map and cubemap, the model could get slightly darker - you can troubleshoot it by raising the emmissive values of the material (I suggest to do this modelwise in the DirectX material definition).

Have fun with this!
Cheers, Christian

Re: detail map on model + environment mapping [Re: HeelX] #167920
11/17/07 12:37
11/17/07 12:37
Joined: Nov 2004
Posts: 7,121
Potsdam, Brandenburg, Germany
Machinery_Frank Offline
Senior Expert
Machinery_Frank  Offline
Senior Expert

Joined: Nov 2004
Posts: 7,121
Potsdam, Brandenburg, Germany
This is a very well done composition of materials and effects. Thanks for sharing it!


Models, Textures and Games from Dexsoft
Re: detail map on model + environment mapping [Re: Machinery_Frank] #167921
11/17/07 13:03
11/17/07 13:03
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Pappenheimer Offline
Senior Expert
Pappenheimer  Offline
Senior Expert

Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
This scene is wonderful!

I'm very curious what you are working on!
I guess, Chrismas will show it! :-)

Re: detail map on model + environment mapping [Re: Pappenheimer] #167922
11/17/07 14:45
11/17/07 14:45
Joined: May 2005
Posts: 2,713
Lübeck
Slin Offline
Expert
Slin  Offline
Expert

Joined: May 2005
Posts: 2,713
Lübeck
Nice Scene
and thanks for the nice effect.
Would you mind adding it to the wiki, would it be okay if I add it or don´t you want it to be there?

Re: detail map on model + environment mapping [Re: Slin] #167923
11/17/07 14:56
11/17/07 14:56
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline OP
Senior Expert
HeelX  Offline OP
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
Do it

Re: detail map on model + environment mapping [Re: HeelX] #167924
11/17/07 15:31
11/17/07 15:31
Joined: May 2005
Posts: 2,713
Lübeck
Slin Offline
Expert
Slin  Offline
Expert

Joined: May 2005
Posts: 2,713
Lübeck
Done

Re: detail map on model + environment mapping [Re: HeelX] #167925
11/17/07 15:48
11/17/07 15:48
Joined: Oct 2006
Posts: 91
G
Ghost Offline
Junior Member
Ghost  Offline
Junior Member
G

Joined: Oct 2006
Posts: 91
Very nice HeelX and very kind of you to contribute it. Thanks.
- just need to add Santa;)

Re: detail map on model + environment mapping [Re: Ghost] #167926
11/17/07 16:40
11/17/07 16:40
Joined: Oct 2004
Posts: 4,134
Netherlands
Joozey Offline
Expert
Joozey  Offline
Expert

Joined: Oct 2004
Posts: 4,134
Netherlands
Thats how leveldesign should be done


Click and join the 3dgs irc community!
Room: #3dgs
Re: detail map on model + environment mapping [Re: Joozey] #167927
11/17/07 17:02
11/17/07 17:02
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline OP
Senior Expert
HeelX  Offline OP
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
I will post further screenshots of the scene in the other thread when I'm ready. I was quite busy these days with modeling and programming and I don't want to present crappy programmers artwork but pretty programmers artwork ^^

Cheers and thanks for the kind replies ^^

Last edited by HeelX; 11/17/07 17:02.
Re: detail map on model + environment mapping [Re: HeelX] #167928
11/17/07 18:07
11/17/07 18:07
Joined: Aug 2002
Posts: 2,692
California, USA
bupaje Offline
Expert
bupaje  Offline
Expert

Joined: Aug 2002
Posts: 2,692
California, USA
I love the way that looks, very cool in every sense of the word.


Find me at: |Stormvisions| Twitter|
Page 1 of 2 1 2

Moderated by  adoado, checkbutton, mk_1, Perro 

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