webGL
by Ice2642. 11/17/25 21:27
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
projected textures?
#32268
08/25/04 02:01
08/25/04 02:01
|
Joined: Oct 2003
Posts: 4,131
Matt_Aufderheide
OP
Expert
|
OP
Expert
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: Orange Brat]
#32272
08/25/04 08:09
08/25/04 08:09
|
Joined: Oct 2003
Posts: 4,131
Matt_Aufderheide
OP
Expert
|
OP
Expert
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
|
|
|
|