Gamestudio Links
Zorro Links
Newest Posts
Blobsculptor tools and objects download here
by NeoDumont. 03/28/24 03:01
Issue with Multi-Core WFO Training
by aliswee. 03/24/24 20:20
Why Zorro supports up to 72 cores?
by Edgar_Herrera. 03/23/24 21:41
Zorro Trader GPT
by TipmyPip. 03/06/24 09:27
VSCode instead of SED
by 3run. 03/01/24 19:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (Imhotep, opm), 785 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
sakolin, rajesh7827, juergen_wue, NITRO_FOREVER, jack0roses
19043 Registered Users
Previous Thread
Next Thread
Print Thread
Rating: 4
Page 10 of 14 1 2 8 9 10 11 12 13 14
Re: Bump Mapping Shader [Re: Rhuarc] #22230
02/28/05 06:24
02/28/05 06:24
Joined: Mar 2002
Posts: 7,726
old_bill Offline
Senior Expert
old_bill  Offline
Senior Expert

Joined: Mar 2002
Posts: 7,726
Thanks,
i've totaly forgotten this entry!
EDIT:
But it still wont work:
Quote:

Malfunction W1550: Error in effect:
mat_bumpmap(36): error X3000: syntax error: unexpected token 'v0'

> dcl_position v0 <




Setting to 0.0 did not help.

old_bill

Re: Bump Mapping Shader [Re: old_bill] #22231
02/28/05 06:39
02/28/05 06:39
Joined: Mar 2002
Posts: 7,726
old_bill Offline
Senior Expert
old_bill  Offline
Senior Expert

Joined: Mar 2002
Posts: 7,726
To make it more easyer to correct, where are possible DX9 problems in this code:
Code:
material mat_bumpmap
{
effect"

matrix matWorldViewProj;
matrix matWorld;

texture entSkin1;
texture entSkin2;

vector vecLight;

technique dot3map
{
pass p0
{
Texture[0] = <entSkin2>;//2te Skin im Model ist die Normal Map
Texture[1] = <entSkin1>;//1te Skin im Model ist die Textur

COLOROP[0] = dotproduct3;
COLORARG1[0] = texture;
COLORARG2[0] = diffuse;

COLOROP[1] = modulate;
COLORARG1[1] = texture;
COLORARG2[1] = current;

VertexShaderConstant[0]=<matWorldViewProj>;
VertexShaderConstant[4]=<matWorld>;
VertexShaderConstant[18]={1.0f,1.0f,1.0f,1.0f};
VertexShaderConstant[19]={0.5f,0.5f,0.5f,0.5f};
VertexShaderConstant[20]= <vecLight>;
VertexShaderConstant[30]={0.0f,1.0f,0.0f,0.0f};
VertexShaderConstant[31]={1.0f,0.0f,0.0f,0.0f};
VertexShaderConstant[32]={0.0f,0.0f,1.0f,0.0f};
VertexShaderConstant[90]={1.0f,0.0f,0.0f,0.0f}; //damit oFog gefüllt ist

dcl_position v0
dcl_normal v3
dcl_texcoord0 v7
dcl_texcoord1 v8

asm
{
vs.1.1
m4x4 oPos, v0, c0
m4x4 r10,v0,c4
m3x3 r8,v3,c4
mov oT0, v7
mov oT1, v7
mov oT2, v7
mov oT3, v7

//calculate texture space matrix from normal and up
mul r0,c31,v3.zxyw //-1,0,0
mul r1,c32,v3.yzxw //0,0,-1
sub r0,r1,r0

dp3 r0.w,r0,r0
rsq r0.w,r0.w
mul r0,r0,r0.w //normalized right vector

mov r1, c30 //0,-1,0
mov r2, r8

sub r9,c20,r10

dp3 r9.w,r9,r9
rsq r9.w,r9.w
mul r9,r9,r9.w //normalized light vector

m3x3 r3,r9,r0
mov r3.w,c30.w //transform light to texture space

add r3,r3,c18 //bias
mul r3,r3,c19//scale
mov oD0,r3
mov oFog,c90
};
}
}
";
}


action fx_bumpmaping
{
my.material = mat_bumpmap;
}



Thanks
old_bill


Success is walking from failure to failure with no loss of enthusiasm.
Re: Bump Mapping Shader [Re: old_bill] #22232
02/28/05 07:40
02/28/05 07:40
Joined: Dec 2003
Posts: 1,097
Maryland, USA
Steempipe Offline
Serious User
Steempipe  Offline
Serious User

Joined: Dec 2003
Posts: 1,097
Maryland, USA
Make it like this:

Code:

asm {
vs.1.1

dcl_position v0
dcl_normal v3
dcl_texcoord0 v7
dcl_texcoord1 v8


.................




Re: Bump Mapping Shader [Re: Steempipe] #22233
02/28/05 20:44
02/28/05 20:44
Joined: Mar 2002
Posts: 7,726
old_bill Offline
Senior Expert
old_bill  Offline
Senior Expert

Joined: Mar 2002
Posts: 7,726
Thanks Steempipe, this part works now!

But the next error lies here:
Code:
VertexShader =

asm
{
vs.1.1

dcl_position v0
dcl_normal v3
dcl_texcoord0 v7
dcl_texcoord1 v8

m4x4 oPos, v0, c0
m4x4 r10,v0,c4
m3x3 r8,v3,c4
mov oT0, v7
mov oT1, v7
mov oT2, v7
mov oT3, v7

//calculate texture space matrix from normal and up
mul r0,c31,v3.zxyw //-1,0,0
mul r1,c32,v3.yzxw //0,0,-1
sub r0,r1,r0

dp3 r0.w,r0,r0
rsq r0.w,r0.w
mul r0,r0,r0.w //normalized right vector

mov r1, c30 //0,-1,0
-----------------------------------------------
mov r2, r8

sub r9,c20,r10

dp3 r9.w,r9,r9
rsq r9.w,r9.w
mul r9,r9,r9.w //normalized light vector

m3x3 r3,r9,r0
mov r3.w,c30.w //transform light to texture space

add r3,r3,c18 //bias
mul r3,r3,c19//scale
mov oD0,r3
mov oFog,c90
};
}
}
";
}



Downwards the red line several errors coming up:

Quote:

Malfunction W1550: Error in effect:
mat_bumpmap(65): error X5326: Read of uninitialized component(*) in r8: x/0 y/1 z/2 *w/3
(79): error X5430: When writing to scalar output register, mov instruction must use replicate swizzle on source parameter(s), in order to select single component. i.e. .x | .y | .z | .w (or rgba equivalent)

> mov r2, r8 <




Please excuse my kind of ignorance, but i have absolutley no knowledge of shaders.

old_bill


Success is walking from failure to failure with no loss of enthusiasm.
Re: Bump Mapping Shader [Re: old_bill] #22234
03/01/05 06:11
03/01/05 06:11
Joined: Mar 2001
Posts: 3,298
Beverly, Massachusetts
Rhuarc Offline
Expert
Rhuarc  Offline
Expert

Joined: Mar 2001
Posts: 3,298
Beverly, Massachusetts
This error is saying that r2 needs to have a "swizzle" on it that grabs only part of it.
Code:
mov r2.w,r8



I'm not sure what it's supposed to be, try using x, y, and z in place of W if the shader doesn't operate properly . I'd have to look at the rest of the code to figure it out and ASM makes me dizzy (I made Phoenix 2 for TI-89... all 68k asm.... YUCK! )

-Rhuarc


I no longer post on these forums, keep in touch with me via:
Linkedin.com
My MSDN blog
Re: Bump Mapping Shader [Re: Rhuarc] #22235
03/03/05 11:54
03/03/05 11:54
Joined: May 2004
Posts: 157
Earth, for the moment
MASTERJUNOJET Offline
Member
MASTERJUNOJET  Offline
Member

Joined: May 2004
Posts: 157
Earth, for the moment
So no one knows why Im gettin all this dark stuff?


Projects: Jet Force Gemini 2
Re: Bump Mapping Shader [Re: MASTERJUNOJET] #22236
03/28/05 20:44
03/28/05 20:44
Joined: Oct 2003
Posts: 1,550
United Kingdom
indiGLOW Offline
Serious User
indiGLOW  Offline
Serious User

Joined: Oct 2003
Posts: 1,550
United Kingdom
Yeah I had the same problems trying to use the 2.0 version on my radeon 9800 pro, and just like old_bill I can't get it to work....

In all honesty I have been trying to implement any shader today, including the code from the manual for a basic bump map shader and im struggling there...

If anyone knows how to solve the problems Old Bill mentions and or someone wants to take the time to help me get ANY shader running I would really appreciate it....

Last year I managed to get the multi texture terrain working, but since then lots of new stuff is out there, at the time I think it was like pixel shader 1.4 or something... so its been a while and it looks like everything I learned then (which was not a gr8 load) has flown the rusty old brain...

Last edited by indiGLOW; 03/28/05 20:45.
Re: Bump Mapping Shader [Re: indiGLOW] #22237
03/29/05 10:35
03/29/05 10:35
Joined: Dec 2003
Posts: 1,097
Maryland, USA
Steempipe Offline
Serious User
Steempipe  Offline
Serious User

Joined: Dec 2003
Posts: 1,097
Maryland, USA
Man.... these codes are old.

However, this is what I was using at one point.

If it helps anyone, great.

Code:
 
////////////////////////////////////////////////////
//
// Basic Dot3 Bumpmapping.
//
// Calulates diffuse lighting from Sun and Level Light
//
// Needs: A6.31 Comm+ DX9c vertexshader.1.1
//
// Todo: Lighting improvements
//
// Eric Hendrickson-Lambert (Steempipe)
//
// 3/28/05: Made changes for DX9 A6

material mat_bumpmap
{

flags=tangent;

effect="

matrix matWorldViewProj;
matrix matWorld;

texture entSkin1; //Colormap
texture entSkin2; //Normalmap

vector vecLight;
vector vecFog;
vector vecSunDir;

technique dot3mapping
{
pass p0
{

AlphaBlendEnable = False;
AlphaTestEnable = False;
Lighting = True;
DitherEnable = True;

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

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

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

VertexShaderConstant[0]=<matWorldViewProj>;
VertexShaderConstant[4]=<matWorld>;

vertexShaderConstant[9]= <vecFog>;
vertexShaderConstant[10]=<vecSunDir>;
vertexShaderConstant[11]=<vecLight>;
VertexShaderConstant[12]={0.5f, 0.5f, 0.0f, 0.0f};

VertexShader =
asm
{

vs_1_1

// Declarations
dcl_position v0
dcl_normal v3
dcl_texcoord0 v7
dcl_texcoord1 v8

// Transform position to clip space
m4x4 oPos, v0, c0

// Tranform normal and tangent to world space
m3x3 r3, v8, c4
m3x3 r5, v3, c4

// Compute binormal
mul r0, r3.zxy, r5.yzx
mad r4, r3.yzx, r5.zxy, -r0

// Transform (Sun)light vector to tangent space
dp3 r0.x, r3.xyz, -c10
dp3 r0.y, r4.xyz, -c10
dp3 r0.z, r5.xyz, -c10

// Normalize transformed light vector
dp3 r0.w, r0, r0
rsq r0.w, r0.w
mul r0, r0, r0.w

// Put light vector in range from 0 to 1
mad r0, r0, c12.x, c12.x
// Adjust the intensity
mul r0, r0, c12.y
// Add environment light then send it down the diffuse pipe
add oD0.xyz,r0,c11

// Fog calculations
mov r1.w,c9.w
dp4 r0,v0,c6 // distance to camera position
add r0,r0,-c9.x // distance-fog_start
mad r0.x,-r0.x,c9.z,r1.w // 1-(distance-fog_start)*(1/(fog_end-fog_start))
max oFog,r0.x,c12.w // clamp with custom max value

// Pass the texture coordinates through
mov oT0, v7
mov oT1, v7
};
}
}
";
}



action fx_bumpmaping
{
my.material = mat_bumpmap;
}





Re: Bump Mapping Shader [Re: Steempipe] #22238
03/29/05 19:08
03/29/05 19:08
Joined: Oct 2003
Posts: 1,550
United Kingdom
indiGLOW Offline
Serious User
indiGLOW  Offline
Serious User

Joined: Oct 2003
Posts: 1,550
United Kingdom
Thanks Steampipe, I will give it a go later today. Wonder if I will manage anything more than black!


The Art of Conversation is dead : Discuss
Re: Bump Mapping Shader [Re: indiGLOW] #22239
03/30/05 19:37
03/30/05 19:37
Joined: Oct 2003
Posts: 1,550
United Kingdom
indiGLOW Offline
Serious User
indiGLOW  Offline
Serious User

Joined: Oct 2003
Posts: 1,550
United Kingdom
Thanks Steampipe, that worked just great for me.

Thanks for getting me back to at least being able to add a material!

I notice that my normal map doesnt seem to make it very obvious that it is bumpy, is there a way to force the depth? So that the raised areas are more...raised and the depth is deeper

Is it just a matter of changing the normal map? I have tried fiddling with the Nvidia Normal plugin for Adobe but have yet to tackle the Studio Max Normal map tools, and i dont seem to be able to get exagerated bump mapping. Any suggestions?


The Art of Conversation is dead : Discuss
Page 10 of 14 1 2 8 9 10 11 12 13 14

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