Jump to content
  • Advertisement

finalcut

Member
  • Content Count

    6
  • Joined

  • Last visited

Community Reputation

122 Neutral

About finalcut

  • Rank
    Newbie
  1. finalcut

    Facial Animation

    thnks for the reply.very helpful
  2. I want to do a little project on facial animation.I've found several papers on the net covering the theory,and i was wondering if anyone knows any source(site,book) covering implementation too(preferably in Direct3D).I've seen some examples that use interpolation between different poses,though i was interested in having control points on the face and applying some deformation algorithm.
  3. finalcut

    ShadowMaps looking bad

    Thanks for the reply..I was dividing the projected vertex with the w component at the vertex shader...i changed it and did it in the pixel shader before the sampling and works a lot better...Anyway thanks again
  4. I'm trying to implement shadow using shadowmaps in direct3d using vertex,pixel shaders.While it works ,the results are quite bad..First of all when the light is near an object a lot of noise occurs around the object,the shadow starts a bit far away from the object and also i get i small shadow in 'negative' as you can see in the pics..The problems become apparent from the time i position the light where you can already see the shadows..Any suggestions?I have tried various values for the SHADOW_EPSILON(when comparing the depth from the shadow map to the current z-value)but doesn't seem to improve anything.. From light's point of view Camera's view Here's the effect file #define SHADOW_EPSILON 0.00005f #define SMAP_SIZE 1024 float4x4 g_worldViewProjectionMatrix4x4, g_worldLightViewLightProjectionMatrix4x4; texture g_shadowMapTexture; sampler g_shadowMapSampler = sampler_state { texture = <g_shadowMapTexture>; }; texture g_modelTexture; sampler g_modelTextureSampler = sampler_state { texture = <g_modelTexture>; MinFilter = Linear; MagFilter = Linear; }; void LightDepthVertexShader( in float4 iPos : POSITION,in float4 iColor : COLOR,in float2 iTex[3] : TEXCOORD,out float4 oPos : POSITION,out float2 oTex[3] : TEXCOORD,out float2 oDepth : TEXCOORD3) { oPos = mul(iPos, g_worldLightViewLightProjectionMatrix4x4); oDepth = oPos.zw; oTex = iTex; } void LightDepthPixelShader(in float2 iDepth : TEXCOORD3,out float4 oColor : COLOR) { oColor = iDepth.x/iDepth.y; } void RenderSceneVertexShader(in float4 iPos : POSITION,in float4 iColor : COLOR, in float2 iTex[3] : TEXCOORD,out float4 oPos : POSITION,out float4 oColor : COLOR,out float4 oPosLightProj : TEXCOORD3,out float2 oTex[3] : TEXCOORD) { oPos=mul(iPos, g_worldViewProjectionMatrix4x4); oColor = iColor; oTex = iTex; oPosLightProj = mul(iPos,g_worldLightViewLightProjectionMatrix4x4); oPosLightProj.xy/=oPosLightProj.w; oPosLightProj.z/=oPosLightProj.w; oPosLightProj.w /=oPosLightProj.w; } void RenderScenePixelShader(in float4 iColora : COLOR,in float4 oPosLightProj : TEXCOORD3,in float2 oTex[3] : TEXCOORD,out vector oColor : COLOR) { oColor = iColora*tex2D(g_modelTextureSampler, oTex[0])*2; float2 shadowMapLookUpCoords = 0.5 * oPosLightProj.xy + 0.5; shadowMapLookUpCoords.y = 1 - shadowMapLookUpCoords.y; float zvalue = tex2D(g_shadowMapSampler,shadowMapLookUpCoords ); float currentz = oPosLightProj.z; if(shadowMapLookUpCoords.x <0 ||shadowMapLookUpCoords.x>1||shadowMapLookUpCoords.y<0||shadowMapLookUpCoords.y<0){ oColor =oColor*0.3; } else if((zvalue+SHADOW_EPSILON) <(currentz)){ oColor =oColor*0.7; } } technique ShadowMap { pass P0 { VertexShader = compile vs_2_0 LightDepthVertexShader(); PixelShader = compile ps_2_0 LightDepthPixelShader(); } pass P1 { VertexShader = compile vs_2_0 RenderSceneVertexShader(); PixelShader = compile ps_2_0 RenderScenePixelShader(); } }
  5. Thanks for the reply.I changed the memory management a bit and seems to be working smooth.I guess that was it :)
  6. hello, i'm making a pac man game and was just fine until i reached the AI part .The buggy code is below.Program stops execution and the classic windows message appears.The thing is that this happens at total random times(at least this is how i see it :) ).So i started printfing in files output from pointers that would potentially lead to memory violation but the output seems to be ok.Another thing is that the program crashes immediatly when i run it on any other pc ,same platform.I'm quite frustated.Logically there must be a strike out error of mine,i just can't locate it.While not calling AI::progress works fine.Any help would be very helpful Thank you in advance // PacMan * pm is public. terrain in memeber of Class AI struct node{ int f; int g; int h; int parentx,parenty; int x,y; int GetF(){ return f; } bool operator <(const node & b)const{ return f<b.f; } node(int _x,int _y):x(_x),y(_y){} node(){} }; struct coord { public: int x,y; bool operator < (const coord &b)const{ return y*29+x<b.y*29+b.x; } bool operator > (const coord &b)const{ return x>b.x && y>b.y; } bool operator == (const coord &b)const{ return x==b.x && y==b.y; } coord(int a,int b):x(a),y(b){ } }; typedef std::map <coord,node> list; struct list_iter { typedef list::value_type T; bool operator()(T const& a, T const & b) { return a.second < b.second; } }; void AI::Progress(){ int tx,ty,r,x=0,y=0,n1,ts; node * ntmp,*curr; coord * ctmp; FILE *fp; tx=ghost->tmp1; ty=ghost->tmp; list open; list close; list::iterator ii ,ii1; int n2=0; bool search=true; if(terrain[ty][tx]==-2 && ghost->counter ==0 ){ tx=ghost->tmp1; ty=ghost->tmp; ntmp =new node(tx,ty); ntmp->parentx=-1; ntmp->parenty=-1; ntmp->f=0; ntmp->g=0; ctmp=new coord(tx,ty); open[*ctmp]=*ntmp; while(search){ ii=min_element(open.begin(),open.end(),list_iter()); assert(ii!=open.end()); assert(ii->first.x<26 &&ii->first.y<29); ctmp = new coord(ii->first.x,ii->first.y); ntmp=new node(ii->second.x,ii->second.y); ntmp->f = ii->second.f; ntmp->g = ii->second.g; ntmp->parentx=ii->second.parentx; ntmp->parenty=ii->second.parenty; curr=ntmp; close[*ctmp]=*ntmp; if(ii->first.x==pm->mapX &&ii->first.y==pm->mapY){ search=false; break; } delete &ii->first; delete &ii->second; open.erase(ii); //Debug code check both lists not empty and valid content fp=fopen("debug.txt","w"); fprintf(fp,"OPEN \n \n"); for(ii1=open.begin();ii1!=open.end();++ii1) fprintf(fp,"X1 %d Y1%d X2 %d Y2 %d PX %d PY %d F %d \n",ii1->first.x,ii1->first.y,ii1->second.x,ii1->second.y,ii1->second.parentx,ii1->second.parenty,ii1->second.f); fprintf(fp,"CLOSE\n\n"); for(ii1=close.begin();ii1!=close.end();++ii1) fprintf(fp,"X1 %d Y1%d X2 %d Y2 %d PX %d PY %d F %d \n",ii1->first.x,ii1->first.y,ii1->second.x,ii1->second.y,ii1->second.parentx,ii1->second.parenty,ii1->second.f); fprintf(fp,"\n\n PM %d %d",pm->mapX,pm->mapY); fclose(fp); if(curr->x<25 && (n1=terrain[curr->y][curr->x+1])!=-1) check2(&open,&close,curr,n1,0,PacRight); if(curr->x>0 && (n1=terrain[curr->y][curr->x-1])!=-1) check2(&open,&close,curr,-n1,0,PacLeft); if(curr->y<28 && (n1=terrain[curr->y+1][curr->x])!=-1) check2(&open,&close,curr,0,n1,PacDown); if(curr->y>0 && (n1=terrain[curr->y-1][curr->x])!=-1) check2(&open,&close,curr,0,-n1,PacUp); } n1=100; if(curr!=NULL){ while(n1-- >0){ ii= close.find(coord(curr->parentx,curr->parenty)); assert(ii!=close.end()); if(ii->second.x==tx && ii->second.y ==ty){ x=curr->x-tx; y=curr->y-ty; if(x >0){ r=PacRight; x=1; } else if(x <0){ r=PacLeft; x=-1; } else if(y >0) { r=PacDown; y=1; } else if(y <0){ r=PacUp; y=-1; } break; } curr=&ii->second; } } //Debug code it reaches here succesfully and correct data fp=fopen("debug3.txt","w"); fprintf(fp,"%d %d %d %d\n \n",curr->x,curr->y,tx,ty); fclose(fp); if(n1==0)allegro_message("Need More"); for(ii=open.begin();ii!=open.end();++ii){ delete &ii->first; delete &ii->second; open.erase(ii); } for(ii=close.begin();ii!=close.end();++ii){ delete &ii->first; delete &ii->second; close.erase(ii); } ghost->mapY=ghost->tmp; ghost->mapX=ghost->tmp1; if(r==PacDown){if(ty<28){x=0;y=1;}} if(r==PacUp){if(ty>0){x=0;y=-1;}} if(r==PacLeft){if(tx>0){x=-1;y=0;}} if(r==PacRight){if(tx<25){x=1;y=0;}} ghost->counter=(terrain[ty+y][tx+x])*20; if(r==PacDown){frB->Start(ghost,frD1,i-1);} if(r==PacUp){frB->Start(ghost,frU1,i-1);} if(r==PacLeft){frB->Start(ghost,frL1,i-1);} if(r==PacRight){frB->Start(ghost,frR1,i-1);} if(y<0) ghost->tmp=ty-terrain[ty+y][tx]; else if(y>0) ghost->tmp=ty+terrain[ty+y][tx]; else if(x>0) ghost->tmp1=tx+terrain[ty][tx+x]; else if(x<0) ghost->tmp1=tx-terrain[ty][tx+x]; //Debug code reaches here too fp=fopen("debug1.txt","w"); fprintf(fp,"YES \n \n"); fclose(fp); } [Edited by - finalcut on January 30, 2007 11:27:19 AM]
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!