shadows
Blitz3D Forums/Blitz3D Programming/shadows
| ||
i finally got my realistic player shadow working. still a few bugs to iron out how the heck do i get the player shadow to align to one direction. right now , the player just drags it around with him, looks a bit weird obviously the shadow mesh is parented to the player, but it has to stay aligned also to a particular light source i tried using point entity , but this didn't work ie PointEntity shadowmesh,light1 |
| ||
How are you doing this shadow? Please give us an example of your code so that we can best judge how to approach it. I think you are wanting to allow the shadow to change with respect to lights in proximity. (Also, this would most likely include creating other shadows for multiple lightsources.) Just as a quick thought, and simplistic solution: Parent the shadow to a pivot located at and parented to, the main character's mesh Turn the pivot to point away from the light. Scale the shadow according to the EntityDistance between the character and the lightsource, using Sin/Cos even to determine the ratio of the dimensions for the scaling. |
| ||
"obviously the shadow mesh is parented to the player, but it has to stay aligned also to a particular light source" Which is why you DON'T parent the shadow mesh to the player. Just use commands like EntityX to move the shadow mesh along with the player every frame. And move the shadow after UpdateWorld to take collisions into account. |
| ||
ooh sounds complicated. i will mess around with it and get back, cheers BTW i am doing the shadow with flex, but am going for the more realistic shadow using a second camera and renderworld. I am hiding everything but the player model and rendering from above and behind the player, copying that to the texture buffer then to the flex mesh( based on most of the shadow stuff in the archives) I don't want to use multiple light sources, just one 'sun'.I just want it looking good enough not to look wrong if you get my meaning. i see what you mean with the parenting though, sounds obvious when someone points it out.The shadow mesh is just inheriting the player models rotation. duh |
| ||
cool, that worked great using x#=EntityX(player):y#=EntityY(player):z#=EntityZ(player) PositionEntity shadowmesh,x,y,z Thanks for the tip |
| ||
Sorry, I thought you wanted to rotate the shadow as the character passed a lightsource! (Quite complicated stuff) No, you'll be fine with the above for a static sun! |
| ||
yeah , that sounds great, but a bit beyond me right now. I was pleased to get this far he he Another problem i am having is that i need to apply a texture to my player model temporarily, then revert to its previous default textures. The problem is that my player has 4 textures( multi sub )How do I unflag the temp texture wihtout having to use entity texture again. Entity texture just expects one texture I could redesign my player to have one texture, but frankly I don't want to |
| ||
its ok i sorted that out. bizzarely by loading the first texture and doing this torso=LoadTexture ("models\torso.tga") EntityTexture Player,torso,torso it then defaults to the multiskinned texture. Don't know why this works, it just does |