Why aren't these dynamic shadows UV-mapping right?
Blitz3D Forums/Blitz3D Programming/Why aren't these dynamic shadows UV-mapping right?
| ||
Edit: FIXED! STRIPPED-DOWN DYNAMIC SHADOW EXAMPLE Graphics3D 640,480,16,2 SetBuffer BackBuffer() cam=CreateCamera() CameraRange cam,1,10000 MoveEntity cam,0,20,-40 m=CreateCube();LoadMesh("swat.3ds") ScaleMesh m,1,10,1 PositionEntity m,0,8,0 EntityColor m,100,100,100 l=CreateLight() b=CreateCube() ScaleMesh b,20,1,20 PositionEntity b,0,-1,0 EntityParent m,b t=CreateTexture(256,256) EntityTexture b,t shadowcam=CreateCamera() While Not KeyHit(1) HideEntity cam ShowEntity shadowcam PositionEntity shadowcam,30,30,0 PointEntity shadowcam,m RotateEntity shadowcam,EntityPitch(shadowcam),EntityYaw(shadowcam),0 CameraViewport shadowcam,0,0,256,256 CameraClsColor shadowcam,255,255,255 EntityAlpha b,0.1 RenderWorld ShowEntity cam CopyRect 0,0,256,256,0,0,BackBuffer(),TextureBuffer(t) EntityAlpha b,1 For s=1 To CountSurfaces(b) surf=GetSurface(b,s) For v=0 To CountVertices(surf)-1 r#=64 TFormPoint VertexX(surf,v),VertexY(surf,v),VertexZ(surf,v),b,shadowcam VertexTexCoords surf,v,TFormedX()/r+0.5,1-(TFormedY()/r+.5) Next Next HideEntity shadowcam TurnEntity b,0,1,0 RenderWorld CopyRect 0,0,256,256,0,0,TextureBuffer(t),BackBuffer() Flip Wend End |
| ||
The circular pattern appears to be caused by the mapping of an image that was rendered in perspective onto a rotating mesh. Since the verts (which double for mapping coords) are constantly rotating and they're rendered in perspective, they're not projecting planar. The shifting in the shadow itself is texture shearing of the two triangles in the top quad of b. |
| ||
What? |
| ||
Halo, you might look into the shadow code in the archives as a base? Can I offer that I write the shadowing code you need as im doing so for my rts very soon anyhow. What shadowing schemes/features were you looking for? |
| ||
LOL - sorry, I guess that does sound kind of strange. What I mean is that since you are projecting the image in perspective, one triangle in the top quad is getting more texels than the other, and causing distortion. The uvs are fine. |
| ||
Well doesn't Shawn's shadow routine do perspective shadows, not just directional light, like orthographics projection would give? Dev, I would appreciate any help you can offer. I have a lot of things going on right now. I have the lightmapping stuff taken care of, but want a method of having small entities like players and dynamic boxes cast a single shadow. I'm looking to UV map the shaded objects, not project a sprite like that MD2 terrain example. I'd like to start simple and make sure I understand the code, so that I can optimize it in the game engine. |
| ||
"Well doesn't Shawn's shadow routine do perspective shadows, not just directional light, like orthographics projection would give?" I beleive that the problem with your system is stemming from the facts that: A) You are trying to render an image from the camera's point of view and then project that onto the locations which the vertices map to on the screen. I do not do that, there could be unforseen problems. Such as: B) What about those vertcies oout of the camera's view? If yuou try to render with all receivers in view, then you're gonna have awfully low res shadows, rather than rendering a view just large enough for the shadow and then projecting that. And what about: C) If I'm not mistaken, you're rendering the shadow map, texturing the entities with it, and then rendering the shadow map again with those entities... Which you textured with the shadow map already... Which is probably modulating the entity color in the new shadow map. Or maybe it's not. Hard to say. Your code is confusing. And no, my system doesn't do perspective shadows. It cheats to save polygons. It uses hybrid point lights. In other words, shadows do not get wider as they receed from the object casting them. I did this only because I wished to. It's not a limitation. I just didn't want all the polygons in all the meshes inside an expanding 4 sided cone that extends infinitely into the distance to get put into the potentially visible set. However even if I chose to do this there is absolutely no need to render the shadows with perspective. I render the object casting the shadow by itself scaled to a size of 1,1,1 fit so that it almost touches the corners of the rendered texture. A shadow map is a 2D thing. No perspective is needed to scale it to be larger as it receeds into the distance. Anyhow Halo, even if you implement that exactly right it still won't be as fast as my shadow system, which has tons of optimiations. :-) But just think... for one copy of Chsop 3, which I can't buy anyhow cause I'm broke, you could sneak a peek at how I optimized the thing, and see how I did all this using math and no camera tricks like you're trying to do. :-) Halo, what would you do without me? :-) |
| ||
Make the source public and I'll give you a copy. |
| ||
"Make the source public and I'll give you a copy." Halo, you, by your own admisison, make like $60-70K a year on Cartography Shop. I make around $60 a MONTH on average on ALL the code I sell, and that's my only current source of income. So no, I don't think I'll be giving it away at this time just so I can have a copy of a program I may or may not make use of in the distant future. |
| ||
Halo, explain what you mean by mapping the objects a bit further and I wills see what I can do about that. I plan on starting with a simple sprite projection routine, but other methods can be plopped in on top. |
| ||
Halo, nice fix, but would you mind explaining how you arrived at the r#=64? |
| ||
I was trying powers of 2 and 64 worked. Dev, was thinking that if you use sprites, you'll only be able to project flat shadows on the floor. This would probably be faster, and useful in areas where there are large flat spaces. I could add a flag to the light entity so that some of them use this method. I suggest using quad meshes instead of sprites, so the routines will transfer more easily to other lighting methods. I would still like to get something working where shadows are cast on any wall, but I think flat shadows cast onto the ground, if that is what you're talking about, would be enough for now. Since we're working within an engine, we can have a little more of a controlled environment than pure Blitz. If you need anything special set up to make your routines faster, let me know. |
| ||
Ive made a couple of simple mods to the above. Change shadow texture size by changing the ssize variable. Hiding the light with the main camera gets a solid shadow...somehow parenting the light to the camera, the light isn't hidden when the camera is? bug? Using entityalpha b,0 instead of 0.1 Key 1 and 2 switch between perspective and orthoganol shadow camera. Perspective is obviously more geometrically correct but orthoganol have a cleaner edge to the shadow, not sure which I like best. Graphics3D 800,600,32 SetBuffer BackBuffer() cam=CreateCamera() CameraRange cam,1,10000 MoveEntity cam,0,20,-40 ssize=256 m=CreateCube() ScaleMesh m,1,10,1 PositionEntity m,0,8,0 EntityColor m,100,100,100 l=CreateLight() b=CreateCube() ScaleMesh b,20,1,20 PositionEntity b,0,-1,0 EntityParent m,b t=CreateTexture(ssize,ssize) EntityTexture b,t shadowcam=CreateCamera() PositionEntity shadowcam,30,30,0 PointEntity shadowcam,m CameraViewport shadowcam,0,0,ssize,ssize CameraClsColor shadowcam,255,255,255 CameraProjMode shadowcam,2 CameraZoom shadowcam,.05 r#=32 While Not KeyHit(1) If KeyHit(2) CameraZoom shadowcam,1 CameraProjMode shadowcam,1 r#=64 EndIf If KeyHit(3) CameraZoom shadowcam,0.05 CameraProjMode shadowcam,2 r#=32 EndIf HideEntity cam HideEntity l ShowEntity shadowcam EntityAlpha b,0 RenderWorld ShowEntity cam ShowEntity l CopyRect 0,0,ssize,ssize,0,0,BackBuffer(),TextureBuffer(t) EntityAlpha b,1 For s=1 To CountSurfaces(b) surf=GetSurface(b,s) For v=0 To CountVertices(surf)-1 TFormPoint VertexX(surf,v),VertexY(surf,v),VertexZ(surf,v),b,shadowcam VertexTexCoords surf,v,TFormedX()/r+0.5,1-(TFormedY()/r+.5) Next Next HideEntity shadowcam TurnEntity b,0,1,0 RenderWorld CopyRect 0,0,ssize,ssize,0,0,TextureBuffer(t),BackBuffer() Flip Wend End |
| ||
I should have a basic quad projection method done later tonight, ill release a demo when it's working. |
| ||
Ive got a basic projection routine done, getting the shadow's size and position matching the geometry is still to be done. |
| ||
Use anything from this, if it helps. I was testing some engine stuff, trying to figure out how the hell to implement this. It can definitely still be improved:Graphics3D 800,600,16,2 SetBuffer BackBuffer() Global cam=CreateCamera() MoveEntity cam,0,20,-40 m=LoadMesh("C:\Program Files\Blitz3D\Samples\Blitz 3D Samples\mak\castle\markio\mariorun.x") PositionMesh m,0,-MeshHeight(m)/2,0 PositionEntity m,0,MeshHeight(m)/2,0 EntityColor m,100,100,100 l=CreateLight() b=CreateCube() ScaleMesh b,100,.5,100 PositionEntity b,0,-1,0 t=LoadTexture("C:\Program Files\Blitz3D\Samples\Blitz 3D Samples\mak\castle\castle\gothic3.jpg") ScaleTexture t,0.1,0.1 EntityTexture b,t ;================================================ ;Shadow caster type ;================================================ Type ShadowCaster Field camera Field w,h Field texture Field shadowmesh Field magnification# Field shadowsize# End Type ;================================================ ;Create a shadow caster entity ;================================================ s.shadowcaster=New shadowcaster s\camera=CreateCamera() HideEntity s\camera s\w=256 s\h=256 s\texture=CreateTexture(s\w,s\h) s\shadowmesh=createquad() s\magnification#=12 s\shadowsize#=20 EntityFX s\shadowmesh,9 EntityBlend s\shadowmesh,2 EntityTexture s\shadowmesh,s\texture CameraClsColor s\camera,255,255,255 CameraViewport s\camera,0,0,s\w,s\h CameraFogMode s\camera,1 CameraFogColor s\camera,150,150,150 CameraFogRange s\camera,0,0 PositionEntity s\camera,0,30,0 ;================================================ ;Loop ;================================================ While Not KeyHit(1) MoveEntity m,KeyDown(205)-KeyDown(203),0,KeyDown(200)-KeyDown(208) HideEntity b UpdateShadowCaster s,m ShowEntity b PointEntity cam,m RenderWorld CopyRect 0,0,s\w,s\h,0,0,TextureBuffer(s\texture),BackBuffer() Flip Wend End ;================================================ ;Update shadows caster entity ;================================================ Function UpdateShadowCaster(s.shadowcaster,rec) ShowEntity rec HideEntity s\shadowmesh HideEntity cam ShowEntity s\camera PointEntity s\camera,rec EntityColor rec,0,0,0 zoom#=EntityDistance(s\camera,rec)/s\magnification CameraZoom s\camera,zoom RenderWorld EntityColor rec,255,255,255 HideEntity s\camera ShowEntity cam CopyRect 0,0,s\w,s\h,0,0,BackBuffer(),TextureBuffer(s\texture) ShowEntity s\shadowmesh surf=GetSurface(s\shadowmesh,1) nx#=EntityX(rec,1)-EntityX(s\camera,1) ny#=EntityY(rec,1)-EntityY(s\camera,1) nz#=EntityZ(rec,1)-EntityZ(s\camera,1) PositionEntity s\shadowmesh,EntityX(rec,1),0,EntityZ(rec,1) RotateEntity s\shadowmesh,0,0,0 AlignToVector s\shadowmesh,nx,0,nz,3 AlignToVector s\shadowmesh,0,1,0,2 CameraProject s\camera,EntityX(rec,1),0,EntityZ(rec,1) y=ProjectedY() ScaleEntity s\shadowmesh,s\shadowsize,1,s\shadowsize MoveEntity s\shadowmesh,0,0,(Float(y)/Float(s\h)-.5)*s\shadowsize*2 End Function Function CreateQuad() mesh=CreateMesh() surf=CreateSurface(mesh) AddVertex surf,-1,0,-1,0,1 AddVertex surf,-1,0,1,0,0 AddVertex surf,1,0,1,1,0 AddVertex surf,1,0,-1,1,1 AddTriangle surf,0,1,2 AddTriangle surf,2,3,0 Return mesh End Function |
| ||
thats basically what I have done, testing multiple light recieving bodies atm, seems very fast. |
| ||
http://www26.brinkster.com/bed1/shadowtest.rar Copy and paste, a couple boxes casting shadows on a simple scene, though the shadow can cast in any direction onto any surface, granted it is pickable. |
| ||
Bit of an update, ive got movable light sources and recievers now. On to big time optimisations. [edit] Once ive optimised this a bit, it should do everything ive seen SSwifts stuff do. Ive tested it on a bit more advanced scenery, it works beutifully. |
| ||
Bit of an update, ive got movable light sources and recievers now. On to big time optimisations. |
| ||
Cool, I am adding projection shadows on the weapon model. These are the high-res dynamic shadows you see in UT2003 when you walk under some lights. Your server gives this: [quote] HTTP1.1 STATUS 403 Remote Access to this object forbidden This file cannot be directly accessed from a remote site, but must be linked through the Brinkster Member's site. [quote] |
| ||
did you copy and paste the link to your browser? |
| ||
Could you scale/distort the shadowmesh (the quad) in such a way that it fakes perspective based upon distance from the light source and angle of light source? |
| ||
it already does.. sort of, the fact that the quad mesh expands the further it gets from the recieving mesh, it distorts. |
| ||
I fixed it so the shadow stretches with distance. The shadow also fades out, which is a nice way to go from not casting a shadow to casting one:Graphics3D 800,600,16,2 SetBuffer BackBuffer() l=CreateLight() Global cam=CreateCamera() MoveEntity cam,0,20,-80 m=LoadMesh("C:\Program Files\Blitz3D\Samples\Blitz 3D Samples\mak\castle\markio\mariorun.x") PositionMesh m,0,-MeshHeight(m)/2,0 PositionEntity m,0,MeshHeight(m)/2,0 EntityColor m,100,100,100 b=CreateCube() ScaleMesh b,100,.5,100 PositionEntity b,0,-1,0 t=LoadTexture("C:\Program Files\Blitz3D\Samples\Blitz 3D Samples\mak\castle\castle\gothic3.jpg") ScaleTexture t,0.1,0.1 EntityTexture b,t ;================================================ ;Shadow caster type ;================================================ Type ShadowCaster Field camera Field w,h Field texture Field shadowmesh Field magnification# Field shadowsize# End Type ;================================================ ;Create a shadow caster entity ;================================================ s.shadowcaster=New shadowcaster s\camera=CreateCamera() HideEntity s\camera s\w=256 s\h=256 s\texture=CreateTexture(s\w,s\h) s\shadowmesh=createquad() s\magnification#=12 s\shadowsize#=10 EntityFX s\shadowmesh,9 EntityBlend s\shadowmesh,2 EntityTexture s\shadowmesh,s\texture CameraClsColor s\camera,255,255,255 CameraViewport s\camera,0,0,s\w,s\h CameraFogMode s\camera,1 CameraFogRange s\camera,0,0 PositionEntity s\camera,0,30,0 ;================================================ ;Loop ;================================================ While Not KeyHit(1) MoveEntity m,KeyDown(205)-KeyDown(203),0,KeyDown(200)-KeyDown(208) HideEntity b UpdateShadowCaster s,m ShowEntity b PointEntity cam,m RenderWorld CopyRect 0,0,s\w,s\h,0,0,TextureBuffer(s\texture),BackBuffer() Flip Wend End ;================================================ ;Update shadows caster entity ;================================================ Function UpdateShadowCaster(s.shadowcaster,rec) ShowEntity rec HideEntity s\shadowmesh HideEntity cam ShowEntity s\camera PointEntity s\camera,rec EntityColor rec,0,0,0 zoom#=EntityDistance(s\camera,rec)/s\magnification CameraZoom s\camera,zoom CameraClsMode s\camera,1,1 fog=EntityDistance(s\camera,rec)*2+50 CameraFogColor s\camera,fog,fog,fog RenderWorld EntityColor rec,255,255,255 HideEntity s\camera ShowEntity cam CopyRect 0,0,s\w,s\h,0,0,BackBuffer(),TextureBuffer(s\texture) ShowEntity s\shadowmesh surf=GetSurface(s\shadowmesh,1) nx#=EntityX(rec,1)-EntityX(s\camera,1) ny#=EntityY(rec,1)-EntityY(s\camera,1) nz#=EntityZ(rec,1)-EntityZ(s\camera,1) PositionEntity s\shadowmesh,EntityX(rec,1),0,EntityZ(rec,1) RotateEntity s\shadowmesh,0,0,0 AlignToVector s\shadowmesh,nx,0,nz,3 AlignToVector s\shadowmesh,0,1,0,2 CameraProject s\camera,EntityX(rec,1),0,EntityZ(rec,1) y=ProjectedY() stretch#=PointDistance(EntityX(rec,1),0,EntityZ(rec,1),EntityX(s\camera,1),0,EntityZ(s\camera,1)) stretch=stretch/5.0 ScaleEntity s\shadowmesh,s\shadowsize,1,s\shadowsize+stretch MoveEntity s\shadowmesh,0,0,(Float(y)/Float(s\h)-.5)*s\shadowsize*2+stretch End Function Function CreateQuad() mesh=CreateMesh() surf=CreateSurface(mesh) AddVertex surf,-1,0,-1,0,1 AddVertex surf,-1,0,1,0,0 AddVertex surf,1,0,1,1,0 AddVertex surf,1,0,-1,1,1 AddTriangle surf,0,1,2 AddTriangle surf,2,3,0 Return mesh End Function |
| ||
"Once ive optimised this a bit, it should do everything ive seen SSwifts stuff do." I wouldn't be so sure of that. :-) Post a demo with the cube casting a shadow onto a sphere which is lit by a light source. If your method is like Halo's then you're porbably wasting a lot of texture space on your shadows. Halo's method seems to create one texture per receiver. How will you shadow objects in a level like that? Also my system has a lot of speed optimizations, soft shadows, and shadows fall off nicely at the edges of objects. |
| ||
Did you hear that? I guess you should just give up. |
| ||
LOL, that's really all I have to say. Since I have a fully opperational shadow system after 1 day, running at decent speed with NO optimisation work, see what I have in 2 weeks. |
| ||
If your method is like Halo's then you're porbably wasting a lot of texture space on your shadows. Halo's method seems to create one texture per receiver. How will you shadow objects in a level like that? I dont follow. Theres not much other way to render said shadows unless each reciever has a texture. Unless your refering to vertex coloring of some sort. If you don't have anything but productive to add to help the masses here, then I suggest you just stay in your corner ditching out copies of your shadow system. [edit] Halo, your system seems to completely ignore that this will have to cast onto surfaces other then a ground plane. Am I missing something? If so, I will gladly look at integrating your method into the shadow systema s well. |
| ||
Hey, I think a setup like my physics system would work well here. How about using the following commands: CreateShadowLight( parent, range, [blah], [blah],...) EnableShadows( entity ) UpdateShadows(); Update all shadows before RenderWorld() Instead of hiding the world, which is impractical with complex levels, maybe we could move both the light and the receiver to some extremely far position where everything else will be out of camera range, perform the rendering, and move them both back. |
| ||
"Did you hear that? I guess you should just give up." This coming from the guy who made the "End all be-all physics engine?" That's a riot! All I said was that I didn't think this early on he's come close to meatching all the features of my system. :-) I didn't say there was no way he could match my system. It'll just take quite a bit more effort, is all. :-) "I dont follow. Theres not much other way to render said shadows unless each reciever has a texture. Unless your refering to vertex coloring of some sort. If you don't have anything but productive to add to help the masses here, then I suggest you just stay in your corner ditching out copies of your shadow system." Hey no need to be snide. I didn't explain how my system worked because I don't have time to repond every single time someone wants to make a shadow system. I have posted how my system works in DETAIL at least three times in the past on these forums. Anyhow... Halo's system appears to fit the receiver into the current view. The shadow itself seems to take up a small area of the texture, and he maps the shadow with perspective so that sections which are farther from the light, yet stretched over a LARGER area are SMALLER in the texture. The way my system works is I do not render the shadows with perspective. And I use the maximum amount of texture area for the shadow. I scale a copy of the CASTER to be 1,1,1 in size, minus a tiny bit, and then render the view of it from the light source such that it almost fills the camera view. I then project this texture without perspective onto all receivers in the scene. Each caster renders one texture per light source. This texture is projected onto all receivers in the scene, so each receiver gets a mesh created for each caster in the scene that casts a shadow on it, and each of these meshes is textured with the texture for each caster. "Instead of hiding the world, which is impractical with complex levels, maybe we could move both the light and the receiver to some extremely far position where everything else will be out of camera range, perform the rendering, and move them both back." That's exactly what I do in my system. |
| ||
"Instead of hiding the world, which is impractical with complex levels, maybe we could move both the light and the receiver to some extremely far position where everything else will be out of camera range, perform the rendering, and move them both back." I do this already also. [edit] Halo, I'll follow a syntax similar to what you made example of when I release a version for singularity to use. |
| ||
Here is the same routine, with more convenient commands. I am going to implement this version into the engine right now, and hand it over to you to develop further:Graphics3D 800,600,16,2 SetBuffer BackBuffer() l=CreateLight() Global cam=CreateCamera() MoveEntity cam,0,80,-80 TurnEntity cam,45,0,0 Dim mario(5) For n=0 To 5 mario(n)=LoadAnimMesh("C:\Program Files\Blitz3D\Samples\Blitz 3D Samples\mak\castle\markio\mariorun.x") PositionEntity mario(n),Rand(-50,50),0,Rand(100) enableshadows mario(n),20,64,20 TurnEntity mario(n),0,Rnd(360),0 EntityRadius mario(n),10 EntityType mario(n),1 Animate mario(n),1,.5 Next Collisions 1,1,1,2 b=CreateCube() ScaleMesh b,200,.5,200 PositionEntity b,0,-1,0 t=LoadTexture("C:\Program Files\Blitz3D\Samples\Blitz 3D Samples\mak\castle\castle\gothic3.jpg") ScaleTexture t,0.1,0.1 EntityTexture b,t Type ShadowLight Field camera Field texture Field shadowmesh Field height# Field range# End Type Type ShadowCaster Field entity Field shadowmesh Field shadowsize# Field texture Field size Field magnification# End Type l=createshadowlight() PositionEntity l,30,30,0 period#=1000.0/60.0 time#=Float(MilliSecs())-period While Not KeyHit(1) Repeat elapsed#=Float(MilliSecs())-time Until elapsed ticks#=elapsed/period tween#=Float(elapsed Mod period)/Float(period) For k=1 To ticks time=time+period For n=0 To 5 TurnEntity mario(n),0,2,0 MoveEntity mario(n),0,0,1 Next UpdateWorld Next CameraProjMode cam,0 UpdateShadows CameraProjMode cam,1 RenderWorld Text 0,0,"FPS: "+fps() Flip False Wend End Function EnableShadows(entity,shadowsize=10,size=256,magnification#=12.0) s.shadowcaster=New shadowcaster s\entity=entity s\size=size s\texture=CreateTexture(size,size) s\shadowmesh=CreateMesh() s\shadowsize=shadowsize surf=CreateSurface(s\shadowmesh) AddVertex surf,-1,0,-1,0,1 AddVertex surf,-1,0,1,0,0 AddVertex surf,1,0,1,1,0 AddVertex surf,1,0,-1,1,1 AddTriangle surf,0,1,2 AddTriangle surf,2,3,0 EntityFX s\shadowmesh,9 EntityBlend s\shadowmesh,2 s\magnification=magnification EntityTexture s\shadowmesh,s\texture End Function Function CreateShadowLight(parent=0,range=200,height=0) s.shadowlight=New shadowlight s\camera=CreateCamera(parent) s\height=height s\range=range CameraClsColor s\camera,255,255,255 CameraFogMode s\camera,1 CameraFogRange s\camera,0,0 CameraRange s\camera,1,range CameraProjMode s\camera,0 Return s\camera End Function Function UpdateShadows() For s.shadowlight=Each shadowlight CameraProjMode s\camera,1 TranslateEntity s\camera,0,-20000,0,1 For c.shadowcaster=Each shadowcaster CameraViewport s\camera,0,0,c\size,c\size TranslateEntity c\entity,0,-20000,0,1 zoom#=EntityDistance(s\camera,c\entity)/c\magnification CameraZoom s\camera,zoom PointEntity s\camera,c\entity fog=200.0*Sqr(EntityDistance(s\camera,c\entity)/s\range)+55 CameraFogColor s\camera,fog,fog,fog RenderWorld TranslateEntity c\entity,0,20000,0,1 CopyRect 0,0,c\size,c\size,0,0,BackBuffer(),TextureBuffer(c\texture) surf=GetSurface(c\shadowmesh,1) nx#=EntityX(c\entity,1)-EntityX(s\camera,1) ny#=EntityY(c\entity,1)-EntityY(s\camera,1) nz#=EntityZ(c\entity,1)-EntityZ(s\camera,1) PositionEntity c\shadowmesh,EntityX(c\entity,1),s\height,EntityZ(c\entity,1) RotateEntity c\shadowmesh,0,0,0 AlignToVector c\shadowmesh,nx,0,nz,3 AlignToVector c\shadowmesh,0,1,0,2 CameraProject s\camera,EntityX(c\entity,1),s\height-20000,EntityZ(c\entity,1) y=ProjectedY() stretch#=PointDistance(EntityX(c\entity,1),0,EntityZ(c\entity,1),EntityX(s\camera,1),0,EntityZ(s\camera,1)) stretch=stretch/5.0 ScaleEntity c\shadowmesh,1,1,1 MoveEntity c\shadowmesh,0,0,(Float(y)/Float(c\size)-.5)*c\shadowsize*2.0+stretch ScaleEntity c\shadowmesh,c\shadowsize,1,c\shadowsize+stretch Next TranslateEntity s\camera,0,20000,0,1 CameraProjMode s\camera,0 Next End Function Global fpstime Global lastupdate Global oldfps Function fps() oldtime=fpstime fpstime=MilliSecs() elapsed=fpstime-oldtime If Not elapsed elapsed=1 time=Int(MilliSecs()/1000) If time>lastupdate lastupdate=time oldfps=1000/elapsed EndIf Return oldfps End Function ;Function CreateQuad() ;mesh=CreateMesh() ;surf=CreateSurface(mesh) ;AddVertex surf,-1,0,-1,0,1 ;AddVertex surf,-1,0,1,0,0 ;AddVertex surf,1,0,1,1,0 ;AddVertex surf,1,0,-1,1,1 ;AddTriangle surf,0,1,2 ;AddTriangle surf,2,3,0 ;Return mesh ;End Function |
| ||
Sounds like a plan. Get me some screenshot of the shadowing working so I can see it's current limitations, don't have time to study your code. I update my demo file, check out the link above. Use the 1,2,3, and 4 keys along the top of the keyboard to move the lightsource. This displays 3 shadows of different resolutions. |
| ||
This is looking good, I can get ten markios running on the screen at 31fps. One small thing, when he walks further away from the light source, there is a point where the shadow no longer starts at his feet, is there a simple solution for this? |
| ||
Halo, your tendancy to use DLL's for functions like getting the distance of one point from another really sucks when you post code like this which won't even run for everyone else without modification. |
| ||
I wrote a point distance function to take the place of Halo's and tried that demo, and PErturbatio is right, even when he's only a short distance from the light osurce the shadow isn't even close to connecting to his feet. I wonder.. are the Markio's even touching the floor? If they were not, that is one explanation for why the shadows would appear to be off. |
| ||
Yep, his feet are touching the floor, I just checked. It's the shadow code which is off. |
| ||
had that same problem when I was writing my own a while back. Haha notice it looks right.. problem? their feet are the end edge of the shadow ;) |
| ||
Dev, any development here? |
| ||
Where i can find the function PointDistance or it s just sqr( (x2-x1) ^ 2 + (y2-y1) ^2 + (z2-z1)^2 ) ? thank |
| ||
"RockStar"? Get over yourself. |
| ||
Would you prefer "PornStar"? |
| ||
Pr0nStar! |
| ||
Yeah, theres development, when I have time :). I need this for my own project, so it's being developed. Just takes time. |
| ||
Too bad "epicboy" and "sswift" ripped off your thread. "Quote: "RockStar"? Get over yourself." Why do you run around insulting and provoking others? He didn't do anything to deserve it. You are the weak-minded one here. Let me remind you that you two do have the option to keep your opinions to yourself, because they are rather annoying and are not benificial in any way. Don't get cocky sswift. Don't think your shadow routines are the best on the planet. Advice: Do not advertise by criticizing. |
| ||
That is because that engine is a lot less simple than you make it out to be. It also has great capabilities because it works directly with map files to place objects, and when these objects are created they become INTERACTIVE IN THEIR OWN WAYS WITH THEIR OWN BEHAVIORS, DEPENDING UPON THE OBJECT AND CLASS. Yes, It is powerful and yes it does deserve respect. Take a look at a few of these screenshots. You have to admit, it does look really good. Just trust that it isn't as simple as you make it out to be. "Quote: that belittles the amount of work which went into my system" I agree with you there. But why not let him go on about how great his shadowing routines are? Just post some executables of yours. Let others formulate their own opinions. If your routines are that good, why not post executables? It would be benificial to yourself. Anyway, I agree with the fact that an engine created in two days cannot duplicate an engine that has had a lot of work put into it. You have already encountered the unpredicted problems that occur when writing these routines. These things take time to solve. He has yet to encounter them you know that. :] -Later |
| ||
"You have to admit, it does look really good." No. I have to admit that LIGHTMAPPING looks really good, and that whoever constructed those levels might make a good level designer one day. :-) You could make those same screens using the YAL lightmapping tool. If I'm not mistaken, Singularity doesn't even come with a lightmapping tool. That would be CSHOP's department. Did you use CSHOP to do the lightmaps? :-) Even if you did, that is not singularity. And nobody's questioning whether CSHOP is any good. I'd consider using it for my own levels. Though if Halo's not gonna give me a free copy I guess I'll just have to write a competing product. :-) Cause I can't afford his extravagant prices on my current budget. :-) "It also has great capabilities because it works directly with map files to place objects, and when these objects are created they become INTERACTIVE IN THEIR OWN WAYS WITH THEIR OWN BEHAVIORS, DEPENDING UPON THE OBJECT AND CLASS." I downloaded the source, and I did not see anyhting like this demonstrated in the levels or in the source, so if you could point to the source file where this occurs, or any singularity based demo which demonstrates this ability I'd be interested in seeing it. That said, such things are pretty simple to program. It's probably one of the most simple systems in a game. The physics that controls dynamic objects is much more complicated than telling an object to rotate 90 degrees when the player clicks on it. "Just post some executables of yours. Let others formulate their own opinions. If your routines are that good, why not post executables? It would be benificial to yourself." Uh... I've had a demo out for forever. :-) See my sig? There's a link there. Click it. Demos of all my stuff. :-) Including the shadow system. As for what my system does that others may not... Well for one, it's optimized in a number of ways. Not that it has every optimization it could. I relly ought to tackle the issue of requiring people to divide up their levels. But right now the slowest part is the actual texture rendering, by far. And my system fades shadows out as they go around corners, so they look nice and smooth and don't cut off suddenly, which looks ugly. Hey all I'm saying is halo should lay off the "I'm god" trip. He's starting to sound like Derek Smart or John Romero. (before Romero got humbled a bit by Ion's Storm's failure.) Oddly enough both those guys are rich, and Halo lives in a nice house in California with a Corvette or something and makes over 60K a year off CShop. Perhaps with EGO comes suckers willing to give you money hand over fist. :-) |
| ||
I drive a '91 Explorer, and CShop doesn't make anywhere near 60k a year yet. Anyways, I am getting kind of tired of programming. |
| ||
Sorry. I got you confused with someone else who lives in california that I despise because they're always begging for money and then I found out they own a corvette and a real nice house. But I distinctly remember you saying that you made X amount of money on CShop 3, a very specific, very high number. And I think it was in the thread where you said you made most of your sales off of DarkBasic users. Unfortunately the search functions on these forums suck, and don't even pull up all the results which match the one word I can put in for the search, making it all but impossible to find it without knowing one word unique to that thread. |
| ||
Perhaps it doesn't matter :). |
| ||
The point distance function is here (by Halo) Function PointDistance#( x1#,y1#,z1#,x2#,y2#,z2# ) Return Sqr#((x1-x2)^2+(y1-y2)^2+(z1-z2)^2) End Function |
| ||
You mean by pathagoras right? :) |
| ||
DEV: LOL... Don't you believe reincarnation :) |
| ||
Pathagoras? What is that, some kind of panther? |