problem with animated sprite shadows

Posted By: sivan

problem with animated sprite shadows - 09/16/15 12:46

Hi

I have just created a sprite animation shader using a few images (one for idle, one for walk) in grid arrangement:



Nearly everything works fine, except shadows, they are casting the shadow of the whole image:



I did not set the NOSHADER flag of the shadowmapping depth view, d3d_instancing is 0, so what could be the problem?

Thanks!
Posted By: Anonymous

Re: problem with animated sprite shadows - 09/16/15 13:24

Malice floats a guess, File name not correct, file has no frame number, engine assumes a non-animated sprite because of files set-up and file name. So animated sprites have to be horizontal strips with a frame number attached to name. If these are missing the engine should assume a none animated sprite. Then cast the shadow of the full image

Thanks for letting me guess. And I have no idea if that correct.
Mal
Posted By: sivan

Re: problem with animated sprite shadows - 09/16/15 13:45

yeah, indeed I could use 64*4096 (4096=64*8*8) pixel sized image strips...
single row sprite output is supported by Fragmotion but buggy (I use it to convert the animated 3D model into animated sprites simply), maybe I can merge the 8 rows...
Posted By: txesmi

Re: problem with animated sprite shadows - 09/16/15 16:03

You will need to compute the frame in the depth shader too. But there will be troubles if the shader is a view material as usually...

Do sprites face the depth view? If not, I guess you will need a solution in order to drop shadows when the camera and the sun are at 90 degrees of pan.

In any case, two different depth views could work: one for static entities and other for sprites, mixed into another view stage before shadow computation. But not cheap at all.
Posted By: Superku

Re: problem with animated sprite shadows - 09/16/15 17:44

The material could have the OVERRIDE flag set and use render events (ENABLE_TREE or whatever those are called) to switch to a special depth material when rendering via the depth view. Much cheaper than two separate depth views.
Posted By: sivan

Re: problem with animated sprite shadows - 09/16/15 20:06

thanks all.

I was simply surprised that it does not work as I expected, I just guessed some tricks are missing from the depth view...

and what do you think, would the same happen with a billboard model with an animated (shifted) skin?

I think I start with the simplest fastest version, i.e. using a one row animation per state (finally I figured out that I can export from Fragmotion an animation sequence corresponding to one angle fine in uniform arrangement, then a little script I just made can merge the 8 png/tga files), and I can set the entity->frame to desired animation and camera compensated angle easily. but I'm happy with that I could make this animation shader of the grid sprite anyway laugh

that OVERRIDE flag also looks interesting to play with, but I'm not really familiar with material events...
Posted By: Superku

Re: problem with animated sprite shadows - 09/17/15 06:28

Check the example 2 in the manual for material events: http://www.conitec.net/beta/amaterial_event.htm
It's rather simple yet sometimes the choice of correct flags (_TREE,_RENDER,...) can be a little confusing, or there may be stuff you cannot change in render events.
Posted By: sivan

Re: problem with animated sprite shadows - 09/17/15 11:56

1st test:
with a +64.tga sprite strip I get the same result, both with or without a entity shader (in case of the shader I set both the ent.frame and do proper UV animation in the shader).

I still have no idea how I could solve it by a material event, but I'm sure I want to avoid to use 2 depth views because it is a performance sensitive situation. indeed the billboard lod itself is made because of performance gaining.

the strange thing is that as I remember earlier with a simple +10 sprite sometimes I got good, sometimes similarly bad results...

moreover imo it should be supported by the engine without workarounds. maybe jcl can give a simple answer...

p.s.
I exceeded the file name length limit of 20 characters, but the same happens now with a short named file placed in the game folder.
Posted By: Superku

Re: problem with animated sprite shadows - 09/17/15 13:28

I can make you an example later today or tomorrow.

EDIT: Something like this (obv. untested):

Code:
VIEW* depth_view =
{
	...
}

MATERIAL* warrior_depth_mat =
{
  effect = "warrior_depth.fx";
  flags = AUTORELOAD;
}

MATERIAL* warrior_tex_mat =
{
  event = "warrior.fx";
  flags = AUTORELOAD;
}

var warrior_mat_event()
{
  if(render_view == depth_view)
  { 
    mtl = warrior_depth_mat;
    return 0;
  }
  mtl = warrior_tex_mat;
  
  return 0;
}

MATERIAL* warrior_mat =
{
  event = warrior_mat_event;
  flags = ENABLE_RENDER | OVERRIDE; // maybe try a different ENABLE_... flag here
}



Then your "warrior.fx" file is your current shader and the "warrior_depth.fx" contains a regular depth shader modified with your cropping shader where you just clip if transparent, return depth otherwise. The "samples" and the "code" folders in your Gstudio installation contain examples.
Posted By: sivan

Re: problem with animated sprite shadows - 09/17/15 19:52

many thanks, I think I have an idea what to do now laugh
Posted By: sivan

Re: problem with animated sprite shadows - 09/18/15 10:38

breaking news:
in the last 20-30 minutes I successfully implemented it!
thanks again for the help! the snipped above is just perfect laugh now I have to test and tweak performance only laugh
Posted By: Superku

Re: problem with animated sprite shadows - 09/18/15 10:44

Great! You're welcome.
© 2024 lite-C Forums