Sign in to follow this  
Sailarg

¿how can I make two shaders in the same object?

Recommended Posts

On 9/24/2017 at 12:48 PM, Sailarg said:

I want to do the same, only I thought it was easy to apply the 2 effects to the same object xD

I do not know much about this topic, but a decent (& much faster) way to get a fish eye effect is done the same way as it is done in the real world, the lens.  It is implemented in camera.fov, or focal length.  It is measured in radians in BJS, but also can be in units of millimeters.  The default camera.fov is 0.80 radians.  That corresponds to nothing in the real world, so I have no idea why it got chosen to be that.  Most things default to 35 mm (0.857556 radians) due human vision.  I typically use 120 mm wide angle lens for my scenes ( 0.265103 radians), but a fisheye lens is about 10 - 15 mm(2.02 - 1.64 radians).  I would try doing this first, before doing some expensive post process.

Share this post


Link to post
Share on other sites

About same mesh using two it is unfortunately not possible.

Solutions are exactly the already proposed ones:

  1. Post Process
  2. Lens Setup
  3. Create your own shader to apply both lighting + effect (as long as the effect does not needs the several pixels in inputs like in blur)

Share this post


Link to post
Share on other sites

First, do an animation of camera.fov the same way you would of any other of that type.  I do not use the BJS animation system.  To go back and forth, a beforerender will possibly work better. 

For a very low focal length, the camera will have to be moved much closer to the subject, but the distortion will be evident as below.  Anything which is closer to the camera than something else will look wildly closer / larger.

fisheye.thumb.jpg.d536a0392fcad9ecb81cbdd57ff8b610.jpg

This means any animation of .fov must not be over too wide a range of values, or the camera distance difference will overpower the distortion.  FYI, I thought of adding a kind of a "flashback" scene transition effect going from fish eye to previous focal length with harp music.  The distance issue stopped me, but did manage to add a "zoom out".  There, I go from about 630 mm to whatever the original focal length was.  Have not published the source yet, but have added "zoom out" onto a test scene of mine which goes through each of my transitions at random: B&W to color, invisible to visible, out of focus to focus, and now also zoom out.  Run this scene over and over till the "zoom out" gets picked as the transition.

On a side note, @Deltakosh or @Sebavan, could I add a setter / getter pair for focalLength?  They would only change / reference fov.  Radians suck.

Share this post


Link to post
Share on other sites

@DeltaKosh are there any underwater effects demos lying around? I can't find anything that remotely resembles automatically increasing & decreasing the FOV view so it creates an underwater-like effect. :/

Thanks!

~M

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.