Jump to content
  • Advertisement

BlueSpud

Member
  • Content Count

    157
  • Joined

  • Last visited

Community Reputation

650 Good

About BlueSpud

  • Rank
    Member

Personal Information

  • Interests
    Art
    Design
    Programming
  1. BlueSpud

    PhysX Tank Simulation in Unreal

    I believe dampening is definitely not the way to go. In circular motion, the motion is not damped to keep the object on the correct path of motion. I was correct, tanks use a double/triple differential to vary the torque on each tread (see https://en.wikipedia.org/wiki/Differential_steering). The older ones use clutch breaking, which is non-regenerative, which is not currently what Im trying to accomplish. I've been playing around with applying a torque manually to the entire hull of the tank in the z axis in addition to applying a different torque to each set of wheels, which has given me the motion that I desire. However, I'm still having a lot of trouble with sliding and achieving circular motion when the turn button is held down.
  2. BlueSpud

    PhysX Tank Simulation in Unreal

    Are you talking about using little rigid bodies that are adjacent to the wheels that would simulate friction? Using capsules as the collision mesh for the tires creates friction that opposes the tank sliding, which is really nice. But I'm still having a lot of issue making the thing turn in a believable manner. I think the best option is to simplify this a lot, do the calculations to convert the torque that I would be applying to the wheels to a forward force and then make turning a torque on the hull of the tank, rather than rely on the physics engine to make the torque from the differential. And at least this way I will have much finer control over all of the forces and torques that are being applied, as opposed to being at the whim of PhysX
  3. BlueSpud

    PhysX Tank Simulation in Unreal

    That's an awesome resource, but as far as I can tell, that functionality requires an engine modification in order to get it to work. I think there has to be something other than the anisotropy that's tripping me up here. AFAIK there is no rolling friction in PhysX. Right now I have my wheels as capsules, so friction serves as the anisotropic force. I have it cranked and it does seem to mitigate the drifting, but doesn't seem to make a realistic effect, and doesn't stop the sliding. I believe modern tanks use some kind of differential, but like I stated in the OP, I have no idea how to achieve this in the engine.
  4. BlueSpud

    PhysX Tank Simulation in Unreal

    I cranked up the friction (past 1.0) to simulate this, and while it did help, it certainly is not perfect.
  5. BlueSpud

    PhysX Tank Simulation in Unreal

    Thanks for the suggestion. I'm not aiming for total realism, but I would prefer that it was somewhat realistic, the game I'm trying to make is not an arcade game. Ill definitely look into PhysX a little more, but I belive that if it did support those features, than someone would have already used them to make a similar project. Cheers
  6. BlueSpud

    PhysX Tank Simulation in Unreal

    AFAIK, Unreal doesn't expose this. For their official tutorial on a conveyer, they just use a collision volume and move the objects manually, without going through the physics engine. I think the problem is with the first method is that friciton is a lot of what makes the tank turn, so it has to be modeled rather well to get that working, which is another reason why I'm not trying to fight the engine and use as much of PhysX as I can without applying a lot of manual forces and such.
  7. BlueSpud

    PhysX Tank Simulation in Unreal

    I'm a little curious how you did that. I initially started using linear force, but opted against it. The reason being is that I'm using capsules for the wheels and applying torque to them to make them move. When they arent on the ground, they don't apply force. If I was to use linear force, AFAIK, I would have to do raycasts or sweeps for every wheel to determine if they were touching the ground or not and should be applying force. I will definitely see if I can find the Newton demo though, hopefully theres something there.
  8. Hey, I've been playing around with making a tank in Unreal using PhysX. I have suspension working really well with some physics constraints, but I'm having a few issues with both the turning and the propulsion. I am aware that there's already an open source plugin that does this, but I've played around with it and it seems to be very performance intensive, so I've decided to roll my own solution. The main problem I've had is turning the tank realistically, while the tank is in gear (neutral is no problem, as neutral steering is quite easy). From my understanding tanks use several methods to turn themselves. One is to brake on one side of the tank, while the other remains at full throttle. The other way is by using a gear differential, such that the tread on the inside of the turn is turning at a slower rate than the one on the outside. I'm not quite sure how to model the differential method using PhysX, and I've had issues with getting the braking method to work, ie. the tank spins out and the brakes don'y apply hard enough to keep the turning radius reasonable. I was wondering if anyone could offer some tips or advice. My thought to fake it would be to apply some kind of radial force based off of an imaginary turning circle, but I'm not quite sure what the magnitude of that force should be, such that turns slow down the tank. Cheers
  9. Hey, Im trying to implement some very simple screen space reflections. Right now I have everything working, except there are some pretty noticeable artifacts. Here is an image of the reflection buffer with the artifact shown. I've outlined the actual geometry extents in red so that its more obvious because this is the reflection buffer only. The noise is intentional, I'm either going to blur it out later, bur right now Im concentrated on getting the reflections themselves to look right. As you can see there are "streaks" that optimally should not be there. My guess is that the ray is facing away from the camera and is actually moving behind the objects but since the ray position is then less than the depth of the object it is reflected.  If an object isn't touching the plane it is reflecting on the streaking becomes much more noticeable.  Does anyone have any ideas on what I can do to fix this?    Thanks   EDIT: Here is my code if there is a chance that its an issue with that  vec2 binarySearch(vec3 last, vec3 current) { vec3 ray_min = last; vec3 ray_max = current; vec3 ray_mid; for (int i = 0; i < 10; i++) { ray_mid = mix(ray_min, ray_max, 0.5); float depth = texture(tex_depth, ray_mid.xy).r; if (ray_mid.z > depth) ray_max = ray_mid; else ray_min = ray_max; } return ray_mid.xy; } void main() { // Get the normal vec3 normal = texture(tex_normal, tex_coord0).rgb; // Calculate world space position float depth = texture(tex_depth, tex_coord0).x; vec4 position_p = vec4(tex_coord0 * 2.0 - 1.0, depth * 2.0 - 1.0, 1.0); position_p = inverse_proj_view * position_p; vec3 position = (position_p / position_p.w).xyz; // Get the reflection vector vec3 V = normalize(position - view_position); vec3 reflection_vector = reflect(V, normal); vec4 reflection_pos = mat_view_proj * vec4(position + reflection_vector, 1.0); reflection_pos = reflection_pos / reflection_pos.w; vec3 reflection_pos_s = reflection_pos.xyz * 0.5 + 0.5; // Calculate a jitter to add some noise float c = (tex_coord0.x * 14400.0 + tex_coord0.y * 8500.0) * 0.25; float jitter = mod( c, 1.0); vec3 NDC = vec3(tex_coord0, depth); vec3 ray_direction = normalize(reflection_pos_s - NDC) * jitter; vec3 last_ray_step = NDC; vec3 reflection_color; for (int i = 0; i < 16; i++) { vec3 ray_step = last_ray_step + ray_direction * 0.04; float depth_ray = texture(tex_depth, ray_step.xy).r; if (depth_ray < ray_step.z) { reflection_color = texture(tex_albedo, binarySearch(last_ray_step, ray_step)).rgb; break; } last_ray_step = ray_step; } reflection = reflection_color * (1 - smoothstep(0.25, 0.5, dot(-V, reflection_vector))); }
  10.   Yeah - I suspect that too. I wouldn't be surprised if the management of the CPU/GPU clock speed is dynamic enough that launching a new program or alt-tabbing out could lead to a temporary speed recovery.     Here are some graphs of the thermals running the game for ~7 minutes. http://imgur.com/a/zZ1iq It seemed like the there could perhaps be some throttling, but for the long patch where the temperature remained constant, the game was still running at 60FPS (V-sync was enabled). This was a fresh reboot, so it could still be a temperature issue, but I'll have to do more extensive tests later on that if there aren't any other ideas.
  11. Hey, So I was working on my OpenGL engine today and I noticed that if I leave it running for ~a minute and a half I start to experience some significant framerate drops. The first thing I did was make sure that there were no OpenGL allocations every frame. After both a code check and a separate profile application check I verified that I am not calling something like glGenBuffers() or something like that. Then I checked for possible issues with dynamic allocations per-frame. The code executed every frame is relatively large, but it doesn't seem like there are any dynamic allocations in the rendering pipeline. I checked the graph of memory usage and it doesn't even seem like I'm allocating any memory except for a little bit here and there, which I assume is coming from PhysX or OpenAL which are both in the program.     I thought that perhaps my CPU or GPU could be thermal throttling (I'm on a laptop). I ran the program until I experienced performance issues, closed it and immediately ran it again. The performance issues stopped once the application was re-run. What also strikes me as odd is that when I tab-out and tab back in the performance issues stop for a short period of time.   I'm a bit puzzled at what is happening here. I highly doubt it's a driver issue as other games work fine, although I haven't tried it on another computer. I've run some standard time-elapsed CPU profiling to try to figure out where the code was getting slow (I know these are generally unreliable because the GPU operates independently) and it just seems like anywhere that is touched by OpenGL just runs slower after the game is left running. Any ideas to what might be causing this? I've noticed this issue for a while but I've always ignored it thinking it was just something else running on the computer until I did extensive testing now so I don't know what code specifically changed this.    Thanks
  12. BlueSpud

    Shadow Mapping Issue

    Could it be this line?  -position.y/position.w/ 2.0f + 0.5f I'm not 100% sure why you are flipping this, could that be the issue?   Also, you can create a matrix to transform your coordinates from [-1, 1] to [0, 1] and multiply it by your light matrix to save a bit of computation when you do the shadow comparison.   Also I believe that you don't need to divide by w for this or the z position. The z value in the shadow map is the projected z without the division, so doing it is pointless I believe.    This is how I sample from my shadow map for reference: vec4 position_shadow = light_matrix * vec4(position, 1.0); vec2 tex_coord_shadow = position_shadow.xy; float z = texture(tex_shadow, tex_coord_shadow).x; position is the word space position of a fragment and my light matrix includes the matrix to transform it to [0, 1]
  13. BlueSpud

    Better PhysX Character Controller

    I've tried using both rigid bodies and manual sweep tests. I had some really nasty problems with both, mostly stuttering / bad collision behavior, etc. I would think that a rigid body would be the best solution as well, so I tried implementing it. I created a dynamic rigid body with a convex shape and set the inertial tensors so it wouldn't rotate and fall over. I then set the linear velocity before I called step simulation. This worked pretty good, but it didn't really slide against the walls and when the rigid body was pushed against the wall at too steep of an angle, it jittered back and forth and I'm not quite sure why. I'm sure there's something physx specific I'm missing but there isn't a whole lot on character controllers in physx from what I've found
  14. I haven't tested this but I'm pretty sure it should work.      I'm assuming your square is defined by things: - a center point - a radius - a rotation vec2 point1 = vec2(cos(pi / 4 + angle), sin(pi / 4 + angle)) * sqrt(2) * radius + center; vec2 point2 = vec2(cos(3 * pi / 4 + angle), sin(3 * pi / 4 + angle)) * sqrt(2) * radius + center; vec2 point3 = vec2(cos(-pi / 4 + angle), sin(-pi / 4 + angle)) * sqrt(2) * radius + center; vec2 point4 = vec2(cos(-3 * pi / 4 + angle), sin(-3 * pi / 4 + angle)) * sqrt(2) * radius + center;  This should give you all 4 points of the square, but once you pass pi/2 the relative position of the points will change. For instance point1 will become the top left point instead of the top right. You could combat this by either sorting the points after or just use something like: void setAngle(float _angle) { angle = angle % (pi / 2); } which is much more efficient.   This works because if you look at a unit circle, you can make a square on the circle by taking the points at pi/4, 3pi/4 5pi/5 and 7pi/4. This will give us a square with a radius of sqrt(2)/2 because cos(pi/4) is sqrt(2)/2. To make it a radius of 1 we multiply by the square root of 2 and then by the desired radius. Take a look at the unit circle if you're having any issues visualizing this.   I would verify this before using it (I didn't really do extensive testing) but it should work.
  15. BlueSpud

    Better PhysX Character Controller

    My mistake, it totally slipped my mind that they were using a convex hull when I wrote the post. I took a look at the character controller source and it seems very specialized to just use capsules and boxes, so I doubt that they modified it because it would probably result in redoing the entire controller.   When I thought of using rigid bodies I envisioned using velocity instead of forces, and I actually tried it out. It resulted in a lot of rubber-banding when colliding with static objects. I'm not really very experienced with PhysX, so it was probably just my ineptness. The forces approach seems like it would require a lot of overcomplicating because the force would have be exactly the same as friction once the controller was accelerated to full speed.    As for the kinematic approach, I was under the impression that kinematic objects don't have collisions? I could be wrong but from the Nvidia docs it says "There is no interaction or collision between kinematic actors and static actors." The regular implementation uses sweep tests for the collisions from what I can tell and kinematics just to simulate collision with dynamic bodies. What were you thinking with this one? Its probably the best solution because it gives the most control. 
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!