Tuesday, April 21, 2009

Opacity Bug II - Material Blending

It is possible to fake material blending using opacity maps on separate meshes to some extend. This technique comes handy if you would like to blend materials with different reflection, bump or specular highlight properties.




As you can see in the 3Dpdf you can download here, the opacity is pretty kinky when it comes to overlaying semi transparent layers (backside). I have no general solution, because the circumstances under which the opacity begins to bug may vary, and I did not fully understand its behaviour yet.
So here a few tips how you could bypass this problem:

- flip the normals of the top layer (requires double sided rendering, no specular highlight is possible)
- detach surfaces (with different directions) to separate objects
- attach surfaces that don't work well, despite flipping or detaching, to a newly created object and delete the element of the object you attached the surface to (this also works if your specular highlights don't work, but your normals are showing in the desired direction)

Your solution might be one, some or all of these points, but it requires sometimes some trial and error.


I used this method to create window frames in my TGV Lyon Scene (Filesize 10mb / 256mb video memory).

The bandwidth is kindly offered by: active-servers


Edit:
If you wish to combine transparancy, bump map and reflection map you cannot use tiff with alpha channel, instead of that use separate jpg's (don't forget to uncheck ICC Profile in Photoshop).

3 comments:

  1. HI! May I know how did you set the "ground collision on/off" button in TGV Lyon Scene?

    ReplyDelete
  2. Hi Li,
    the ground collision goes back to a tutorial provided by adobe, I don't know which one it was again, but here is the script you attach to your 3d annotation (not knowing how deep you are into scripting):

    //minimum z value
    var camz= 0

    //camera collision script:
    mouseEventHandler = new MouseEventHandler();
    mouseEventHandler.onMouseMove = true;
    mouseEventHandler.onEvent = function( event )
    {
    if (cam.position.z < camz)
    cam.position.z = camz;
    }
    runtime.addEventHandler( mouseEventHandler );
    //end of collision script


    If you want to witch it on and off, you have to connect it to a button by an action.
    In the actions tab of your button choose "execute a javascript" with the following command:

    getAnnots3D(0)[0].context3D.action1 ("groundcollisionOn");

    The attached javascript of your 3d annotation got to be modified so it "reacts" to the executed action by the button:

    function action1 (groundcollisionOn)
    {
    //insert the collision script here
    }

    As this only turns on your ground collision, you will need a second button to turn it off again executing the following line:

    getAnnots3D(0)[0].context3D.action2 ("groundcollisionOff");


    To the attached javascript of your 3d annotation you would have to add the following lines to turn the collision off again:

    function action2 (groundcollisionOff)
    {
    runtime.removeEventHandler( mouseEventHandler );
    }

    With the show/hide fields function (actions tab of your button) you would have to make the buttons hide oneself and make it show the other one on mouse up, so you only have one button visible.
    Finally you got to define the initial visibility of the buttons under the "general" tab of your buttons and save the document.
    If you would like to have the collision on by default you would have to copy the collision script (I suggest to the top of your 3d annotation's javascript) so it is executed on opening the document, and invert your initial button visibility.

    I hope I could help, Chuck

    ReplyDelete
  3. Little correction to the post above:
    First you got to call the camera which you use the z value limitation on with:

    cam=scene.cameras.getByIndex(0)

    Otherwhise Acrobat doesn't know what cam means, sorry for that mistake.

    ReplyDelete