[WIP] Robot Project
- walaber
- OGRE Expert User
- Posts: 829
- Joined: Sat Oct 02, 2004 2:20 pm
- Location: California, USA
- Contact:
[WIP] Robot Project
I reached a point on my latest project that I think I can show it off, and ask a few questions while I'm at it
VIDEO
http://www.youtube.com/watch?v=wD6DVdWD0a0 - YouTube
http://walaber.com/misc/rp_wip_video01.wmv - Windows Media download
**don't mind the speed, the framerate dropped because of fraps.
The project is a physics-based 2D game that will involve robots. So far I have implemented the first revision of my graphics system (shaders) which are basically normal-mapped billboards. I think the system works pretty well, and it's extremely easy to create content for it in Blender. Each visual object has 4 maps: ambient, diffuse, normal, and specular.
The physics are working great so far, with some custom joints and constraints I've come up with for 2D. The robot is moving by powered joints (currently running off a Sin() wave).
Finally, at the end of the video you can see my "replay" system, which lets you stop and go back and "scrub" through the timeline, watching the physics. At any point in the past you can restart the simulation.
finally a question - the attenuation on my point light does not seem to work smoothly between objects (esp. noticable on the ground blocks at the bottom)... as you can see there are strange "steps" where each block is darker than the one next to it.
does anyone know what might be causing this?
VIDEO
http://www.youtube.com/watch?v=wD6DVdWD0a0 - YouTube
http://walaber.com/misc/rp_wip_video01.wmv - Windows Media download
**don't mind the speed, the framerate dropped because of fraps.
The project is a physics-based 2D game that will involve robots. So far I have implemented the first revision of my graphics system (shaders) which are basically normal-mapped billboards. I think the system works pretty well, and it's extremely easy to create content for it in Blender. Each visual object has 4 maps: ambient, diffuse, normal, and specular.
The physics are working great so far, with some custom joints and constraints I've come up with for 2D. The robot is moving by powered joints (currently running off a Sin() wave).
Finally, at the end of the video you can see my "replay" system, which lets you stop and go back and "scrub" through the timeline, watching the physics. At any point in the past you can restart the simulation.
finally a question - the attenuation on my point light does not seem to work smoothly between objects (esp. noticable on the ground blocks at the bottom)... as you can see there are strange "steps" where each block is darker than the one next to it.
does anyone know what might be causing this?
- nedelman
- Gnome
- Posts: 315
- Joined: Wed Feb 21, 2007 6:03 am
- Location: San Francisco, California
- x 6
- Contact:
Cool looking demo.
As for the lighting issue, it may be helpful if you posted your shader code, in particular the parts that calculate the attenuation.
As for the lighting issue, it may be helpful if you posted your shader code, in particular the parts that calculate the attenuation.
http://www.ogremax.com - Ogre3D Scene Exporter for 3DS Max, Maya, and Softimage
http://www.linkedin.com/in/dereknedelman - My LinkedIn Profile
http://www.linkedin.com/in/dereknedelman - My LinkedIn Profile
- walaber
- OGRE Expert User
- Posts: 829
- Joined: Sat Oct 02, 2004 2:20 pm
- Location: California, USA
- Contact:
in the pixel shader:
lightDir is the object-spcace position of the light (passed over from the vertex shader without modification):
lightDir is the object-spcace position of the light (passed over from the vertex shader without modification):
Code: Select all
float dist = length(lightDir.xyz);
float attn = clamp(0,1, 1 / (lightAttn.y +
lightAttn.z * dist +
lightAttn.w * dist * dist ));
- smernesto
- Halfling
- Posts: 78
- Joined: Wed Jan 03, 2007 12:49 am
- Location: Bogota, Colombia
- nedelman
- Gnome
- Posts: 315
- Joined: Wed Feb 21, 2007 6:03 am
- Location: San Francisco, California
- x 6
- Contact:
Your lighting is being done per vertex even though all your other operations are occurring per pixel. The interpolated nature of lightDir is probably causing this very slight visual discontinuity. Try calculating lightDir per pixel.walaber wrote:in the pixel shader:
lightDir is the object-spcace position of the light (passed over from the vertex shader without modification):Code: Select all
float dist = length(lightDir.xyz); float attn = clamp(0,1, 1 / (lightAttn.y + lightAttn.z * dist + lightAttn.w * dist * dist ));
http://www.ogremax.com - Ogre3D Scene Exporter for 3DS Max, Maya, and Softimage
http://www.linkedin.com/in/dereknedelman - My LinkedIn Profile
http://www.linkedin.com/in/dereknedelman - My LinkedIn Profile
- walaber
- OGRE Expert User
- Posts: 829
- Joined: Sat Oct 02, 2004 2:20 pm
- Location: California, USA
- Contact:
- skullfire
- Gremlin
- Posts: 150
- Joined: Sat Mar 19, 2005 7:51 pm
- Location: San Jose, Costa Rica
- Contact:
- walaber
- OGRE Expert User
- Posts: 829
- Joined: Sat Oct 02, 2004 2:20 pm
- Location: California, USA
- Contact:
@skullfire - thanks! the game is coming along nicely, and although it will never be as beautiful as LittleBigPlanet, I'm enjoying making it!
regarding the shaders...
I can't seem to get light_position_object_space to be valid as a parameter into the pixel shader... Ogre appears to just pass me (0,0,0,0).
how would I calculate the distance / direction of a light in object space entirely in the pixel shader?
regarding the shaders...
I can't seem to get light_position_object_space to be valid as a parameter into the pixel shader... Ogre appears to just pass me (0,0,0,0).
how would I calculate the distance / direction of a light in object space entirely in the pixel shader?
- walaber
- OGRE Expert User
- Posts: 829
- Joined: Sat Oct 02, 2004 2:20 pm
- Location: California, USA
- Contact:
I'm ignoring the attenuation problem for now, and moving on with the game itself.
I thought I'd post a few updated screens... click for larger. Most of the shots are from the "Part Editor" that I have created to build the physics objects that are in the game. It's come out pretty well, so when the game is eventually released, I might include the editor so people can create their own levels and objects. You can also see the custom CEGUI skin I'm working on for both the editor, and the game itself. I think it's looking pretty nice if I do say so myself
I thought I'd post a few updated screens... click for larger. Most of the shots are from the "Part Editor" that I have created to build the physics objects that are in the game. It's come out pretty well, so when the game is eventually released, I might include the editor so people can create their own levels and objects. You can also see the custom CEGUI skin I'm working on for both the editor, and the game itself. I think it's looking pretty nice if I do say so myself
- walaber
- OGRE Expert User
- Posts: 829
- Joined: Sat Oct 02, 2004 2:20 pm
- Location: California, USA
- Contact:
- Praetor
- OGRE Retired Team Member
- Posts: 3335
- Joined: Tue Jun 21, 2005 8:26 pm
- Location: Rochester, New York, US
- x 3
- Contact:
With some really quick, late-night thinking this is what I came up with. I actually made a 2D, normal-mapped engine without Ogre this year and came across lighting anomalies like this. My guess is that the light position coming in is relative to the object. What you might want to do is pass in the light position in global coordinates. Then get the per-vertex direction by doing
and letting that get interpolated into the pixel shader.
Code: Select all
vertPos - lightPos
Game Development, Engine Development, Porting
http://www.darkwindmedia.com
http://www.darkwindmedia.com
- walaber
- OGRE Expert User
- Posts: 829
- Joined: Sat Oct 02, 2004 2:20 pm
- Location: California, USA
- Contact:
- Praetor
- OGRE Retired Team Member
- Posts: 3335
- Joined: Tue Jun 21, 2005 8:26 pm
- Location: Rochester, New York, US
- x 3
- Contact:
Ok.
Here's my thought. Pass through both the object space position of the light and the object space position of the vertex. They'll get interpolated into the pixel shader. There calculate the direction by subtraction. Seems like an unnecessary operation put onto the pixel shader, but I think it will give you the results you want.
Here's my thought. Pass through both the object space position of the light and the object space position of the vertex. They'll get interpolated into the pixel shader. There calculate the direction by subtraction. Seems like an unnecessary operation put onto the pixel shader, but I think it will give you the results you want.
Game Development, Engine Development, Porting
http://www.darkwindmedia.com
http://www.darkwindmedia.com
- walaber
- OGRE Expert User
- Posts: 829
- Joined: Sat Oct 02, 2004 2:20 pm
- Location: California, USA
- Contact:
- walaber
- OGRE Expert User
- Posts: 829
- Joined: Sat Oct 02, 2004 2:20 pm
- Location: California, USA
- Contact:
it's similar to a system I implemented in Stunt Playground, feel free to download the source code for that game to see how I did it there. This game has a slightly more complex replay system, because it remembers keyframes for poses as well as basic physics movement, but overall the implementation is very similar.
Stunt Playground also lets you save and load replays, so if you're interested, have a look at the source. It's based on Newton's callback system, so keyframes are only added when an object actually moves, which makes the system pretty memory-efficient, especially if you have lots of props in a scene, that don't move constantly. In Stunt Playground I also implemented a filter so that objects keyframes are only recorded at a certain frequency, basically reducing the accuracy for some objects. So in that game for instance, all props only record keyframes at something like 30 frames per second, but the vehicles and tires have keyframes accurate up to >100 fps IIRC.
Stunt Playground also lets you save and load replays, so if you're interested, have a look at the source. It's based on Newton's callback system, so keyframes are only added when an object actually moves, which makes the system pretty memory-efficient, especially if you have lots of props in a scene, that don't move constantly. In Stunt Playground I also implemented a filter so that objects keyframes are only recorded at a certain frequency, basically reducing the accuracy for some objects. So in that game for instance, all props only record keyframes at something like 30 frames per second, but the vehicles and tires have keyframes accurate up to >100 fps IIRC.