Horde3D http://horde3d.org/forums/ |
|
Skinning Artifacts http://horde3d.org/forums/viewtopic.php?f=2&t=1602 |
Page 1 of 1 |
Author: | dazza007 [ 02.12.2011, 14:04 ] |
Post subject: | Skinning Artifacts |
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 Cheers Darrin |
Author: | dazza007 [ 07.12.2011, 23:51 ] |
Post subject: | Re: Skinning Artifacts |
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 |
Author: | worstplayer [ 31.05.2012, 19:14 ] |
Post subject: | Re: Skinning Artifacts |
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 . EDIT2: everything seems to work OK when the model has only one bone. |
Author: | worstplayer [ 02.06.2012, 18:59 ] |
Post subject: | Re: Skinning Artifacts |
PROGRESS! If I put this in the vertex shader: Code: pos.w=1.0; visual distortion exactly follows distortion in g-buffer positiongl_Position =viewProjMat *normalize( pos); So, quick and dirty workaround would be putting this somewhere into VS_GENERAL and VS_SHADOWMAP: Code: pos.xyz/=pos.w; This works well enough but i'm sure there's a better way to solve this.
pos.w=1.0; |
Author: | MistaED [ 03.06.2012, 10:04 ] |
Post subject: | Re: Skinning Artifacts |
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? |
Author: | worstplayer [ 03.06.2012, 12:10 ] |
Post subject: | Re: Skinning Artifacts |
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. |
Page 1 of 1 | All times are UTC + 1 hour |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |