Jump to content


Re-Help Me Reedbeta!!! ;)


9 replies to this topic

#1 mysticman

    Member

  • Members
  • PipPip
  • 95 posts

Posted 01 July 2005 - 05:13 PM

I am trying to create a vertex/fragment shader that implements the offset-mapping
I have followed various forum for to document me and I have tried.
I now want to ask you, it is normal that if I go near too much me to the wall (I speak of a bsp)
do the bricks that are in relief have an effect soft pudding Posted Image?
If then I put the vision in third person, rotating the camera to the right-left, the tiles follow
the camera instead of being verse the normal of the wall!

What am I being wrong, or thing I have not understood?
Thanks!


vertex program:
!!ARBvp1.0
#================================================================
# shader_BOFFG_vp.s - Diffuse+Bump+Height+Gloss+Specular
#================================================================
# Copyright (C) 2005 - Frank Mikero.
# aka Typhontaur.
#================================================================
# This program is free software. You can redistribute it and/or
# modify it under the terms of the GNU General Public License.
# See the GNU General Public License for more details. You
# should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software:
# Foundation, Inc.59 Temple Place Suite 330,Boston,MA 02111-1307,
# USA.
#================================================================

OPTION ARB_position_invariant;

#===============================================
OUTPUT output = result.color;

#===============================================
ATTRIB attr_TexCoord0 = vertex.attrib[8];
ATTRIB attr_VertexPos = vertex.position;
ATTRIB attr_Tangent = vertex.attrib[6];
ATTRIB attr_Binormal = vertex.attrib[7];
ATTRIB attr_Normal = vertex.normal;

#===============================================
PARAM u_view_origin = program.env[0];
PARAM u_light_origin = program.env[1];

#===============================================
OUTPUT var_texCoord = result.texcoord[1];
OUTPUT var_lightVec = result.texcoord[2];
OUTPUT var_viewVec = result.texcoord[3];

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

#===============================================
TEMP lightVec, viewVec;

#===============================================
# ASSEMBLY CODE
#===============================================
DP4 var_texCoord.x, texMatrix[0], attr_TexCoord0;
DP4 var_texCoord.y, texMatrix[1], attr_TexCoord0;
DP4 var_texCoord.z, texMatrix[2], attr_TexCoord0;
DP4 var_texCoord.w, texMatrix[3], attr_TexCoord0;

SUB lightVec.xyz, u_light_origin, attr_VertexPos;
SUB viewVec.xyz, u_view_origin, attr_VertexPos;

DP3 var_lightVec.x, attr_Tangent, lightVec;
DP3 var_lightVec.y, attr_Binormal, lightVec;
DP3 var_lightVec.z, attr_Normal, lightVec;

DP3 var_viewVec.x, attr_Tangent, viewVec;
DP3 var_viewVec.y, attr_Binormal, viewVec;
DP3 var_viewVec.z, attr_Normal, viewVec;

MOV output, vertex.color;

#===============================================
END # end of program
#===============================================

fragment program:
!!ARBfp1.0
#================================================================
# shader_BOFFG_fp.s - Diffuse+Bump+Height+Gloss+Specular
#================================================================
# Copyright (C) 2005 - Frank Mikero.
# aka Typhontaur.
#================================================================
# This program is free software. You can redistribute it and/or
# modify it under the terms of the GNU General Public License.
# See the GNU General Public License for more details. You
# should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software:
# Foundation, Inc.59 Temple Place Suite 330,Boston,MA 02111-1307,
# USA.
#================================================================

OPTION ARB_precision_hint_fastest;
#OPTION ARB_precision_hint_nicest;

#===============================================
OUTPUT output = result.color;
TEMP base, bump, gloss, lVect, viewV, atten;
TEMP diffuse, specular, temp, invLen;
TEMP height, newtexcoord;

#===============================================
PARAM u_specular_exponent = program.env[6];
PARAM u_specular_scale = program.env[7];
PARAM u_ambient = program.env[15];
PARAM u_attparams = program.local[0];

#===============================================
PARAM m_one = {-1.0, -1.0, -1.0, -1.0 };
PARAM two  = { 2.0, 2.0, 2.0, 2.0 };

#===============================================
ATTRIB var_texCoord = fragment.texcoord[1];
ATTRIB var_lightVec = fragment.texcoord[2];
ATTRIB var_viewVec = fragment.texcoord[3];

#===============================================
# ASSEMBLY CODE
#===============================================

#===============================================
# Normalize view vector
#===============================================
DP3 temp,  var_viewVec, var_viewVec;
RSQ invLen, temp.x;
MUL viewV, var_viewVec, invLen;


TEX height, var_texCoord, texture[2], 2D;
MAD height, height, 0.04, -0.02; # scale and bias

MAD newtexcoord, height, viewV, var_texCoord;

TEX base, newtexcoord, texture[0], 2D;
TEX bump, newtexcoord, texture[1], 2D;
TEX gloss, newtexcoord, texture[3], 2D;

#===============================================
# Scale and bias
#===============================================
MAD bump, bump, two, m_one;

#===============================================
# Post-filter normalisation of bumpmap
#===============================================
DP3 temp,  bump, bump;
RSQ invLen, temp.x;
MUL bump,  bump, invLen;

#===============================================
# Normalize light vector
#===============================================
DP3 temp,  var_lightVec, var_lightVec;
RSQ invLen, temp.x;
MUL lVect, var_lightVec, invLen;

#===============================================
# Attenuation
#===============================================
DST atten, temp, invLen;
DP3 atten, atten, u_attparams;
RCP atten, atten.x;

#===============================================
# Diffuse
#===============================================
DP3_SAT	diffuse, lVect, bump;

#===============================================
# Reflection vector
#===============================================
DP3 temp, lVect, bump;
MUL temp, temp, two;
MUL temp, temp, bump;
SUB lVect, temp, lVect;

#===============================================
# Specular
#===============================================
DP3_SAT	specular, lVect, viewV;

#===============================================
# Specular ^ specExp
#===============================================
LG2 temp, specular.x;
MUL temp, temp, u_specular_exponent;
EX2 specular, temp.x;
MUL specular, specular, gloss;

#===============================================
# Ambient*Base+(Diffuse*Base+u_specular_scale*
# Specular) * Attenuation
#===============================================
MUL temp, specular, u_specular_scale;
MAD diffuse, diffuse, base, temp;
MUL temp, base, u_ambient; 

MAD output, diffuse, atten, temp;


#===============================================
END # end of program
#===============================================
Posted Image
Posted Image
:blush:

#2 Reedbeta

    DevMaster Staff

  • Administrators
  • 4976 posts
  • LocationBellevue, WA

Posted 01 July 2005 - 07:31 PM

Yup, that is a normal effect. It's just something that goes along with offset mapping. I discovered a way you can improve it (see this page for details), but there is still swimming when you get close to the surface. No way to get around this, except to use smooth (not steep) bump maps. On higher-end hardware relief mapping is possible, which solves this issue but is quite a bit slower.
reedbeta.com - developer blog, OpenGL demos, and other projects

#3 mysticman

    Member

  • Members
  • PipPip
  • 95 posts

Posted 01 July 2005 - 08:51 PM

10x! Reed!

You are a friend! :happy:

I was afraid to be imbecile me :wacko:

#4 Dia

    DevMaster Staff

  • Administrators
  • 1097 posts

Posted 01 July 2005 - 11:54 PM

Reedbeta: the effect he's getting doesn't look normal to me. His images seem to suffer from major distortion at distances away from the view direction.

It could be that your tangent space transformation is incorrect. Try inverting your binormal vector (i.e. using -attr_Binormal) and see if that fixes it.

#5 Reedbeta

    DevMaster Staff

  • Administrators
  • 4976 posts
  • LocationBellevue, WA

Posted 02 July 2005 - 12:47 AM

Hmm...now that I look at it more closely, there does seem to be something weird going on with the floor. It's hard to tell without being able to see it in action. But yeah, try reversing the binormal - the orientation of the normal map can make a difference.
reedbeta.com - developer blog, OpenGL demos, and other projects

#6 mysticman

    Member

  • Members
  • PipPip
  • 95 posts

Posted 02 July 2005 - 07:40 AM

Boys, have saved me the life!!!!

offset correct
Posted Image
Posted Image

new code in vertex shader:
...
...
DP3 var_lightVec.x, attr_Tangent, lightVec;
DP3 var_lightVec.y, -attr_Binormal, lightVec;
DP3 var_lightVec.z, attr_Normal, lightVec;

DP3 var_viewVec.x, attr_Tangent, viewVec;
DP3 var_viewVec.y, -attr_Binormal, viewVec;
DP3 var_viewVec.z, attr_Normal, viewVec;
...
...


I now see a blue sky with angels dispersed above the clouds, I attentively look and from distant it seems me to perceive 2 particular angels, but yes.... but are them!!
Dia & Reedbeta!!!

:wub:

#7 mysticman

    Member

  • Members
  • PipPip
  • 95 posts

Posted 03 July 2005 - 08:01 PM

Shadows Volume
I have tried with "z-pass", I have tried with "Carmack z-fail", but I continue to have this problem: :sad:

Posted Image

I have also tried with glPolygonOffset, I get a good result but they are seen some small strips of the volume! :sad:

Posted Image

why? :blink:

I remember you that I use the shaders arb...

#8 Reedbeta

    DevMaster Staff

  • Administrators
  • 4976 posts
  • LocationBellevue, WA

Posted 04 July 2005 - 01:24 AM

Try using the back faces of the model, with winding reversed, for the front cap of the shadow volume.
reedbeta.com - developer blog, OpenGL demos, and other projects

#9 mysticman

    Member

  • Members
  • PipPip
  • 95 posts

Posted 04 July 2005 - 07:50 AM

ok, I am stupid, I applied polygon-offset to the process shadows, instead that to the model before... :blush: 10x Reed! :wink:

#10 mysticman

    Member

  • Members
  • PipPip
  • 95 posts

Posted 04 July 2005 - 08:01 AM

Posted Image
Posted Image

:rolleyes:





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users