Horde3D

Next-Generation Graphics Engine
It is currently 28.04.2024, 16:32

All times are UTC + 1 hour




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Skinning Artifacts
PostPosted: 02.12.2011, 14:04 
Offline

Joined: 29.10.2011, 01:33
Posts: 8
Hi All,
Struck a few issues with Skinned characters.
Hoping someone can look at the below image - and tell me what I am doing wrong
The shadow mapping is all wrong when using the skinned flag, when i dont use it - the shadows are fine

Image

Cheers
Darrin


Top
 Profile  
Reply with quote  
 Post subject: Re: Skinning Artifacts
PostPosted: 07.12.2011, 23:51 
Offline

Joined: 29.10.2011, 01:33
Posts: 8
Well still no luck - however I have discovered something weird
- When the character is at world coordinates (0,0,0) and the camera not far off - everything looks fine
- the further the character gets away from 0,0,0 the worse the artifacting appears, you can actually see it degrade as you walk the character further away.
- it only appears to happen with shadow maps

- Any ideas, anyone? this has taken far too much time to try and isolate.

Cheers
D


Top
 Profile  
Reply with quote  
 Post subject: Re: Skinning Artifacts
PostPosted: 31.05.2012, 19:14 
Offline

Joined: 08.06.2010, 14:17
Posts: 63
Hello, I have same exact problem.

http://www.youtube.com/watch?v=Db4b6jw-1UI

Shadows appear OK when near the origin and get progressively more "screwy" as i move away.
This happens even when I don't move any bones, just adding skin flag is enough to trigger this.

EDIT: this is what gbuffer looks like: http://imgur.com/EpE6V

So, skinning outputs "wrong" position, and yet somehow the model is not visually distorted (but it affects lighting). I have absolutely no idea what's going on :shock: .

EDIT2: everything seems to work OK when the model has only one bone.


Top
 Profile  
Reply with quote  
 Post subject: Re: Skinning Artifacts
PostPosted: 02.06.2012, 18:59 
Offline

Joined: 08.06.2010, 14:17
Posts: 63
PROGRESS!

If I put this in the vertex shader:
Code:
pos.w=1.0;
gl_Position =viewProjMat *normalize( pos);
visual distortion exactly follows distortion in g-buffer position
Image

So, quick and dirty workaround would be putting this somewhere into VS_GENERAL and VS_SHADOWMAP:
Code:
pos.xyz/=pos.w;
pos.w=1.0;
This works well enough but i'm sure there's a better way to solve this.


Top
 Profile  
Reply with quote  
 Post subject: Re: Skinning Artifacts
PostPosted: 03.06.2012, 10:04 
Offline

Joined: 15.02.2009, 02:13
Posts: 161
Location: Sydney Australia
Ok here's the VS_SHADOWMAP pass:
Code:
[[VS_SHADOWMAP]]
// =================================================================================================
   
#include "shaders/utilityLib/vertCommon.glsl"
#include "shaders/utilityLib/vertSkinning.glsl"

uniform mat4 viewProjMat;
uniform vec4 lightPos;
attribute vec3 vertPos;
varying vec3 lightVec;

#ifdef _F05_AlphaTest
   attribute vec2 texCoords0;
   varying vec2 texCoords;
#endif

void main( void )
{
#ifdef _F01_Skinning   
   vec4 pos = calcWorldPos( skinPos( vec4( vertPos, 1.0 ) ) );
#else
   vec4 pos = calcWorldPos( vec4( vertPos, 1.0 ) );
#endif

#ifdef _F05_AlphaTest
   texCoords = texCoords0;
#endif

   lightVec = lightPos.xyz - pos.xyz;
   gl_Position = viewProjMat * pos;
}

Change it to look like:
Code:
[[VS_SHADOWMAP]]
// =================================================================================================
   
#include "shaders/utilityLib/vertCommon.glsl"
#include "shaders/utilityLib/vertSkinning.glsl"

uniform mat4 viewProjMat;
uniform vec4 lightPos;
attribute vec3 vertPos;
varying vec3 lightVec;

#ifdef _F05_AlphaTest
   attribute vec2 texCoords0;
   varying vec2 texCoords;
#endif

void main( void )
{
#ifdef _F01_Skinning
   mat4 skinningMat = calcSkinningMat();
   vec4 pos = calcWorldPos( skinPos( vec4( vertPos, 1.0 ), skinningMat ) );
#else
   vec4 pos = calcWorldPos( vec4( vertPos, 1.0 ) );
#endif

#ifdef _F05_AlphaTest
   texCoords = texCoords0;
#endif

   lightVec = lightPos.xyz - pos.xyz;
   gl_Position = viewProjMat * pos;
}

Does that fix the issue?

_________________
-Alex
Website


Top
 Profile  
Reply with quote  
 Post subject: Re: Skinning Artifacts
PostPosted: 03.06.2012, 12:10 
Offline

Joined: 08.06.2010, 14:17
Posts: 63
It didn't fix it by itself. The problem isn't only in VS_SHADOWMAP, but also in VS_GENERAL. In case of deferred lighting it puts wrong position into gbuffer.

The problem seems to come from vertSkinning.glsl, from this function:
Code:
vec4 skinPos( const vec4 pos, const mat4 skinningMat )
{
   return pos * skinningMat;
}


changing it to:
Code:
vec4 skinPos( const vec4 pos, const mat4 skinningMat )
{
   vec4 npos = pos * skinningMat;
   return vec4(npos.xyz/npos.w,1.0);
}

together with your change to VS_SHADOWMAP, finally made both casting and receiving shadows correct. Now, i don't understand exact mechanism of what's going on, but it seems that with skinning, pos.w isn't always exactly 1, so gl_Position=viewProjMat*pos still computes correct position, but things like lightVec=lightPos.xyz-pos.xyz don't.

EDIT: works in game http://www.youtube.com/watch?v=q99euNflHos , also going to test it with chicago guy and some other models.
EDIT2: Everything else works too.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 26 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group