Applying FisheyeFilter3D to split screen

Software: Away3D 4.x

Beek, Member
Posted: 19 February 2015 05:03 AM   Total Posts: 67

Hi,

I’m trying to apply this filter:

https://github.com/away3d/away3d-core-fp11/blob/dev/src/away3d/filters/FishEyeFilter3D.as

That is mentioned here:

http://infiniteturtles.co.uk/projects/away3d4/examples/Advanced_TerrainDemo/srcview/index.html

I’m using view.filters3d = Vector.<Filter3DBase>([ new FishEyeFilter3D(1024, 180) ]);

And attempting to split the views using Stage3dProxy.

The new view is taking up the whole screen, is there a way to reduce the view size using this filter?

   

Pierce, Jr. Member
Posted: 19 February 2015 11:05 PM   Total Posts: 40   [ # 1 ]

theoretically, to display a split screen on a single proxy, you can change the context settings between rendering each view using scissorRectangle:
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display3D/Context3D.html#setScissorRectangle()
i haven’t tried it myself yet, but i think it should work. i believe, the filter should not affect the drawing area manually set by context3d. give it a try and see what happens.

   

Beek, Member
Posted: 20 February 2015 09:02 PM   Total Posts: 67   [ # 2 ]

Hi Thanks.

I think I’ve enabled this with

  private var scissorL:Rectangle = new Rectangle( 0, 0, width/2, height );
  private var scissorR:Rectangle = new Rectangle( width/2, 0, width/2, height );
      context3D.setScissorRectangle(scissorL);
    view.render();
   
context3D.setScissorRectangle(scissorR);
    rightEye.render();


Which isn’t having any effect. The filter is still full screen. Any ideas how to keep the filter to only the area specified?

   

Pierce, Jr. Member
Posted: 20 February 2015 10:47 PM   Total Posts: 40   [ # 3 ]

maybe if you render the view that has the filter enabled, then remove the filter, and then render the second view, then next frame enable the filter again?

   

Beek, Member
Posted: 20 February 2015 10:56 PM   Total Posts: 67   [ # 4 ]

Thanks. The filter needs to be applied to both sides.

For some reason I can’t get the outputted filter to be the same size as the view.

   

Beek, Member
Posted: 20 February 2015 10:58 PM   Total Posts: 67   [ # 5 ]

I wonder if setRenderTargets(mainTarget:Texture, stage3DProxy:Stage3DProxy) might respect the view3D dimensions. Not sure what the texture is tho? Would it be the view?

   

Beek, Member
Posted: 21 February 2015 10:05 PM   Total Posts: 67   [ # 6 ]

I’m getting close - adding this to the render loop:

stage3DProxy.width width/2;
        
stage3DProxy.=0;
     
barrelDistortionFilterLeft.update(view.stage3DProxycamera);
      
view.render();
      
stage3DProxy.width/2;
      
barrelDistortionFilterRight.update(rightEye.stage3DProxycamera);
      
rightEye.render(); 

Renders one side with the filter just applied to that side, with a white overlay covering the rest of the screen. I can do one side or the other, I can’t do both. Any idea how to get it to show both sides?

   

Pierce, Jr. Member
Posted: 23 February 2015 09:59 PM   Total Posts: 40   [ # 7 ]

can you upload screenshots of both the fullscreen filter and the one-sided filter? i just don’t really understand what’s going on bcs you’re saying both sides need the filter but the filter can’t be fullscreen. are you trying to get two separate fisheyes, one on each side? anyhow, if you were able to get the effect you want on either side, then the trick might be in utilizing the stencil buffer. considering that you seem to be restricted to a single context3d, i can only assume that this is for like the galaxy note or something right?

   

Beek, Member
Posted: 23 February 2015 11:13 PM   Total Posts: 67   [ # 8 ]

Hi, thanks for answering!

Yes it is a Galaxy Note 3 that I’m testing on, I had no idea that would be an issue!

I’ll do the screen shots soon, but in answer to your question

- i’ve got the side by side views working perfectly
- Yes, I want to apply a fisheye or barrel distortion filters to each view
- If I apply the filter, the output is full screen

I can get the filter to output to half the screen by reducing the size of the Stage3dProxy, but as Stage3dProxy doesn’t allow any transparency, it covers the other half of the screen.

Could you give me any hints on using the stencil buffer? I’ve got no idea how to use it.

   

Pierce, Jr. Member
Posted: 24 February 2015 08:49 AM   Total Posts: 40   [ # 9 ]

we can get into it, but it’s a little bit of a chore to use and might not even be a factor given the way you’re doing things. it’s hard for me to tell here though bcs you’re also directly editing the transform of the proxy between views, which may have it’s own effect entirely in terms of displaying what was previously written to the stage in another area. i couldn’t really be sure without playing with the code directly.

try this: in addition to the code you’re currently using to render either side correctly, try setting the scissor rectangle property on stage3dproxy or context3d between view renders, as it might have the same effect you’re looking for as the stencil buffer in this instance. basically you’re just restricting which pixels get written to. it may be that rendering the stage again is overwriting the information rendered with the previous view, even though it’s in a different area you wouldn’t expect to get rendered.
i think the last time you tried the scissor rectangle, it was technically sort of working, just that each half was rendering with a filter centered at the center of the stage rather than the views, but now that you are resizing and positioning the proxy, something entirely different is going on.

Another thing to try: it could be that when you reposition the proxy, you are also just moving all the pixels you just rendered to the other side, and then writing over them with the second view. if that is the case, then you can’t accomplish anything by moving the x property. however you may be able to creatively resize it to re-center the fish-eye, depending on if the filter changes with proportions and stretches or maintains a square-ish aspect ratio. after rendering the first view with the proxy at .5 width, change the proxy to 1.5 width and set the scissor rect render from .5-1 width, thereby centering the filter at .75 width as desired.

And yet another method entirely: if all else fails, i suspect that you may be able to get away with rendering each view to a texture using a proxy at .5 width, and then resize the proxy to full and render a 3rd orthographic view of two planes displaying the textures. it’s kind of a gross workaround and i’ve never really played with render textures, but i think it theoretically would work as intended. as i understand it, that’s sort of how reflections are rendered.

i expect that somewhere between those techniques lies your solution, hopefully at least. let me know how it works out, and if the results are weird screen-cap those too. if none of that works i may just be inclined to compile some version of this myself just to tinker with and find out exactly what is happening.

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X