Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
2 registered members (TipmyPip, 1 invisible), 18,787 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Hatching-Problem #57682
10/17/05 10:25
10/17/05 10:25
Joined: Jul 2002
Posts: 60
BW, Germany
Tschieses Offline OP
Junior Member
Tschieses  Offline OP
Junior Member

Joined: Jul 2002
Posts: 60
BW, Germany
Hi folks.
I tried the hatching shader version from the wiki in A6.31.4 and the latest beta after converting the code from DX8 to DX9 but the only thing I get is a weird looking grayscale texture on my object.

Screenshots and code snippet following soon.

Now I want to ask if anyone has a working version of the shader.

Re: Hatching-Problem [Re: Tschieses] #57683
10/21/05 10:16
10/21/05 10:16
Joined: Jul 2002
Posts: 60
BW, Germany
Tschieses Offline OP
Junior Member
Tschieses  Offline OP
Junior Member

Joined: Jul 2002
Posts: 60
BW, Germany
Now here are two screenshots of my test level: a 26 sided sphere within a hollowed cube.

The sphere without hatching shader:


The sphere with hatch shader (d3d_automaterial = 1):


And the code of the hatching shader:

Code:
function mtl_hatch_init
{
bmap_to_mipmap(mtl.skin1);
bmap_to_mipmap(mtl.skin2);
}

material hatch123 {
skin1=bmp_hatch123;
skin2=bmp_hatch456;
event=mtl_hatch_init;
effect
"
texture mtlSkin1;
texture mtlSkin2;
matrix matWorldViewProj;
matrix matWorld;
vector vecSunDir;

technique hatch
{
pass p0
{
texture[0]=<mtlSkin1>;
texture[1]=<mtlSkin2>;

vertexShaderConstant[16]=<matWorldViewProj>;
vertexShaderConstant[20]=<matWorld>;
vertexShaderConstant[32]=<vecSunDir>;

vertexShaderConstant[48]={2.0,2.0,0.0,0.0}; // u_scale, v_scale, 0, 0
vertexShaderConstant[49]={6.0,6.0,6.0,1.0}; // brightness

vertexshader=
asm
{
vs.1.1

dcl_position v0;
dcl_normal v3;
dcl_texcoord0 v7;

def c0,0,0,0,0
def c1,1,1,1,1
def c2,2,2,2,2
def c3,3,3,3,3
def c4,4,4,4,4
def c5,5,5,5,5
def c6,6,6,6,6
def c7,7,7,7,7

m4x4 oPos,v0,c16 // transform position to clip space

mul oT0.xy,v7.xy,c48.xy // output scaled uvs
mul oT1.xy,v7.xy,c48.xy // output scaled uvs

m3x3 r3,v3,c20 // transform normal to world space
dp3 r3,r3,-c32 // normal.light -> light factor
mul r3,r3,c4 // brightness

mov r5.x,c5.x // seed blend weights
mov r5.y,c4.x
mov r5.z,c3.x
mov r5.w,c0.x

mov r6.x,c2.x
mov r6.y,c1.x
mov r6.z,c0.x
mov r6.w,c0.x

sub r5,r3,r5 // sub each weight's initial value from the light factor
sub r6,r3,r6

max r5,r5,c0 // ged rid of everything below zero
sge r7,c2,r5 // flag weights that are <= 2
mul r5,r5,r7 // zero out weights > 2
sge r7,r5,c1 // flag weights that are >= 1
mul r7,r7,c2 // subtract all weights that are greater than or equal to one from 2
sub r5,r7,r5
slt r7,r5,c0 // flag all weights that are < 0 and negate
sge r8,r5,c0 // flag all spots that are >= 0
add r7,-r7,r8 // add the flags
mul r5,r5,r7 // should negate negatives and leave positives

max r6,r6,c0 // repeat for second set of weights
sge r7,c2,r6
mul r6,r6,r7
sge r7,r6,c1
mul r7,r7,c2
sub r6,r7,r6
slt r7,r6,c0
sge r8,r6,c0
add r7,-r7,r8
mul r6,r6,r7

sge r8,c1,r3 // check for total shadow and clamp on the darkest texture
mov r7,c0
mov r7.z,r8.z
add r6,r6,r7
min r6,r6,c1

mov oT2.xyz,r5 // output 123 weights to uv3
mov oT3.xyz,r6 // output 456 weights to uv4
};
pixelshader=
asm
{
ps.1.1
tex t0 // sample t0
tex t1 // sample t1
texcoord t2 // get 123 weights
texcoord t3 // get 456 weights
dp3_sat r0,1-t0,t2 // t0.t2_weights
dp3_sat r1,1-t1,t3 // t1.t3_weights
add_sat r0,r0,r1 // r0+r1
mov_sat r0,1-r0 // complement and saturate
};
}
}
";
}



Re: Hatching-Problem [Re: Tschieses] #57684
10/21/05 10:30
10/21/05 10:30
Joined: Oct 2002
Posts: 8,939
planet.earth
ello Offline
Senior Expert
ello  Offline
Senior Expert

Joined: Oct 2002
Posts: 8,939
planet.earth
did you try the shader on a model, too?


www.earthcontrol.de
quoted: We want to maintain a clean, decent, American family suited forum look... which means you may post zombies or chainsaw massacres, but no erotic.
Re: Hatching-Problem [Re: ello] #57685
10/24/05 15:04
10/24/05 15:04
Joined: Jul 2002
Posts: 60
BW, Germany
Tschieses Offline OP
Junior Member
Tschieses  Offline OP
Junior Member

Joined: Jul 2002
Posts: 60
BW, Germany
Tried it with a sphere model but I can't get the material on it.
I named the material like the model file (sphere_mdl) and set d3d_automaterial to 1 but that all has no effect :/

Beside that I need the shader for geometries as well.

Can anyone help?

Re: Hatching-Problem [Re: Tschieses] #57686
10/24/05 17:05
10/24/05 17:05
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
Quote:

I named the material like the model file (sphere_mdl) and set d3d_automaterial to 1 but that all has no effect :/




d3d_automaterial works with level textures only. You have to write the follwing code in the models action:
Code:
My.Material = hatch123;




Always learn from history, to be sure you make the same mistakes again...
Re: Hatching-Problem [Re: Uhrwerk] #57687
10/26/05 07:15
10/26/05 07:15
Joined: Jul 2002
Posts: 60
BW, Germany
Tschieses Offline OP
Junior Member
Tschieses  Offline OP
Junior Member

Joined: Jul 2002
Posts: 60
BW, Germany
OK, found the problem.
After setting d3d_automaterial to 2 the hatch shader works on the model but not in that way it should. The whole model is drawn in the darkest cross hatch. The light map seems to be ignored completely.


Moderated by  Blink, Hummel, Superku 

Gamestudio download | 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