Strange result drawing 1000 black lines.

23 posts

Flag Post

package 
{
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.Shape;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.StatusEvent;
	
	/**
	 * ...
	 * @author Erlend Hofstad Langseth
	 */
	public class Main extends Sprite 
	{
		
		public function Main():void 
		{
			if (stage) init();
			else addEventListener(Event.ADDED_TO_STAGE, init);
		}
		
		private function init(e:Event = null):void 
		{
			removeEventListener(Event.ADDED_TO_STAGE, init);
			// entry point
			addEventListener(Event.ENTER_FRAME, update);
			addChild(s);
		}
		
		private var s:Shape = new Shape();
		
		private function update(e:Event):void
		{
			s.graphics.clear();
			s.graphics.lineStyle(1);
			for (var i:uint = 0; i < 1000; i ++) {
				s.graphics.moveTo(0, i);
				s.graphics.lineTo((i&1) * 500, 0);
			}
		}
		
	}
	
}

Just experimenting o.o

 
Flag Post

Very odd indeed.

 
Flag Post

This is an instance of a graphical artefact
I guess that much is obvious

I’m not sure what the scientific term for that particular artefact is, but it’s similar to the Moiré pattern

Your other recent topic is relevant:
http://www.kongregate.com/forums/4-game-programming/topics/318162-can-someone-help-me-grasp-the-circle-algorithm

 
Flag Post

Originally posted by Dealmaster13:

I’m not sure what the scientific term for that particular artefact is, but it’s similar to the Moiré pattern

that’s exactly what it is: Line moiré

 
Flag Post

Are the lines overlapping then? I don’t think it is the Sine Moiré effect, but something to do with the anti-aliasing. Maybe the AA treats lines differently according to their angle. See what happens when you change the stage quality to low or medium.

 
Flag Post

We are talking about the same artefect, right? I’m talking about the 4 differently colored faces, not about repeating pattern within these faces.

 
Flag Post
Originally posted by JohnnyBohnny:

Are the lines overlapping then?

No, they’re just so close together that when rendered as pixels, they’re touching.

 
Flag Post

Originally posted by JohnnyBohnny:

Are the lines overlapping then? I don’t think it is the Sine Moiré effect, but something to do with the anti-aliasing. Maybe the AA treats lines differently according to their angle. See what happens when you change the stage quality to low or medium.

Originally posted by JohnnyBohnny:

We are talking about the same artefect, right? I’m talking about the 4 differently colored faces, not about repeating pattern within these faces.

the pattern is the moiré pattern; the cause is due to the lines being positioned at the subpixel level (a whole pixel needs to be colored, but the line is partially on two pixels: two pixels get colored a blend of foreground+background). and what does four differently colored faces have to do with anything? there aren’t even any colors there

the larger pattern (light→dark→light→dark) is interesting, too; no idea what’s happening there. still related to subpixel shading, though

 
Flag Post

I’m sorry, with the four differently colored faces I ment the larger pattern.
Subpixel shading, is that AA?

 
Flag Post
Originally posted by JohnnyBohnny:

Subpixel shading, is that AA?

Yes

 
Flag Post

Here is something similar:

Link

Keep decreasing the linespace until you can see the effect.

 
Flag Post

Originally posted by JohnnyBohnny:

Here is something similar:

Link

that’s shit-tastic. forcing you to reload the page if rendering takes too long and refusing to render it further is the dumbest thing i have ever seen.

 
Flag Post

AS2, flippin shittastic. I did save your pc from melting down..
What do you think of the awesome flashlight btw?

 
Flag Post
Originally posted by JohnnyBohnny:

AS2, flippin shittastic. I did save your pc from melting down..
What do you think of the awesome flashlight btw?

What flashlight? It always forced me to refresh 3 seconds after loading the page.

 
Flag Post

lol it crashes even when i toggle the reach param :p

also seems like you have some garbage collection problem it gets slower and slower after i set the spacing to a small value, then crashes.

why not a better algorithm instead of the brute force one to generate your lights?

Edit: you have tunneling issues. You can’t trade accuracy for speed like that :P

 
Flag Post

In a game the fov would be 40, not 360, which makes it 9x faster. The accuracy would be lower (which means higher, bad choise of var names), and the linespace would be higher. The performance should be fine then.

Also, suggestions for a better algorithm are much appreciated. Currently, for every light beam it has a loop increasing the length of the line by [accuracy] pixels, and then hittesting it with the collision clip.
I did try something where only a third of the lines started at the guy, and the rest halfway the collision course, but that didn’t work as great as expected. Maybe a completely different approach?

Are you actually able to move the character and sliders and stuff, or did the freeze protection actually do the exact opposite? Because that would be pretty bad.

 
Flag Post

Originally posted by JohnnyBohnny:

Are you actually able to move the character and sliders and stuff, or did the freeze protection actually do the exact opposite? Because that would be pretty bad.

the “freeze protection” only means no one can even see what it looks like for very long. however you’re doing it is just sloppy at best, and so horribly inefficient i haven’t actually seen what it produces; mostly because you kill it after 3 seconds, limit is usually 15 seconds before flash steps in and kills it — i’ve upped that on my computer to 60 due to the performance tests i run. but an unresponsive flash app i can manage. a flash app that self-terminates so i don’t get the chance to see it or manage the unresponsiveness is just stupid

and what good would refreshing do? make the user experience the same crap again with no chance of it ever improving because you don’t make any effort to make it cheaper when you detect lag, you just flat out kill it and make it impossible to modify

 
Flag Post
Originally posted by JohnnyBohnny:

In a game the fov would be 40, not 360, which makes it 9x faster. The accuracy would be lower (which means higher, bad choise of var names), and the linespace would be higher. The performance should be fine then.

Also, suggestions for a better algorithm are much appreciated. Currently, for every light beam it has a loop increasing the length of the line by [accuracy] pixels, and then hittesting it with the collision clip.
I did try something where only a third of the lines started at the guy, and the rest halfway the collision course, but that didn’t work as great as expected. Maybe a completely different approach?

Are you actually able to move the character and sliders and stuff, or did the freeze protection actually do the exact opposite? Because that would be pretty bad.

It’s quite fast if you find the vertices of your walls and draw shapes.
http://dl.dropbox.com/u/17828135/index.html

 
Flag Post

It’s quite fast if you find the vertices of your walls and draw shapes.
http://dl.dropbox.com/u/17828135/index.html

Could you explain that a bit more? Because I was thinking of that, but i thought that it wouldn’t work unless you use a tile engine or you define all vertices yourself. Maybe I am missing something.

 
Flag Post

All right, I updated it now: link

Now it will not remove the flashlight, but reset the sliders, which can be disabled by leaving the min. fps at 0. Also, the settings are by default what they will be when used as a flashlight.

 
Flag Post

Change the flashlight when aiming down; it looks like the light comes from below his feet.

That said, its performance sucks. I’m not at the desktop, but I’m guessing it wouldn’t even run there. This is the first time that I see a Flash app running at such low FPS on the laptop.
As a comparison, 100,000 particles run at a constant 30 fps.

 
Flag Post

Originally posted by Senekis93:

As a comparison, 100,000 particles run at a constant 30 fps.

particles are in AS3, his flashlight is in AS2 — this is one of those things that AS2 can’t match AS3 on

 
Flag Post

Well, any suggestions?