Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 26 Jul 2012
Offline Last Active Apr 04 2016 03:24 PM

Topics I've Started

Accumulate color value along x-axis

20 August 2015 - 03:27 PM


in order to compute light intensity for a pixel, I need to sum per-pixel attenuation along a ray to a buffer. The ray is parallel to the x-axis, so I have to sum values along the x-axis:


eg. 0112011 would become: 0124456 (number is sum of all previous numbers plus itself)

This is a rather complex operation, depending on length of ray (width of texture) and number of rays (height).


I thought a solution would be to draw the texture additive multiple times, shifting it to the right one pixel each time:

+ 011201
+  01120
+   0112
+    011
+     01
+      0

This works, but is computation expensive as well. Also, there are only 255 values which yields chunky results. I can't encapsulate numbers to 3-digit base 256 colors because additive blending would break this (it just adds per channel obviously).

Please ask if I have not described the problem well. I hope someone can help me!

Thanks, Phil

White Noise in CAPTCHAs

03 January 2015 - 08:02 AM

Hey, I hope this is the right board to post this!


When I saw this prototype for a game idea (great site, btw.), I immediately thought of the usage as a CAPTCHA. It is very easy for a human to distinguish foreground and background. Would it be equally difficult for a computer to read it? I know that traditional CAPTCHAs can be read by a compute more reliably than by a human (http://www.digitaltrends.com/computing/google-cracks-captcha-with-an-algorithm-thats-99-8-percent-accurate/). I am curious because I know very little about efficient image processing. This is why I ask you: would it be very easy for a computer to read CAPTCHAs that are generated by a moving/still white noise, as you can see in the prototype I linked? Or could you think of a technique that would require little processing costs thus making my idea useless?


Thank you, Phil.

2D Motion Blur Shader

05 November 2014 - 03:37 PM


I've been struggling for a while now getting a motion blur shader to work. I want to give the player a better feeling for velocity. My current approach is to draw a texture of my scene that consists of vectors how much this pixel is blurred and in what direction. I pack the numbers into the RG and BA channels to the base of 256. I even want to write a shader that does this for me, depending on rotational velocites, giving pixel-perfect gradients.


No problem until now, but how does my shader blur the scene, having just a sampler of the BlurTexture and the normal scene? I suck at math, so please help me! Thank you in advance, Phil.

2D chase steering algorithm

30 May 2014 - 04:52 PM

Hello community,

I do not know how to make enemies chase the player.

I already have the code to find the angle the enemy needs to shoot at

to hit the moving player, and how to steer to it.

(I don't want to make them cheat, they need to use their left-/right-jets like the player).

But how do I find out which translational acceleration needs to be applied?


The challenge is to cope with the different physical attributes the ships have.

Enemies might be much faster than the player, or much more inert.

If I let them accelerate continuously, they are much too fast and rush by the player

and can't rotate fast enough back which makes them lose the player

(they can accelerate translational into the direction they head to and rotational left-/right)

If I take the braking distance into account, they try to approach the point where the player

is, which works, but if the player moves it results in too slow enemies because the

braking distance is higher than the actual distance to the ship and they slow down.


I tried vector projection, to find out how much the velocity of an enemy matches with

the direction to the player or the player's velocity, but that didn't help me either.

I hope you understood my problem: How do I take the player's velocity into account to find

the translational acceleration an enemy needs to have to chase it?


Here are the properties a ship has, I hope it helps you:

int Mass { get; set; }
float TranslationalAcceleration { get; set; }
float RotationalAcceleration { get; set; }
float TranslationalFriction { get; set; } // Amount the velocity vector is reduced each second
float RotationalFriction { get; set; }
float MaxTranslationalVelocity { get; set; }
float MaxRotationalVelocity { get; set; }

Here is the code for the rotational acceleration, in case you need it:

        public float ApproachAngle(float desiredAngle)
            if (Math.Abs(desiredAngle) > .001f)
                if (Physics.GetBrakingDistance(Math.Abs(ship.WorldRotationalVelocity), ship.RotationalAcceleration / ship.Mass + ship.RotationalFriction) > Math.Abs(desiredAngle))
                    return -MathHelper2.GetSign(desiredAngle);
                    return MathHelper2.GetSign(desiredAngle);
            else return 0;

        public float GetIntersectionOffset(float currentAngle, Vector2 targetVelocity, float ammoVelocity)
            float tangential = targetVelocity.RotateBy(-currentAngle).Y;
            return MathHelper2.GetAngle(new Vector2((float)Math.Sqrt(Math.Pow(ammoVelocity, 2) - Math.Pow(tangential, 2)), tangential));

It would be very nice if you help me.


Democratic Chess

27 February 2014 - 10:04 AM

Hello Community,

some of you may have seen "Twitch plays Pokemon".

On the site there is a stream of an emulator that runs an old pokemon game. With the chat, you can press the keys of the virtual gameboy which leads to pure chaos, with sometimes 100,000 players.


This gave me the idea for an experiment: what would happen if two large groups would play chess against each other? Just one board and one game. Every team member can vote for the next turn. When a timer reaches zero, the turn with most of the votes is executed. When both teams are large, they would be exactly equally strong (in theory).


What do you think about it?