Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stage3D proxy is null in Filter3DRenderer when setting filters3d property #6

Closed
jasonsturges opened this issue Mar 30, 2017 · 3 comments

Comments

@jasonsturges
Copy link
Contributor

jasonsturges commented Mar 30, 2017

When I add 3d filters to a view, I'm receiving a runtime exception.

Adding filters to my view:

dofFilter = new DepthOfFieldFilter3D(32, 32);
view.filters3d = [ dofFilter ];

In View3D, the set_filters3d() property creates a new Filter3DRenderer

private function set_filters3d(value:Array<Filter3DBase>):Array<Filter3DBase>
{
    ...
    } else if (_filter3DRenderer==null && value!=null) {
        _filter3DRenderer = new Filter3DRenderer(stage3DProxy);  // <-- line 326

In the Filter3DRenderer constructor, stage3DProxy is null.

This errors in Filter3DRenderer at line 35 when adding the event listener.

public function new(stage3DProxy:Stage3DProxy)
{
    _stage3DProxy = stage3DProxy;
    _stage3DProxy.addEventListener(Stage3DEvent.CONTEXT3D_RECREATED, onContext3DRecreated);

Null object reference at _stage3DProxy.addEventListener()

screen-capture

Apologies if I'm missing something, but I believe the proxy is in error.

I'll put together a small project to isolate this error and help debug this error here.

@jasonsturges
Copy link
Contributor Author

jasonsturges commented Mar 30, 2017

Example project to replicate error: https://github.com/jasonsturges/openfl-away3d-filter3d

Filter is added at line 132

Looks like the proxy is set after the first frame's render, but I believe I should be able to add a 3d filter before frame 2. Maybe this is by design.

Not to further complicate this, but when the filter is added on frame 2, mac64 target throws

Program3D.hx:332: fragment: ERROR: 0:18: Incompatible types (float and vec4) in assignment (and no available implicit conversion)
ERROR: 0:18: Use of undeclared identifier 'va0'

Error : Error compiling fragment shader: ERROR: 0:18: Incompatible types (float and vec4) in assignment (and no available implicit conversion)
ERROR: 0:18: Use of undeclared identifier 'va0'

@Greg209
Copy link
Contributor

Greg209 commented Mar 31, 2017

Just a quick note (not a complete solution - sorry).

In your example, stage3DProxy is indeed null and as such causes the error. The reason for this is that the stage3DProxy is only requested when the view is added to the stage. In your Away3DViewport class, moving the addChild(view) from the end of the initialiseListeners (ln95) to the end of initializeEngine (after ln65) instatiates a stage3DProxy before adding the filters and fixing your error.

Now the next problem is that the DepthOfFieldFilter3D is causing a GL error at the moment at runtime which I've not yet looked at. I tried the BloomFilter3D and that seemed to work ok after moving the addChild reference.

See what you think but it might be easier to close this item (after you've checked it) and create a new issue for the DepthOfFieldFilter3D for clarification.

@jasonsturges
Copy link
Contributor Author

That makes total sense - sorry about that.

Cool, let me track down the exact issue with the DepthOfFieldFilter3D and log that here, or appropriate project if root cause is Lime or OpenFL.

Thanks, again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants