Player Shadows onto DTS
by Phoenix Online Studios · in Torque Game Engine · 04/29/2005 (10:08 am) · 18 replies
Hello,
Is it possible to cast the player's shadow within TSStatic .DTS objects. I realise that by default shadows are only cast onto the terrain and .DIF's, but our scenes require detailed textures (i.e. non-tiling and larger than 512x512) so I cannot convert them entirely to .DIF. Currently, I am able to see the player shadow on the .DTS when it is flush-up against the terrain, but they don't always show up.
Does anyone know how to do this? I've considered making a transparent textured .DIF cube to put inside the scene, but I'm not sure if the engine or .DIFs can even support transparent .DIF textures. However, even if I can get this to work, it would only provide ground floor shadows and not shadows on other 3D surfaces within the .DTS.
If no one knows how to do this, could you please tell me which engine source files I should look at?
Thanks
Is it possible to cast the player's shadow within TSStatic .DTS objects. I realise that by default shadows are only cast onto the terrain and .DIF's, but our scenes require detailed textures (i.e. non-tiling and larger than 512x512) so I cannot convert them entirely to .DIF. Currently, I am able to see the player shadow on the .DTS when it is flush-up against the terrain, but they don't always show up.
Does anyone know how to do this? I've considered making a transparent textured .DIF cube to put inside the scene, but I'm not sure if the engine or .DIFs can even support transparent .DIF textures. However, even if I can get this to work, it would only provide ground floor shadows and not shadows on other 3D surfaces within the .DTS.
If no one knows how to do this, could you please tell me which engine source files I should look at?
Thanks
#2
Right now, I'm mostly concerned with getting the player's shadow to just show up on the ground. Then I'll figure out how to get it to adapt to the other collision meshes in the .DTS scene.
I'll check out that file now. If you know of any other techniques I can use, I'd be glad to hear them. I was considering making the terrain invisible and putting the scene's flooring slightly under the terrain, but unfortunately the terrain doesn't support transparent .png textures.
04/29/2005 (10:52 am)
Thanks! :)Right now, I'm mostly concerned with getting the player's shadow to just show up on the ground. Then I'll figure out how to get it to adapt to the other collision meshes in the .DTS scene.
I'll check out that file now. If you know of any other techniques I can use, I'd be glad to hear them. I was considering making the terrain invisible and putting the scene's flooring slightly under the terrain, but unfortunately the terrain doesn't support transparent .png textures.
#3
One quick and dirty hack comes up to my mind:
You could find the shapes that intersect the shadow projection box, and render those shapes again, along with the transparency-enabled shapes (using the sorting thingie), but using the shadow texture generated by Torque instead of it's own, using a projective UV mode (using the current shadow projection data) with texture wrapping turned off, and some Z-offset, to avoid z-fighting. Voil
04/29/2005 (11:30 am)
You'd better coding a different shadow method to get better results. The stock TGE dynamic shadow will be pretty hard to hack to project properly against .DTS files (but I think it might be doable to project it against the .DTS collision meshes).One quick and dirty hack comes up to my mind:
You could find the shapes that intersect the shadow projection box, and render those shapes again, along with the transparency-enabled shapes (using the sorting thingie), but using the shadow texture generated by Torque instead of it's own, using a projective UV mode (using the current shadow projection data) with texture wrapping turned off, and some Z-offset, to avoid z-fighting. Voil
#4
I really should have put this out there as a code snippet or resource a while back, but I guess I was just being greedy! haha...
Well, ok, here it is, in shadow.cc under the engine/game dir on line 17
replace the current line with this
There ya go then, Shadows casted onto Statics, Can obviously add other *.dts object types, but that there is just for statics... Shadows on them just as thought they are terrain, looks just fine...
Don't forget to recompile!!
This is 1.3 just to let ya know, don't know if it's diff in 1.4/5....
Ben, should I submit this as a resource or whatnot?... Just wondering :P
Max
04/29/2005 (11:40 am)
Hey guys, I really should have put this out there as a code snippet or resource a while back, but I guess I was just being greedy! haha...
Well, ok, here it is, in shadow.cc under the engine/game dir on line 17
replace the current line with this
U32 Shadow::smShadowMask = TerrainObjectType | InteriorObjectType | StaticShapeObjectType | StaticObjectType;
There ya go then, Shadows casted onto Statics, Can obviously add other *.dts object types, but that there is just for statics... Shadows on them just as thought they are terrain, looks just fine...
Don't forget to recompile!!
This is 1.3 just to let ya know, don't know if it's diff in 1.4/5....
Ben, should I submit this as a resource or whatnot?... Just wondering :P
Max
#5
That code works perfectly with my StaticShape objects! Unfortunately, it's not working with TSStatic objects. I tried adding two more masks to it: "StaticTSObjectType | StaticRenderedObjectType"; but they still don't show up.
I'm using 1.3 of the engine, and yes you should definitely submit it as a resource. :)
04/29/2005 (11:55 am)
Thanks Max!That code works perfectly with my StaticShape objects! Unfortunately, it's not working with TSStatic objects. I tried adding two more masks to it: "StaticTSObjectType | StaticRenderedObjectType"; but they still don't show up.
I'm using 1.3 of the engine, and yes you should definitely submit it as a resource. :)
#6
Will post as a resource later on...
Max
04/29/2005 (12:10 pm)
Hey, I'm glad it worked for you, I'm going to try and get it working with TSStatic objects now, also water and vehicles etc...Will post as a resource later on...
Max
#7
I just realised that they ARE showing up in my TSStatic objects! They're just appearing in the places I have collision meshes. That probably explains why they don't show up everywhere else in the .dts. Anyway, all that's required is for us to give everything a collision mesh.
Thanks again!
04/29/2005 (12:26 pm)
Hey Max,I just realised that they ARE showing up in my TSStatic objects! They're just appearing in the places I have collision meshes. That probably explains why they don't show up everywhere else in the .dts. Anyway, all that's required is for us to give everything a collision mesh.
Thanks again!
#8
Yeah, it only is cast on the collision meshes of the objects, I'm trying to get it to go through the collision and be cast on the polys of the mesh at the moment, not too easy, but should have it workin in a little while...
Naturally you can add the vehicle object type, the water object type, basically any object type... DO not have the plaper cast shadows onto other players though, it shadows from the payer onto it's own hitbox's.... So it looks kinda weird and doesn't work out whatsoever...
Max
04/29/2005 (12:33 pm)
Hey, Yeah, it only is cast on the collision meshes of the objects, I'm trying to get it to go through the collision and be cast on the polys of the mesh at the moment, not too easy, but should have it workin in a little while...
Naturally you can add the vehicle object type, the water object type, basically any object type... DO not have the plaper cast shadows onto other players though, it shadows from the payer onto it's own hitbox's.... So it looks kinda weird and doesn't work out whatsoever...
Max
#9
04/30/2005 (11:08 am)
Great catch Max!...makes me wonder tho: why these masks were not included before? have you noticed any performance or any other issues enabling them?
#10
Also Max, if you're able to get the shadows to cast onto the polys, please post in this thread to let me know. It would save us from having to create tons of shadow collision meshes. :)
04/30/2005 (11:22 am)
I didn't notice any performance hits after this fix. Looking strictly at FPS, they're both pretty much the same before and after.Also Max, if you're able to get the shadows to cast onto the polys, please post in this thread to let me know. It would save us from having to create tons of shadow collision meshes. :)
#11
Frankly, I have no idea why these masks wheren't included..
Also though, I think I have an idea of how to get the players shadow to cast through the collision mesh onto the actual polys of the object, as you both have probably noticed, the light from projectiles is cast through the collision mesh onto the actual polys of the object, so I think that if I find the time I'll write a new shadowing method for DTS objects...
Max
04/30/2005 (12:39 pm)
Hey, thanx guys.Frankly, I have no idea why these masks wheren't included..
Also though, I think I have an idea of how to get the players shadow to cast through the collision mesh onto the actual polys of the object, as you both have probably noticed, the light from projectiles is cast through the collision mesh onto the actual polys of the object, so I think that if I find the time I'll write a new shadowing method for DTS objects...
Max
#12
Any progress yet on that shadowscript on static DTS non-collision meshes?
Just anxious to know if you got round trying stuff :)
- Allert
Asst. Art Director
Unofficial King's Quest IX Development Team
http://www.kqix.com
07/12/2005 (3:31 pm)
Hey Max,Any progress yet on that shadowscript on static DTS non-collision meshes?
Just anxious to know if you got round trying stuff :)
- Allert
Asst. Art Director
Unofficial King's Quest IX Development Team
http://www.kqix.com
#13
Just read this thread. We're working on the same little problem as Pheonix here to get realistic shadows without doing all the added geometry for our DTS objects. If and when you get something working let us know k? I'll be making some changes to the code (those you suggested) for the time being while I'm working LOTs of other stuff.
Thanks a lot bud.
Sylien Entertainment Corporation www.sylien.com
Creators of "The Paradise Project". www.tpp-online.com
10/13/2005 (8:45 am)
Hey Max,Just read this thread. We're working on the same little problem as Pheonix here to get realistic shadows without doing all the added geometry for our DTS objects. If and when you get something working let us know k? I'll be making some changes to the code (those you suggested) for the time being while I'm working LOTs of other stuff.
Thanks a lot bud.
Sylien Entertainment Corporation www.sylien.com
Creators of "The Paradise Project". www.tpp-online.com
#14
My computers been down for a good while now, but got it back up and running recently. So I have a good bit of work to do yet, but if I find the time to get around to this and have it looking nice, I'll throw it up as a resource.
-Max
10/13/2005 (8:54 am)
Hey guys,My computers been down for a good while now, but got it back up and running recently. So I have a good bit of work to do yet, but if I find the time to get around to this and have it looking nice, I'll throw it up as a resource.
-Max
#15
It's not quite easy (lots of places to mess with), but it sounds doable.
10/27/2005 (7:19 am)
You could get the shadows to project on arbritrary DTS geometry by detecting which DTS objects intersect the shadow volume, then draw those objects again, but using the shadow texture instead, and setup a projected UV coordinate set using the shadow projection information. The meshes should be drawn with front-faces only, to minimize the fact that the shadow will be visible on the other side.It's not quite easy (lots of places to mess with), but it sounds doable.
#16
11/13/2005 (3:44 am)
Wow, that's so simple and it works.
#17
11/13/2005 (8:06 am)
@Ramen, I can see we have very different ideas of simple ;)
#18
11/30/2006 (10:54 pm)
Wow i have to try this.. thanks
Associate Kyle Carter