Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (degenerate_762, Aku_Aku, 7th_zorro, Ayumi), 1,080 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
projection shader #42494
03/14/05 01:14
03/14/05 01:14
Joined: Jan 2004
Posts: 3,023
The Netherlands
Helghast Offline OP
Expert
Helghast  Offline OP
Expert

Joined: Jan 2004
Posts: 3,023
The Netherlands
hello everyone,

i wanna ask if someone can help me update the projection shader to DX9.

i wanted to do myself and went through the manual with all lines that are in there (i learned from it, but obviously not enough :P).
i came as far as to update 4 lines to DX9 code (which are stated in the code as a comment, you should see them ^_^ ).

anyone know what to update more on this code to get it to work, or does someone has me a HLSL code for this ??

hope someone can help.

Code:
 
bmap projectiontex = <attack.tga>;


var scan_radius=210;
var lighttimer=0;

var matTexProj[16];

var tempmatrix[16];


function mat_projection_init()
{

mtl.enable_render=on;

//set up the texture projection matrix

matTexProj[0]=my.skill80;
matTexProj[1]=my.skill81;
matTexProj[2]=my.skill82;
matTexProj[3]=my.skill83;

matTexProj[4]=my.skill84;
matTexProj[5]=my.skill85;
matTexProj[6]=my.skill86;
matTexProj[7]=my.skill87;

matTexProj[8]=my.skill88;
matTexProj[9]=my.skill89;
matTexProj[10]=my.skill90;
matTexProj[11]=my.skill91;

matTexProj[12]=my.skill92;
matTexProj[13]=my.skill93;
matTexProj[14]=my.skill94;
matTexProj[15]=my.skill95;

mat_set(mtl.matrix,matWorld);
mat_multiply(mtl.matrix,matTexProj);

}


material mat_projection
{

skin1 = projectiontex;

event = mat_projection_init;

flags = tangent;
effect =
"

texture mtlSkin1; //projector
texture entSkin1; //colormap
matrix matWorldViewProj;
matrix matWorld;
matrix matMtl;

technique projector
{

pass p0 //projector
{

//load matrices
VertexShaderConstant[0] = <matWorld>; //World Matrix
VertexShaderConstant[8] = <matWorldViewProj>; //World*View*Proj Matrix
VertexShaderConstant[95] = <matMtl>;


//range constant
VertexShaderConstant[33] = (0.01f, 0.5f, 0.05f, 0.0f);

Texture[0] = <mtlSkin1>; //projection tex
Texture[1] = <entSkin1>; //projection tex

AddressU[0] = Clamp; // don't wrap around edges
AddressV[0] = Clamp;
AddressU[1] = Clamp; // don't wrap around edges
AddressV[1] = Clamp;

zWriteEnable=true; // enables writing to the z-buffer
//AlphaBlendEnable=true; // disables alpha blending
//srcblend=destcolor;
//destblend=one;


VertexShader=
dcl_position v0 // updated from DX8
dcl_normal v3 // updated from DX8
dcl_texcoord0 v7 // updated from DX8
dcl_texcoord1 v8 // updated from DX8
asm
{
vs.1.1

; position in clip space
m4x4 oPos, v0, c8

; position in texture projection space
m4x4 r10,v0,c95

; Divide each component by the range value
mul r10, r10, c33.x

; multiply with 0.5 and add 0.5
mad r10, r10, c33.yyyy, c33.yyyy

; map the x and y components into the first texture
mov oT0.xy, r10.xy

mov oT1.xy, v7.xy; color

};

PixelShader=
asm
{

ps.1.1

tex t0
tex t1

mov r0,t0
mul r0,r0,t1
};
}

}
";
}

function light_data()
{

if event_type==event_detect && my.skill4 == 6666 //projector
{

your.material=mat_projection;
//you.skill100=6666;
//texture projection matrix
you.skill80=my.skill80;
you.skill81=my.skill81;
you.skill82=my.skill82;
you.skill83=my.skill83;

you.skill84=my.skill84;
you.skill85=my.skill85;
you.skill86=my.skill86;
you.skill87=my.skill87;

you.skill88=my.skill88;
you.skill89=my.skill89;
you.skill90=my.skill90;
you.skill91=my.skill91;

you.skill92=my.skill92;
you.skill93=my.skill93;
you.skill94=my.skill94;
you.skill95=my.skill95;

// return;
}

}

function light_view_matrix()
{

//temporary matrix to store view matrix
vec_set(camera.x,my.x);
vec_set(camera.pan,my.pan);

wait(1);

mat_set(tempmatrix,matView);

my.skill80=tempmatrix[0];
my.skill81=tempmatrix[1];
my.skill82=tempmatrix[2];
my.skill83=tempmatrix[3];

my.skill84=tempmatrix[4];
my.skill85=tempmatrix[5];
my.skill86=tempmatrix[6];
my.skill87=tempmatrix[7];

my.skill88=tempmatrix[8];
my.skill89=tempmatrix[9];
my.skill90=tempmatrix[10];
my.skill91=tempmatrix[11];

my.skill92=tempmatrix[12];
my.skill93=tempmatrix[13];
my.skill94=tempmatrix[14];
my.skill95=tempmatrix[15];

}

ACTION lightobject
{
MY.passable=ON;
MY.shadow=OFF;
my.flare=off;
my.transparent=off;
my.invisible=on;
my.enable_detect=on;
my.event=light_data;

my.skill100=lighttimer;
lighttimer+=1;

if my.skill4==6666 //is a projector
{
wait(my.skill100);

light_view_matrix();

while(1)
{

temp.pan = 360;
temp.tilt = 360;
temp.z = 220;
//indicator=NULL;
scan_entity(my.x,temp);
wait(1);
}
}
}




with kind regards and TIA,


Formerly known as dennis_fantasy
Portfolio - http://www.designorhea.com/
Project - http://randomchance.cherrygames.org/
Re: projection shader [Re: Helghast] #42495
03/14/05 14:29
03/14/05 14:29
Joined: Jan 2004
Posts: 3,023
The Netherlands
Helghast Offline OP
Expert
Helghast  Offline OP
Expert

Joined: Jan 2004
Posts: 3,023
The Netherlands
<BUMP>

doesnt anyone know??

</BUMP>


Formerly known as dennis_fantasy
Portfolio - http://www.designorhea.com/
Project - http://randomchance.cherrygames.org/
Re: projection shader [Re: Helghast] #42496
03/14/05 16:48
03/14/05 16:48
Joined: Oct 2003
Posts: 4,131
M
Matt_Aufderheide Offline
Expert
Matt_Aufderheide  Offline
Expert
M

Joined: Oct 2003
Posts: 4,131
Yes i wrote that shader.. hold on lemme fix it

Re: projection shader [Re: Helghast] #42497
03/14/05 16:55
03/14/05 16:55
Joined: Oct 2003
Posts: 4,131
M
Matt_Aufderheide Offline
Expert
Matt_Aufderheide  Offline
Expert
M

Joined: Oct 2003
Posts: 4,131
ok try this.. i think i've fixed it, but if it doesnt work let me know what error it gives you and i will fix it..(to busy to test it myself right now)


Code:

material mat_projection
{

skin1 = projectiontex;

event = mat_projection_init;

flags = tangent;
effect =
"

texture mtlSkin1; //projector
texture entSkin1; //colormap
matrix matWorldViewProj;
matrix matWorld;
matrix matMtl;

technique projector
{

pass p0 //projector
{

//load matrices
VertexShaderConstant[0] = <matWorld>; //World Matrix
VertexShaderConstant[8] = <matWorldViewProj>;
VertexShaderConstant[95] = <matMtl>;

//range constant
VertexShaderConstant[33] = {0.01f, 0.5f, 0.05f, 0.0f};

Texture[0] = <mtlSkin1>; //projection tex
Texture[1] = <entSkin1>; //projection tex

AddressU[0] = Clamp; // don't wrap around edges
AddressV[0] = Clamp;
AddressU[1] = Clamp; // don't wrap around edges
AddressV[1] = Clamp;

zWriteEnable=true; // enables writing to the z-buffer

VertexShader=

asm
{
vs_1_1

dcl_position v0
dcl_normal v3
dcl_texcoord0 v7
dcl_texcoord1 v8

; position in clip space
m4x4 oPos, v0, c8

; position in texture projection space
m4x4 r10,v0,c95

; Divide each component by the range value
mul r10, r10, c33.x

; multiply with 0.5 and add 0.5
mad r10, r10, c33.yyyy, c33.yyyy

; map the x and y components into the first texture
mov oT0.xy, r10.xy

mov oT1.xy, v7.xy; color

};

PixelShader=
asm
{

ps_1_1

tex t0
tex t1

mov r0,t0
mul r0,r0,t1
};
}

}
";
}




Re: projection shader [Re: Helghast] #42498
03/15/05 06:47
03/15/05 06:47
Joined: Jan 2004
Posts: 1,398
North from here...
BlindLeader Offline
Senior Developer
BlindLeader  Offline
Senior Developer

Joined: Jan 2004
Posts: 1,398
North from here...
What does this shader do?
I understand allmost nothing...no just nothing...


"klar wird es unter dem einem oder anderem problem zu zusammenbrüchen kommen, aber solange die sonne keine 2 schaufeln rosinen bekommt, kann man alle lösen, augen zu machen, oder sich warmzittern"
Re: projection shader [Re: BlindLeader] #42499
03/15/05 07:02
03/15/05 07:02
Joined: Oct 2003
Posts: 4,131
M
Matt_Aufderheide Offline
Expert
Matt_Aufderheide  Offline
Expert
M

Joined: Oct 2003
Posts: 4,131
This shader and the related c-script code can project a texture onto models.. like a film projector.

Re: projection shader [Re: Helghast] #42500
03/15/05 15:10
03/15/05 15:10
Joined: Jan 2004
Posts: 3,023
The Netherlands
Helghast Offline OP
Expert
Helghast  Offline OP
Expert

Joined: Jan 2004
Posts: 3,023
The Netherlands
thanks, it seems to project onto me now, the only problem is, why o i get rendered balck fter stepping out of the mterial projection??

can that be fixed too??

regards,


Formerly known as dennis_fantasy
Portfolio - http://www.designorhea.com/
Project - http://randomchance.cherrygames.org/
Re: projection shader [Re: Helghast] #42501
03/15/05 17:29
03/15/05 17:29
Joined: Oct 2003
Posts: 4,131
M
Matt_Aufderheide Offline
Expert
Matt_Aufderheide  Offline
Expert
M

Joined: Oct 2003
Posts: 4,131
Well yes it will be black when you aren't in a projector because there is no standard lighting calculated in this shader.. the way to fix this is to add another pass with lighting in it. A quick fix is to use the lighting code from the Wiki terrain multitexture shader and put that into a second pass (in HLSL) rendered additively. The whole shader should probably be redone in HLSL, and you would really only need one pass in ps2.0 ..If you have no idea what i mean then maybe someone else can make the relevant changes, i'm too busy- sorry.


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