Closed mrcdk closed 9 years ago
The interface is really intuitive, congrats!
Wow, pretty! Hey, it worked fine in neko, but not html5 for me (and the away3d examples worked in html5, so I assume it's not a hardware issue.) html5 (on the right) just sits there: Nvm, I keep forgetting to use -Dwebgl
with html5 target.
Oh, I see this PR is fairly old, I assumed it was updated with @mrcdk 's shaders_again branch, no?
Also, fyi, once I start rotating or translating the shape, the light doesn't track the mouse. I tried various combinations of globalToLocal, or sprite.mouseX/Y, but I couldn't get the light to properly track the sprite once I altered the positioning of the sprite.
Of importance to these shaders, since they apply to displayobjects, is that it's obvious how to interact with the shader varibles appropriately in the (potentially transformed) displaylist.
Are you compiling html5 with webgl? haxelib run lime test html5 -Dwebgl
You're right, sorry -- I keep forgetting the in html5 target, -Dwebgl
isn't the default. It worked!
It's old but they should work. I'll close it and open a new one later.
You will have to modify the code to do that. Right now it takes the global coordinates of the mouse and tells the shader what the size of that global coordinate will be. What you want to do are local coordinates so you have to tell the shader the local coordinates of the point and the local size of the object.
sprite.x = 100;
sprite.y = -100;
sprite.rotation = 20;
stage.addEventListener(MouseEvent.MOUSE_MOVE, function(e:MouseEvent) {
lightShader.uLightPos[0] = sprite.mouseX;
lightShader.uLightPos[1] = sprite.mouseY;
});
stage.addEventListener(MouseEvent.MOUSE_WHEEL, function(e:MouseEvent) {
lightShader.uLightPos[2] += e.delta * 0.005;
});
var bounds;
stage.addEventListener(Event.RESIZE, function(_) {
bounds = sprite.getBounds(null);
lightShader.uResolution = [bounds.width, bounds.height];
});
Cool, thanks for the info. And thanks for all your work on this!
It needs this PR https://github.com/openfl/openfl/pull/697
Don't merge yet, let's see if people like how it works.