Jump to content


Deluxemapping help...


5 replies to this topic

#1 mysticman

    Member

  • Members
  • PipPip
  • 95 posts

Posted 19 September 2005 - 07:48 AM

I am implementing the deluxemapping in qfusion-fx, but I have this problem:

Posted Image

Posted Image

Posted Image

that is 3 walls are correctly drawn, while the others 3 are wrong.
The shaders that I use are those of Tr3B.

vertex program

!!ARBvp1.0

#================================================================

ATTRIB attr_TexCoord0 = vertex.attrib[8];

ATTRIB attr_TexCoord1 = vertex.attrib[9];

ATTRIB attr_VertexPos = vertex.position;

ATTRIB attr_Tangent = vertex.attrib[6];

ATTRIB attr_Binormal = vertex.attrib[7];

ATTRIB attr_Normal = vertex.normal;


#================================================================

OUTPUT var_TexCoord0 = result.texcoord[1];

OUTPUT var_TexCoord1 = result.texcoord[2];

OUTPUT var_tangent = result.texcoord[3];

OUTPUT var_binormal = result.texcoord[4];

OUTPUT var_normal = result.texcoord[5];

OUTPUT var_viewVec = result.texcoord[6];

OUTPUT var_vertexPos = result.texcoord[7];


#================================================================

PARAM texMatrix0[4] = { state.matrix.texture[0] };

PARAM mvpMatrix[4] = { state.matrix.mvp };


#================================================================

	MOV var_vertexPos, attr_VertexPos;

	MOV var_tangent, attr_Tangent;

	MOV var_binormal, attr_Binormal;

	MOV var_normal, attr_Normal;

	

	DP4 result.position.x, mvpMatrix[0], attr_VertexPos;

	DP4 result.position.y, mvpMatrix[1], attr_VertexPos;

	DP4 result.position.z, mvpMatrix[2], attr_VertexPos;

	DP4 result.position.w, mvpMatrix[3], attr_VertexPos;


	DP4 var_TexCoord0.x, texMatrix0[0], attr_TexCoord0;

	DP4 var_TexCoord0.y, texMatrix0[1], attr_TexCoord0;

	DP4 var_TexCoord0.z, texMatrix0[2], attr_TexCoord0;

	DP4 var_TexCoord0.w, texMatrix0[3], attr_TexCoord0;

	

	DP4 var_TexCoord1.x, texMatrix0[0], attr_TexCoord1;

	DP4 var_TexCoord1.y, texMatrix0[1], attr_TexCoord1;

	DP4 var_TexCoord1.z, texMatrix0[2], attr_TexCoord1;

	DP4 var_TexCoord1.w, texMatrix0[3], attr_TexCoord1;

#================================================================

END

#================================================================


fragment program

!!ARBfp1.0

#================================================================

ATTRIB var_TexCoord0 = fragment.texcoord[1];

ATTRIB var_TexCoord1 = fragment.texcoord[2];

ATTRIB var_tangent = fragment.texcoord[3];

ATTRIB var_binormal = fragment.texcoord[4];

ATTRIB var_normal = fragment.texcoord[5];

ATTRIB var_viewVec = fragment.texcoord[6];

ATTRIB var_vertexPos = fragment.texcoord[7];


#================================================================

PARAM u_view_origin = program.local[2];

PARAM u_bump_scale = program.local[1];

PARAM u_specular_exponent = program.local[0];

PARAM c0 = {2, 0.5, 0, 0};


#================================================================

TEMP R0;

TEMP R1;

TEMP R2;

TEMP R3;


#================================================================

TEX R0.xyz, var_TexCoord1, texture[4], 2D;# deluxemap

TEX R1.xyz, var_TexCoord0, texture[1], 2D;# bumpmap

ADD R0.xyz, R0, -c0.y;

MUL R0.xyz, R0, c0.x;

ADD R1.xyz, R1, -c0.y;

MUL R1.xyz, R1, c0.x;

ADD R2.xyz, u_view_origin, -var_vertexPos;

DP3 R0.w, var_tangent, R2;

MOV R3.x, R0.w;

DP3 R0.w, var_binormal, R2;

MOV R3.y, R0.w;

DP3 R0.w, var_normal, R2;

MOV R3.z, R0.w;

DP3 R0.w, var_tangent, R0;

MOV R2.x, R0.w;

DP3 R0.w, var_binormal, R0;

MOV R2.y, R0.w;

DP3 R0.x, var_normal, R0;

MOV R2.z, R0.x;

DP3 R0.x, R3, R3;

RSQ R0.x, R0.x;

MUL R3.xyz, R0.x, R3;

MOV R0.xy, R1;

MUL R0.w, R1.z, u_bump_scale.x;

MOV R0.z, R0.w;

DP3 R0.w, R2, R2;

RSQ R0.w, R0.w;

MAD R3.xyz, R0.w, R2, R3;

MUL R2.xyz, R0.w, R2;

DP3 R0.w, R0, R0;

RSQ R0.w, R0.w;

MUL R0.xyz, R0.w, R0;

DP3_SAT R0.w, R0, R2;

DP3 R1.x, R3, R3;

RSQ R1.x, R1.x;

MUL R3.xyz, R1.x, R3;

DP3_SAT R0.x, R0, R3;

POW R0.x, R0.x, u_specular_exponent.x;

TEX R1.xyz, var_TexCoord1, texture[3], 2D;# lightmap

TEX R2, var_TexCoord0, texture[0], 2D;# diffusemap

MUL R3.xyz, R1, R0.w;

MUL R3.xyz, R2, R3;

MOV R2.xyz, R3;

TEX R3.xyz, var_TexCoord0, texture[2], 2D;# specularmap

MUL R1.xyz, R3, R1;

MAD R0.xyz, R1, R0.x, R2;

MOV R2.xyz, R0;

MOV result.color, R2;

#================================================================

END

#================================================================

Does someone know in thing I am being wrong?
Tangents and Binormals and Normals and all the other parameters are correct, as use them with dynamic lights.

Sorry for my bad english!

Thanks

#2 Reedbeta

    DevMaster Staff

  • Administrators
  • 4979 posts
  • LocationBellevue, WA

Posted 19 September 2005 - 04:17 PM

What is deluxe mapping?? I have never heard of this before, and Google doesn't know either.
reedbeta.com - developer blog, OpenGL demos, and other projects

#3 mysticman

    Member

  • Members
  • PipPip
  • 95 posts

Posted 19 September 2005 - 05:35 PM

HI! Reedbeta!!! :)

Posted Image

for info:
http://www.splashdam...a0d9015832e1ce9
http://www.shaderlab.com/q3map2/

;)

#4 mysticman

    Member

  • Members
  • PipPip
  • 95 posts

Posted 20 September 2005 - 03:02 PM

I have resolved!

Thanks!

#5 Reedbeta

    DevMaster Staff

  • Administrators
  • 4979 posts
  • LocationBellevue, WA

Posted 20 September 2005 - 05:15 PM

Cool, what was the problem?
reedbeta.com - developer blog, OpenGL demos, and other projects

#6 mysticman

    Member

  • Members
  • PipPip
  • 95 posts

Posted 20 September 2005 - 08:50 PM

the problem was not in the shaders, on the contrary in the loading of the deluxemaps and the construction of the same using a scale factor of 1.0/255.0. Other values brought out range. ;)

However you will see it to you, if you will want, when I will release the code in my forum...

Hi & thanks ;)





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users