why DirectionalLight is not casting shadow? - libgdx

Code:
Color color = new Color(1f,1f,1f,0.9f);
DirectionalLight directionalLight = new DirectionalLight(rayHandler,200,color,-90f);
directionalLight.setSoftnessLength(0);
Result:
When light falls directly from above, why it is not casting shadows from boxes?

This could be caused by a few things. Some things to check:
Check if your RayHandler is set to blur. Blurring with small objects can hide shadows.
Check the Shadows are enabled in the ray handler.
Check the ambient light is off or lower than the directional light. If ambient light is too high it may hide shadows.
Check your objects are larger than 0.1f as this is the smallest distance box2dlights works with
Check the light is not set to x-ray
check softness length. lights with high softness will have their light bleed through small objects.

Related

Can we have soft shadows using Aframe?

I'm trying to have a better render on my scene. So I added directional and ambiant lights. So Shadows are generated. Here's the
Result
I wonder if there is a way to have softer shadows.
The model has been created with Sweet Home : http://www.sweethome3d.com/
On the scene element, you could try to change the default type of the shadows:
<a-scene shadow="type: pcfsoft">
https://aframe.io/docs/0.8.0/components/shadow.html#scene_properties_type
Also worth experimenting with the properties on the light itself:
Adjust the shadow camera position and frustum (shadowCameraTop, shadowCameraRight, …) of the directional light, until it envelops the scene tightly. If the frustum is too small, shadows will be missing or partially clipped. If the frustum is too large, shadows will appear coarse or pixelated
https://aframe.io/docs/0.8.0/components/light.html#adding-real-time-shadows
https://aframe.io/docs/0.8.0/components/light.html#configuring-shadows
Turn up the ambient light to change the shadow color.
Play with light.shadowRadius property (currently master branch of A-Frame). And decrease shadow map resolution.
<a-scene shadow="type: pcfsoft">

Flash color transform

I'm having difficulty with transforming colour in Flash. It should be easy I think, but for some reason my code isn't working as expected.
I have a bitmap graphic consisting of a colour spectrum from red to yellow to green (you know, like you see in an audio level meter).
I simply want to sample a colour from that bitmap and then tint a movie clip on stage that sampled colour. (the effect I'll be going for is coloured progress - the closer you get to 100% green is displayed, the closer you are to 0% it's red - I haven't implemented that part yet, but I'm not worried about that).
Anyhow, I sample the colour just fine, and tint my clip, but no matter what I tint the clip it comes up a different colour than what I've sampled (the trace is a different colour than what I see on the clip). I can't see where I'm going wrong - I'm hoping it's a stupid mistake and someone can spot it easily.
import flash.display.BitmapData;
var bmd:BitmapData = new BitmapData(mc_colourbar.width, mc_colourbar.height);
bmd.draw(mc_colourbar);
var pixelvalue:uint = bmd.getPixel(0, 1);
trace(pixelvalue.toString(16));
var colourtransform:ColorTransform = mc_box.transform.colorTransform;
colourtransform.color = uint("0xff" + pixelvalue);
mc_box.transform.colorTransform = colourtransform ;
mc_box is the clip on stage I'm trying to tint - it's simply a white square.
Any help is appreciated, thanks in advance!
ColorTransform.color expects an RGB value, and it appears as though you're attempting to give it an ARGB value*.
Change the line:
colourtransform.color = uint("0xff" + pixelvalue);
to just:
colourtransform.color = pixelvalue;
and your code should work as expected.
*Though I don't think the way you're trying to do it here is correct.

The intersection part of CSS Canvas paths seem to have incorrect color.

I'm trying to draw a path using HTML Canvas. It consists of several Bezier curves linked together. For some reason, I cannot draw the whole path and then stroke. Instead, I need to stroke for each Bezier curve. I'm using a light purple color as the stroke color, but at the intersection of the curves, I seem to get something like white instead of the light purple I expect. Like this (sorry I can't post an image since I'm new on Stack Overflow):
I'm using stroke style with opacity 1, so I believe it's not a transparency issue. So what might be causing this problem?
FYI, I'm drawing each Bezier curve with code like this, where a is the drawing context of the canvas, and this.bloom.c is something like "rgba(xxx,xxx,xxx,1)":
a.strokeStyle = this.bloom.c;
a.beginPath();
a.moveTo(e.x, e.y);
a.bezierCurveTo(c.x, c.y, b.x, b.y, d.x, d.y);
a.stroke();
Thanks very much!
Use the appropriate "blend modes" natively supported by HTML5 Canvas context for Composite Operations. In your case you may use 'source-over'
For example:
var context = document.getElementById('myCanvas').getContext('2d');
context.globalCompositeOperation = 'source-over';
See Compositing and Blending 1.0
source-atop
source-in
source-out
source-over
destination-atop
destination-in
destination-out
destination-over
lighter
xor
copy

how can I set the size of a directional light in Three.JS?

I've added a directional light to my scene, but it doesn't show all the shadow. The shadow gets cut off, just like when the FOV of a spotlight is too small.
When I enable the shadowCameraVisible, i see that my light is like a big box which shows the shadow (which makes sense). The question is: how can I make this 'box' bigger?
Found it! Turns out the shadowcamera has left, right, top and bottom properties:
light.shadowCameraLeft = -3000;
light.shadowCameraRight = 3000;
light.shadowCameraTop = 3500;
light.shadowCameraBottom = -3000;
If you get pixelized shadows, it means your shadow map (read: memory) is not big enough. Experiment which is the lowest map you need, because this seems to be expensive. Example:
light.shadow.mapSize.x = 2048
light.shadow.mapSize.y = 2048

Filter for overlapping circle objects in actionscript 3

Basically i have x circles represented as MovieClips.
They are all assigned the same base color (for example red).
They should all have a brightness property ranging from 0 to 1 (0 would be completely white and 1 completely red).
I would like the following properties for representing these circles on stage:
When the circles dont overlap they are represented as stated above.
When the circles overlap the overlapping region should have the same base color as the original circles but the brightness of that area should be the sum of the brightnesses of all the circles that define the overlap.
The brightness saturates at 1. So the overlap of 2 circles with brightness 0.8 is 1 (the maximum value) instead of 1.6.
I am wondering if there is some kind of BitmapFilter i could use on the circles to achieve these properties? Or am I looking in the wrong place?
I am relatively new to Actionscript so any pointers are welcome!
Hi and welcome to SO and AS3!
I'll take each point separately:
1) Quite simple, you've probably already figured out that "addChild()" will add MovieClip objects to the Display List, meaning Flash will render them every frame.
2) The easiest way to do this is through "Blend Modes", which is Adobe's way of handling overlapping display objects.
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/DisplayObject.html#blendMode
Try setting the .blendMode property of each circle to BlendMode.ADD:
var circle:MovieClip = new MovieClip();
circle.blendMode = BlendMode.ADD;
3) If BlendMode.ADD doesn't give you the results you want, try creating a custom shader to do the job.
http://help.adobe.com/en_US/as3/dev/WSB19E965E-CCD2-4174-8077-8E5D0141A4A8.html
IMHO Blendmode is the easiest way of achieving the desired effect, and blendShader if you want precise customization. Please comment if you have further questions!
Some tutorials and examples:
http://www.learningactionscript3.com/2007/11/03/more-properties-blendmodes-filters/
http://active.tutsplus.com/tutorials/games/introducing-blend-modes-in-flash/
Cheers,
J