how to make these kind shodow?


#1



These are not true shodows, just like a spotlights light to ground, how to make these shodows? The shodow in the first image also include a circle border, how to make it? [/img]


Making a circle decal on ground
Panda3d paged geometry?
#2

Make a texture with the shadow on it, put it on a plane using CardMaker, and put it flat on the ground under the object.


#3

That would work if the ground is perfectly flat, but what if it isn’t?


#4

I agree with Cyan. That solution works fine for completely flat terrain, but if it has any depth (like most situations) that solution won’t work.

The image would have to be projected I think.


#5

Hm, it’s not very hard to do it in CG… or at least with multitexturing…


#6

check out the manual page about projecting textures (and the pages before it too if you want it to make any sense).


#7

According to these method, I made a shdow using CardMaker, and make the ground flat, but when I set the card pos z coordinate to 0 same as the ground, the card didn’t cover the ground, the ground and the shadow card texture mixed, because ground and card z coordinate are all 0, when I set the card z coordinate to 0.1, it’s no problem, the card over the ground, but I think it’s not a appropriate way, How to let them has a same z coordinate, and shadow card can over the ground and cover it ?


#8

You can do that by setting the render order.

Try this out on your ground model:

ground.setBin('background',10)
ground.setDepthWrite(0)
ground.setDepthTest(0)

This will make the ground drawn behind everything else.


#9

pro i think he will still have z buffer artifacts what flyaflya was doing is the correct way only the .1 can be computed more sophisticated based on distance from the camera and lens close/far planes.


#10

If you want to use additional polygon, you might consider using DepthOffsetAttrib and DecalEffect.
But I like the multitexturing approach, at least it works for uneven terrain, and not limited by your graphics HW’s multitexture limit.

I created this tonight, and not optimized by any means. You just need to figure out the textures stacking system.
jon1.us/P3D/dropShadow/=UnlimitedMultitex1.zip


#11

new version :

  1. the dropShadow now projected from above (Z axis)
  2. added random movement
    jon1.us/P3D/dropShadow/=UnlimitedMultitex2.zip

Does anyone know the technique used in ToonTown ?


#12

Looks great ynjh_jo. Thank you for this script.
enn0x


#13

Bad news…
I guess now I’m limited by instructions limit ?
I couldn’t go beyond 14.

error C5041: cannot locate suitable resource to bind parameter “o_texcoord15”

[EDIT]
I just know that DX9 can bind 16 input textures and 4 output. I guess OGL simply the same ?
So the answer must be multipass ?


#14

ynjh_jo,

just use k_pos1 - k_pos100 and read them directly in the fragment step


#15

Of course it works, but it means I have to calc the texcoord on my own for every fragment. It’s slower than lerp’ing between vtx.
Here is the result : (still 9 avatars)
before (vShd->fShd passing) : 45 fps
after (directly in fShd) : 30 fps

it’s like this now:

  float4 t1=tex2D(tex_1, l_texcoord1*k_scalePos1.x+k_scalePos1.yz);
  float4 t2=tex2D(tex_1, l_texcoord1*k_scalePos2.x+k_scalePos2.yz);
  float4 t3=tex2D(tex_1, l_texcoord1*k_scalePos3.x+k_scalePos3.yz);

I tried to chop off this calc :

o_color.rgb = o_color.rgb*( 1-t1.a ) + t1.rgb*t1.a

to this :

o_color.rgb = o_color.rgb*( 1-t1.a ) + t1.rgb

by storing the rgb*a result in the texture’s rgb itself, but that only helps a little, only covering <50% performance hole to 36 fps.

Hmm, my broken spirit says : shading is not the correct way for doing this. I think geometric technique would be faster, as long as using quad/octree terrain, simply by collecting the nearby triangles around the collision point and texturize them, every frame. Just like Panda’s collision visualizer, but it’s not quite fast anyway.


#16

just chopped off this calc :

o_color.rgb = o_color.rgb*( 1-t.a) + t.rgb;

to this

o_color.rgb = o_color.rgb*t.a + t.rgb;

by inverting the texture’s alpha.

result :
9 avatars : 43 fps
20 avatars : 24 fps
jon1.us/P3D/dropShadow/=UnlimitedMultitex3.zip


#17

Thanks for all helping me, I will try all the methods you refered, when I get the best way, I will write the result here.


#18

Alright, this is a simple attempt of geometric approach, simply using octree to build it. Then at runtime, each ground geom would be checked for proximity to the avatar, if the geom is in avatar’s range, it’s get copied and textured.
jon1.us/P3D/dropShadow/=GeomDropShadow2.zip

9 avatars : 58 fps
20 avatars : 29 fps


#19

this is another one, with tree traversal. I hope I got it right, it’s a little slower.
jon1.us/P3D/dropShadow/=GeomDropShadow3.zip

5 avatars : 92 fps
9 avatars : 60 fps
20 avatars : 30 fps
40 avatars : 16 fps


#20

I’m sorry, terribly sorry. I made not much sense lately, too much tense here. I made some silly mistakes in the previous versions.
Here is the better one, but the tree traversal is too slow in Python.

jon1.us/P3D/dropShadow/=GeomDropShadow4.zip
5 avatars : 20 fps
9 avatars : 14 fps