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
2 registered members (AndrewAMD, 1 invisible), 1,395 guests, and 12 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19055 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Wow! A flat grey shader! #49040
07/11/05 20:44
07/11/05 20:44
Joined: Apr 2005
Posts: 64
Italy - Rome
_
_Tommo_ Offline OP
Junior Member
_Tommo_  Offline OP
Junior Member
_

Joined: Apr 2005
Posts: 64
Italy - Rome
I'm a shader newbie, and i were trying to program a simple vertex shader just for test. The shader works, but after the level loads and the camera is loaded, all the objects using that material get a beautiful flat grey... and i'm sure that the shader's parameters aren't modified by starters or other functions...
Here's the code:
Code:
 

material mat_test
{
effect = "

matrix matWorldViewProj;
matrix matWorld;

texture entSkin1; //
texture entSkin2; //
dword mtlSkill1;

vector vecLight;

vector vecViewDir;

// default technique
technique test
{
pass P0
{
VertexShaderConstant[0]=<matWorldViewProj>;
VertexShaderConstant[4]=<matWorld>;
VertexShaderConstant[10]= <vecLight>;
VertexShaderConstant[15]= <vecViewDir>;

Texture[0] = <entSkin1>;
Texture[1] = <entSkin2>;

VertexShader = asm

vs.1.1

dcl_position v0
dcl_normal v3
dcl_texcoord0 v7

def c16, 0, 175, 175, 100
def c20, 175, 0.011,0,0

m4x4 oPos, v0,c0

sub r0, v3, -c15

mul r0, r0, c16

mul oD0, r0, c20.yyyy
};

}
}


technique fallback
{
pass P0
{
// set texture stage states
Texture[0] = <entSkin1>;
ColorArg1[0] = Texture; // stage 0 = skin texture
ColorOp[0] = Modulate2x;
ColorArg2[0] = Diffuse; // modulate by lighting
}
}
"; // end of the effect string
}





There are some useless things, and the shader itself it's useless, but someone has an idea of because it becomes flat grey after camera loading?
Thanks, Tommo

Re: Wow! A flat grey shader! [Re: _Tommo_] #49041
07/12/05 02:36
07/12/05 02:36

A
Anonymous
Unregistered
Anonymous
Unregistered
A



I fixed the code for you. Please note: I'm not a shader programmer.

Code:
material mat_test
{
effect = "

matrix matWorldViewProj;
matrix matWorld;

texture entSkin1; //
texture entSkin2; //
dword mtlSkill1;

vector vecLight;

vector vecViewDir;

// default technique
technique test
{
pass P0
{
VertexShaderConstant[0]=<matWorldViewProj>;
VertexShaderConstant[4]=<matWorld>;
VertexShaderConstant[10]= <vecLight>;
VertexShaderConstant[15]= <vecViewDir>;

Texture[0] = <entSkin1>;
Texture[1] = <entSkin2>;

VertexShader = asm vs.1.1

dcl_position v0
dcl_normal v3
dcl_texcoord0 v7

def c16, 0, 175, 175, 100
def c20, 175, 0.011,0,0

m4x4 oPos, v0,c0
sub r0, v3, -c15
mul r0, r0, c16
mul oD0, r0, c20.yyyy
};
}

technique fallback
{
pass P0
{
// set texture stage states
Texture[0] = <entSkin1>;
ColorArg1[0] = Texture; // stage 0 = skin texture
ColorOp[0] = Modulate2x;
ColorArg2[0] = Diffuse; // modulate by lighting
}
}
"; // end of the effect string
}



Re: Wow! A flat grey shader! [Re: _Tommo_] #49042
07/12/05 07:04
07/12/05 07:04
Joined: Oct 2002
Posts: 8,939
planet.earth
ello Offline
Senior Expert
ello  Offline
Senior Expert

Joined: Oct 2002
Posts: 8,939
planet.earth
and what did you expect from that shader?
when i apply it to a model the color changes as the camera-angle changes

btw, both of you forgot the bracket at the beginning of the vertexshader asm section

so lets look:

Code:
 
technique test
{
pass P0
{
VertexShaderConstant[0]=<matWorldViewProj>;
VertexShaderConstant[4]=<matWorld>;
VertexShaderConstant[10]= <vecLight>;
VertexShaderConstant[15]= <vecViewDir>;

Texture[0] = <entSkin1>;
Texture[1] = <entSkin2>;

VertexShader = asm
{
vs_1_1

dcl_position v0
dcl_normal v3
dcl_texcoord0 v7

def c16, 0, 175, 175, 100
def c20, 175, 0.011,0,0

m4x4 oPos, v0,c0

sub r0, v3, -c15 //r0 now contains : normal - ( - vecViewDir)

mul r0, r0, c16 //r0 gets multiplied by cyan

mul oD0, r0, c20.y //ro gets scaled down by 0.011
};

}
}




Last edited by ello; 07/12/05 07:11.
Re: Wow! A flat grey shader! [Re: ello] #49043
07/12/05 16:52
07/12/05 16:52

A
Anonymous
Unregistered
Anonymous
Unregistered
A



OK. I didn't know, but like I said, I'm not a shader programmer. Sorry.

Re: Wow! A flat grey shader! #49044
07/12/05 18:42
07/12/05 18:42
Joined: Oct 2002
Posts: 8,939
planet.earth
ello Offline
Senior Expert
ello  Offline
Senior Expert

Joined: Oct 2002
Posts: 8,939
planet.earth
Quote:

OK. I didn't know, but like I said, I'm not a shader programmer. Sorry.




hey, take this excuse back, or i put you into a barrel full of ink:)

i cant hear those "sorry" here and "sorry" there.. sorry for what?? you dont need to be sorry:)

Re: Wow! A flat grey shader! #49045
07/12/05 19:05
07/12/05 19:05
Joined: Apr 2005
Posts: 64
Italy - Rome
_
_Tommo_ Offline OP
Junior Member
_Tommo_  Offline OP
Junior Member
_

Joined: Apr 2005
Posts: 64
Italy - Rome
As i said, i didn't expect nothing from the shader... i was only trying v3 and vecView parameters, to simulate an electronic microscope view (that doesn't work, but this is another matter). My problem was that with my custom camera all the objects with the shader applied get flat grey. I made another try, and with the predefined camera it works... maybe it could happen because of the fog parameter?
And btw, while the vecview is expressed in pan, tilt and roll, how it's the normal of the vertex expressed?

Re: Wow! A flat grey shader! [Re: _Tommo_] #49046
07/13/05 06:26
07/13/05 06:26
Joined: Oct 2002
Posts: 8,939
planet.earth
ello Offline
Senior Expert
ello  Offline
Senior Expert

Joined: Oct 2002
Posts: 8,939
planet.earth
o yes, is your fog color grey?


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: Wow! A flat grey shader! [Re: ello] #49047
07/13/05 11:24
07/13/05 11:24
Joined: Apr 2005
Posts: 64
Italy - Rome
_
_Tommo_ Offline OP
Junior Member
_Tommo_  Offline OP
Junior Member
_

Joined: Apr 2005
Posts: 64
Italy - Rome
yes, the grey is the same color of fog_color 1, but fog_color 1 isn't active, and cam (my camera) has fog = 0... i don't know how it can influence the shader, anyway thanks for the help.

Re: Wow! A flat grey shader! [Re: _Tommo_] #49048
07/13/05 11:31
07/13/05 11:31
Joined: Oct 2002
Posts: 8,939
planet.earth
ello Offline
Senior Expert
ello  Offline
Senior Expert

Joined: Oct 2002
Posts: 8,939
planet.earth
you could try to write a value into the oFog register in your vertex shader like

mov oFog.x,c20.w


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.

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