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
1 registered members (TipmyPip), 18,449 guests, and 6 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
projected textures? #32268
08/25/04 02:01
08/25/04 02:01
Joined: Oct 2003
Posts: 4,131
M
Matt_Aufderheide Offline OP
Expert
Matt_Aufderheide  Offline OP
Expert
M

Joined: Oct 2003
Posts: 4,131
I am wondering if someone has a agood tutorial or an idea of how to do projected texture shader.. my attempt fails.. .. at least it only seems to work if facing one direction. This indicates to me im not using the correct projection matrix... any ideas?

Code:
				pass p1 
{

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

//light vector
VertexShaderConstant[12] = <vecSkill41>;

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

Texture[0] = <mtlSkin1>; //pointlight attenuation
Texture[1] = <mtlSkin1>; //pointlight alpha

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;

srcblend=srccolor;
destblend=one;
VertexShader=
decl
{
stream 0;
float v0[3]; //position
float v3[3]; //normal
float v7[3]; //uv
float v8[3]; //tangent
}
asm
{
vs.1.1

; position in clip space
m4x4 oPos, v0, c8

; position in world space
m4x4 r2, v0, c0

; get light vector
add r10, r2, -c12

; 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

; z-component v0
mov oT1.x, r10.z


};

PixelShader=
asm
{

ps.1.1
tex t0
tex t1

add r0, 1-t0, -t1.a

};
}



Re: projected textures? [Re: Matt_Aufderheide] #32269
08/25/04 02:44
08/25/04 02:44
Joined: Oct 2003
Posts: 4,131
M
Matt_Aufderheide Offline OP
Expert
Matt_Aufderheide  Offline OP
Expert
M

Joined: Oct 2003
Posts: 4,131
update: i got it work now but only for the world view matrix.. in other words.. it projects the texture from your camera point.. now i need to make it project from an arbitrary vector.


Sphere Engine--the premier A6 graphics plugin.
Re: projected textures? [Re: Matt_Aufderheide] #32270
08/25/04 04:55
08/25/04 04:55
Joined: May 2004
Posts: 43
J
JeremyB Offline
Newbie
JeremyB  Offline
Newbie
J

Joined: May 2004
Posts: 43
Did you update the code in your original post? Because I am having the same problem with it.

Re: projected textures? [Re: JeremyB] #32271
08/25/04 06:22
08/25/04 06:22
Joined: Aug 2000
Posts: 7,490
O
Orange Brat Offline

Senior Expert
Orange Brat  Offline

Senior Expert
O

Joined: Aug 2000
Posts: 7,490
Is this related to "projectors" as described here:

http://w1.312.telia.com/~u31225218/fc/effects.html

These project from dynamic lights.


My User Contributions master list - my initial post links are down but scroll down page to find list to active links
Re: projected textures? [Re: Orange Brat] #32272
08/25/04 08:09
08/25/04 08:09
Joined: Oct 2003
Posts: 4,131
M
Matt_Aufderheide Offline OP
Expert
Matt_Aufderheide  Offline OP
Expert
M

Joined: Oct 2003
Posts: 4,131
yes thats basiaclly what i am talking about. no i didnt update the code.. just change the shader to:

Code:
	pass p0
{

//load matrices
VertexShaderConstant[0] = <matWorld>; //World Matrix
VertexShaderConstant[8] = <matWorldViewProj>; //World*View*Proj Matrix
VertexShaderConstant[95] = <matWorldView>; //World*View Matrix
//light vector
VertexShaderConstant[12] = <vecSkill17>;

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

VertexShaderConstant[33] = (0.01f, 0.5f, 0.0f, 0.0f);

Texture[0] = <mtlSkin3>; //pointlight attenuation
Texture[1] = <mtlSkin3>; //pointlight alpha

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=false; // disables alpha blending

VertexShader=
decl
{
stream 0;
float v0[3]; //position
float v3[3]; //normal
float v7[3]; //uv
float v8[3]; //tangent
}
asm
{
vs.1.1

; position in clip space
m4x4 oPos, v0, c8

; position in world space
m4x4 r2, v0, c95



; get light vector
// add r10, r2, -c12

; Divide each component by the range value
// mul r10, r10, c33.x
mul r10,r2,c33.x
; multiply with 0.5 and add 0.5
mad r10, r10, c33.yyyy, c33.yyyy
mov oT0.xy,r10.xy

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

; z-component v0
mov oT1.x, r10.z


};

PixelShader=
asm
{

ps.1.1
tex t0
tex t1

add r0, 1-t0, -t1.a


};
}



now this as i said will only work using the camera as the "projector".. i still dont know the matrix math the get it work for a point light


Sphere Engine--the premier A6 graphics plugin.

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