PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
Shadowmasters! Proper castshadow fall off?
A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Shadowmasters! Proper castshadow fall off?

  1. #1
    Interested User Rohm's Avatar
    Join Date
    Aug 2004
    Location
    Sweden
    Posts
    214

    Question Shadowmasters! Proper castshadow fall off?

    Is there a way in CS4 to make a proper cast shadow falloff from graphic objects. Where the shadow is hard closer to the object and blurrier the futher away from it.
    I just dont seem to find anywhere in flash where I can control the blurryness by an alpha channel. I've tried even with mask layers that goes from 0% alpha to 100% but that didn't work either.

    Is it possible or do I have to make bitmapped in photshop and then put them in the timeline.
    There is "actionally" a truth to be found in flash.

  2. #2
    Senior Moderator
    Defender of the Faith
    Pope de Flash's Avatar
    Join Date
    Feb 2000
    Posts
    3,429
    Are you trying to code this or use the filter property?

    If you want to do it using code your going to have to call to the filter ie filter.blurY=40;

    Actionscript Code:
    import flash.filters.DropShadowFilter;
    var mc:MovieClip = createDropShadowRectangle("DropShadowBlurY");
    mc.onRelease = function() {
        var filter:DropShadowFilter = this.filters[0];
        filter.blurY = 40;
        this.filters = new Array(filter);
    }

    function createDropShadowRectangle(name:String):MovieClip {
        var art:MovieClip = this.createEmptyMovieClip(name, this.getNextHighestDepth());
        var w:Number = 100;
        var h:Number = 100;
        art.beginFill(0x003366);
        art.lineTo(w, 0);
        art.lineTo(w, h);
        art.lineTo(0, h);
        art.lineTo(0, 0);
        art._x = 20;
        art._y = 20;

        var filter:DropShadowFilter = new DropShadowFilter(15, 45, 0x000000, 0.8, 16, 16, 1, 3, false, false, false);
        var filterArray:Array = new Array();
        filterArray.push(filter);
        art.filters = filterArray;
        return art;
    }
    Macromedians 1:1

    In the beginning the web was without shape and color, and the hype covered the darkness of the net. Then there was a Flash and life came to the web and vision became reality.

    Footer... We dont need no Stinking Footers!!!!

  3. #3
    Interested User Rohm's Avatar
    Join Date
    Aug 2004
    Location
    Sweden
    Posts
    214
    I was only trying to use the filter property in this case but if I have to code it I would, I have to use AS3 though 'cus the file uses that allready.

    Your shadow is nice but not the thing I'm looking for
    Here is an example what I mean

    As you see a proper shadow gets hit by stray light from all around which means its crisp close to the object and very blurry and faded the futher away it is.

    Is THAT possible top achieve?
    There is "actionally" a truth to be found in flash.

  4. #4
    Senior Member
    Join Date
    Sep 2008
    Posts
    100

    Talking

    Well... the only approach I can imagine is the approach of using actual 3d.

    I'm making my own 3d engine right now. I don't have lighting but I got the idea of how I'll do it already.

    Basically the idea I have is to make it so that every polygon has two elements for coloring, even bitmapdata textured ones. The first element is the polys actual color. The polys actual color can be specified by the person while setting up the object, or even with an image. Like usual the image would be chopped up till the amount of bitmapdatas matches the amount of polys in the object. Then, for each of the bitmapdatas, it loops through its width and height to find the color values of each pixel. When the color value is found, it uses a small process to find out what the color values are for the r g and b separately. so basically it just keeps looping through the bmds till all of them are searched through.

    But what it does with the r g and b values it gets while its looping is finds out whether or not the r g b is higher than the current highest r g b. and if it is higher then it sets the highest red value to the new highest red value, same with blue and green. Keep in mind that it doesn't matter if the pixel holding the highest red is different than the pixel holding the highest green or blue.

    Basic idea, for each bitmapdata, find the highest red green and blue values possible within the bmd.


    Well anyway the polys highest r g b can be set with your own numbers or with a bmds highest numbers.

    Then next up comes the second color factor for the polygons, its quite simple.

    Basically the lighting is just like the polys natural color, only holds r g and b, if you feel like it you can have both of them specify alpha as well. the only real difference is, lighting is the actual drawn color for the poly, and it actually it dependent on two factors.

    With the lighting color of the poly, the lighting is default to black, in other words all r, g, and b are 0. And the lighting changes when a light ray hits it and transforms the lighting color of the poly to the lighting color of the light ray.

    And then what it does after it sets the polys lighting color to the lighting of the ray is simply checks if the color levels of the polys lighting is higher the color levels of the polys actual color and just simply makes it so the lighting gets set to the polys color. Each greater than check is individual of course.

    In the case of using just plain color and no texture, all you have to do is simply turn the lighting color back to a uint and do a beginfill using the lighting color.

    In the case of a texture fill you apply a color matrix filter to the bmd using the lighting colors. then use beginBitmapfill like usual. Keep in mind that in actual 3d, you have to use a tranformation matrix on the bmd to make it match the shape of the polygon it fills. But thats another topic entirely, I can't believe I said all this considering you will most likely not use it anyways.

    In case your wondering, this will only work if your actually using a 3d engine, and if you have a light element, the object that your lighting, and something behind it so that the shadow can be put on.

    Also, even though it seems like this doesn't target actual projection of a shadow from an object, it actually does, because keep in mind, when the light beams hit the objects they stop in their tracks, in other words, elements that would usually get that lighting are not because the object in front of it, and wherever lightbeams aren't hitting its already pitch black. Hence, shadow shapes are formed from places where light isn't hitting. Though a truly smooth shadow would require a form of smooth shading to make it look like the shape you want. Other wise the shape of the shadow is the same as the shape formed by the polys not receiving light beams.
    Last edited by cody112; 06-28-2010 at 12:56 PM.

  5. #5
    Interested User Rohm's Avatar
    Join Date
    Aug 2004
    Location
    Sweden
    Posts
    214
    Well you seem to have that bit under control.

    Yes you were right I will not be using this 'cus I've faked it through photoshop already.
    It's interesting to read anyway and most of it I knew and it would have been the best way to make it in 3d but that usually goes heavy on the processor so I was looking for a way to just make the shadow blurrier in one end compared to the other and fake it, since the object would only move in a certain way the blurryness would follow a linier scale and that could be made. I thought that maybe there was a way in flash to control that but it seemes that we will have to wait for that feature.

    Oh and I found that a good shadow and a decent 3d object can make the eye believe it more than just a really good 3D object.

    Thanx for the answer though.
    There is "actionally" a truth to be found in flash.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center