The Stage3DPunk Thread!


(Red Ligot) #45
public class MainWorld extends World 
    {
        [Embed(source="../../assets/Tile0002.png")]
        private var gameGraphicImg:Class;
        private var img:Image;
        private var gameEntity:Entity;
        
        public function MainWorld() 
        {
            img = new Image(gameGraphicImg);
            gameEntity = new Entity(32, 32, img);
            add(gameEntity);
        }
        
        override public function update():void
        {
            super.update();
            img.color = 0x008080;
        }
        
    }

So I tried to recreate the bug with a simple project that simply adds an Entity and changes its graphic’s color. I was able to successfully recreate it. Unless the image’s color has been set before in the begin function or constructor and the color it was set to wasn’t white, the color doesn’t change.


(azrafe7) #46

Great! I can reproduce the issue using your code.

I’ve tried to find out where the problem might be without success, but… I discovered a weird workaround that should give some hints to @Ultima2876 of what is going wrong:

public class GameWorld extends World 
{
	[Embed(source="../../assets/Tile0002.png")]
	var gameGraphicImg:Class;
	
	var img:Image;
	var gameEntity:Entity;

	public function GameWorld() 
	{
		img = new Image(gameGraphicImg);
		img.tinting = 0;
		gameEntity = new Entity(32, 32, img);
		add(gameEntity);
	}

	override public function update():void
	{
		super.update();
		img.tinting = 1;
		img.color = 0x008080;
	}
}

As you’ll see the color gets applied with a one frame delay.


(Ultima2876) #47

Strange stuff. Thanks very much guys for looking into it - I really appreciate it! These test cases and explorations of the issue are incredibly helpful for me, especially at the moment as I am quite pressed for time. I’ll look into a fix this evening!

Thanks!


(Ultima2876) #48

I’ve found the issue and have fixed it. I haven’t yet had time to look into the other issues here so for now I’m going to provide a hotfix swc rather than doing a full release. You can grab that here:

Simply replace your current swc with that.

I’m aiming to make a full official update this weekend that addresses all of the issues gathered up to this point (plus exposing documentation for the internal stage3d functionality etc - and possibly an ASDoc export!). Sorry I haven’t been very active recently!


(azrafe7) #49

Thanks for the fix, you’re fast! :smile:

I’ve tested it and it works. What was it if I may ask?

The only thing I’d wish to add is that it still has the one frame delay I mentioned before (in both FP mode and S3P). The issue is not present in vanilla FP, and I seem to have restricted it to Engine.update(), which has a different order of function calls (watch out for checkWorld() and updateLists() specifically).


(Ultima2876) #50

Ah, I’ll have to check that. It probably is exactly as you say - a different order of operations there meaning it isn’t picking up the new color until the next render. That also probably effects many other things in a similar way I’d imagine.

The issue was to do with optimisations not picking up on the update as I thought, but not specifically to do with the ‘lazy vertices’ optimisation - basically, it only enables the tint shader for batches that require them and it wasn’t picking up on the color updates to do so in this particular instance (ie changing colors without the tint mode changing). Now it enables the tint shader in the actual color update functions (within the Stage3DSprite class).


(John Andersson) #51

Hi, I got a weird error which might be related to stage3dpunk

Thank you


(Zouhair Elamrani Abou Elassad) #52

I tried to follow exactly the demo video that was used to set The Pink Demo Project, i’m using Flex 4.13.0 and AIR 15, i get this error :

 Error while setting up Stage3D: 3702 - Error #3702: Context3D non disponible.
 Running in Non-Stage3D mode (Stage3D not supported)!
 Post-Init Children: 0 [Null Stage]

(Ultima2876) #53

How are you testing your game? In order for Stage3D to be supported when testing in the browser (rather than a desktop AIR window) you need to have ‘direct’ render mode enabled. For AIR, depending on your environment, you may also need to enable the ‘direct’ render mode to allow the game to get a Stage3D context.


(Zouhair Elamrani Abou Elassad) #54

I get the trace log saying that there is an error while setting the Stage3D, i never tested my game on the browser, i’m already setting wmode=“direct” in my web page, i’m testing my game just on desktop, do i need to put on the server for the Stage3D to be activated ?


(Ultima2876) #55

Stage3D should work without issues on desktop, unless your GPU is unsupported (which is fairly unlikely but possible). Has anyone else had this issue?

Which GPU do you have?


(Mike Evmm) #56

Well, I dunno how @AbouElassad has his IDE set up, but running the swf directly (I.e., not through FD) doesn’t usually let me use S3D.
That reminds me, worst case scenario, provided you’re using FD, you could always automate testing, by automatically compiling and running an html file.


(Ultima2876) #57

Oh yeah! You’re absolutely right @miguelmurca; you need to run the game from FlashDevelop directly to be able to support S3D (or otherwise run it from a html page that specifies ‘direct’ render mode).

I’m slowly becoming useless at supporting Stage3DPunk as I haven’t worked on it seriously in some time, so I’m sorry to anyone I’ve been giving poor advice to recently.


(Zouhair Elamrani Abou Elassad) #58

Hey, sorry for the late reply, i’ve been working on my game like a monster :smile:, i have an NVIDIA graphic card, the things is thatwhen i run the game in the FlashViewer Default mode in FD i get a white screen, once i change it to Open in Popup i get the Flashpunk mode, even through FD, i haven’t tested in a browser, i’ll do that in i’ll get back to you guys.


(John Andersson) #59

Hmmm… After taking a bit of a break from programming in general, I restarted on a new game. I am using no hand drawn graphics what so ever, except for the backdrop of the game. The normal graphics are created with the Draw functions.

As soon as I added stage3dpunk to the game, the graphics “froze”. So I disabled enablelazyvertexupdates, and now the backdrop works. But the Draw’n graphics aren’t visible! What is up with that?


(Ultima2876) #60

Stage3DPunk doesn’t support Draw at all; at least not officially (this is due to the difficulty in implementing it with the way Stage3DPunk and Stage3D work internally). I believe there may have been some experimental support for Draw->bitmap, but that’s slower than using regular old CPU rendering unless you’re clever about precaching and storing your sprites.


(bldd) #61

Hi, I was searching for this library but I can’t find the link, ¿Can someone pass me the link of the library? PD: My english is pretty basic :slight_smile:.


(rostok) #62

I got this file s3dpunk.zip dated 11th Jan 2015 http://rostok.3e.pl/download/s3dpunk.zip


(G Kri) #63

Maybe it will be a good idea to open source the Stage3DPunk…


(Ultima2876) #64

I’d love to do that but unfortunately I cannot - it took investment from an outside company that now owns the code for it.