Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - liquid8d

Pages: 1 ... 28 29 [30]
436
Scripting / Re: Share some Shader info
« on: June 06, 2014, 05:29:49 PM »
Ah, that blur is cool.. I do understand vertices in the context of graphics, I guess I just need to see a few in action to understand how it can modify it.

Pretty much anything except for C stuff I am fine with. I probably should put some effort into it though :)

contrast.frag
Code: [Select]
//https://code.google.com/p/ewigehoffnung/source/browse/lib/glsl/contrast.frag
uniform sampler2D texture;
void main()
{   
    float contrast = 2.0;
    vec4 color = texture2D(texture, gl_TexCoord[0].xy);

    color = (color-0.5)*contrast + 0.5;

    gl_FragColor.rgb = color.rgb;
    gl_FragColor.a = 1.0;
}

sepiatone.frag
Code: [Select]
//https://code.google.com/p/ewigehoffnung/source/browse/lib/glsl/sepia.frag
uniform sampler2D texture;
void main()
{   
    vec4 Sepia1 = vec4( 0.2, 0.05, 0.0, 1.0 );   
    vec4 Sepia2 = vec4( 1.0, 0.9, 0.5, 1.0 );

    vec4 Color = texture2D(texture, vec2(gl_TexCoord[0]));

    float SepiaMix = dot(vec3(0.3, 0.59, 0.11), vec3(Color));
    Color = mix(Color, vec4(SepiaMix), vec4(0.5));
    vec4 Sepia = mix(Sepia1, Sepia2, SepiaMix);

    gl_FragColor = mix(Color, Sepia, 1.0);
}

I tried to modify this screen flicker one, because it would be a cool effect, but I couldn't quite get what I wanted:
http://glsl.heroku.com/e#17112.0

437
Scripting / Re: Dynamic change res
« on: June 06, 2014, 04:57:10 PM »
hmm, interesting... it doesn't seem to pick up rotations from the hotkeys, only if you change it from your layout (i.e. fe.layout.orient = RotateScreen.Right;) That seems like a bug.

I also didn't realize this:
"a layout could provide a "layout.nut" for horizontal monitor orientations and a "layout-vert.nut" for vertical"

I need to mess with vertical layouts more.. I cheaped out and didn't get a rotating mount (expensive!) for the tv I am using, so I don't use vertical layouts :/

438
Scripting / Share some Shader info
« on: June 05, 2014, 03:58:20 PM »
The other day, I started to mess with shaders, which was... fun? :) I have done practically no C programming and zero graphics or game development, so this was all new to me. There was only one example I saw in the orbit layout (bloom) so I started looking around..

This has a couple cool things that I was able to implement:
http://www.geeks3d.com/shader-library/

Here is a site where you can play around with stuff:
https://www.shadertoy.com/new#

And here is a site where people have played around (WARNING: no joke, some of these could probably induce an epileptic seizure):
http://glsl.heroku.com/

Here is the ones I thought were pretty cool and maybe useful:

pixelate.frag
Code: [Select]
//http://www.geeks3d.com/20101029/shader-library-pixelation-post-processing-effect-glsl/
uniform sampler2D texture;
void main()
{   
    float rt_w = 480.0;
    float rt_h = 360.0;
    float pixel_w = 4.0;
    float pixel_h = 2.0;
   
    vec2 uv = gl_TexCoord[0].xy;

    vec3 tc = vec3(1.0, 0.0, 0.0);
    float dx = pixel_w*(1./rt_w);
    float dy = pixel_h*(1./rt_h);
    vec2 coord = vec2(dx*floor(uv.x/dx),
                      dy*floor(uv.y/dy));
    tc = texture2D(texture, coord).rgb;
    gl_FragColor = vec4(tc, 1.0);
}

ripple.frag
Code: [Select]
//http://www.geeks3d.com/20110316/shader-library-simple-2d-effects-sphere-and-ripple-in-glsl/
uniform sampler2D texture;
uniform float ttime;

void main()
{   
    float time = ttime / 1000.0;
    vec2 tc = gl_TexCoord[0].xy;
    vec2 p = -1.0 + 2.0 * tc;
    float len = length(p);
    vec2 uv = tc + (p/len)*cos(len*12.0-time*4.0)*0.03;
    vec3 col = texture2D(texture,uv).xyz;
    gl_FragColor = vec4(col,1.0);
}

Ripple requires you to send a parameter, ttime, so your layout.nut would look something like:
Code: [Select]
local fshader = fe.add_shader(Shader.Fragment, "pixelate.frag");
fshader.set_texture_param("texture");

local snap = fe.add_artwork("snap", 50, 50, 480, 360);
snap.shader = fshader;

fe.add_ticks_callback("onTick");

function onTick( ttime ) {
    fshader.set_param("ttime", ttime);
}



scanlines.frag
Code: [Select]
//http://glsl.heroku.com/e#15689.0

uniform sampler2D texture;

void main()
{
    vec4 pixel = texture2D(texture, gl_TexCoord[0].xy);
    gl_FragColor = pixel - vec4( step(1.0,mod(gl_FragCoord.y,2.0)) );
}


I tried to convert these as best I could and I only really grasped a little about fragment shaders - vertex is still a bit of a mystery to me. So, I guess.. share your shader info?? :)

439
Scripting / Re: Dynamic change res
« on: June 05, 2014, 03:36:53 PM »
Looks nice, I'll have to check this one out.. for now, you could probably check fe.layout.orient in onTick.

This would be a good reason to think about adding callbacks to AM. Just like how onTransition is triggered for transitions but for other events that occur so you don't have to keep checking them in onTick. I added generic callback functions in ExtendedObjects where anything that wants to can run something like 'ExtendedObjects.run_callback('onRotationChanged', params), then any .nut files or class can register and listen for that callback and act on it.

A bunch of other things could probably be added like ScreenSaverActive, onKeyPress, etc. with parameters included.

440
Scripting / Re: ExtendedObjects and Animate library
« on: June 05, 2014, 03:25:21 PM »
raygun,

That sounds great, I'll definitely take a look at it.. at some point once it's a little more polished, I want to make sure it is as easy as possible to add in. I wonder does that conflict or overlap with plugins? Something to think about.

Luke,
Thanks! Looking forward to some people trying it out.

It still has a few kinks to work out..  the addition of system should be extremely helpful with clock() because I was having to do a workaround on tracking animation times between onTick (which stops while onTransition returns true) and onTransition :)

441
Scripting / ExtendedObjects and Animate library
« on: June 04, 2014, 08:38:55 PM »
This is a set of extensions I am working on for Attract-Mode:

https://github.com/liquid8d/attract-extra/tree/master/layouts/extended

I say extensions because it's a set of .nut files that can be added to any layout that will extend the capabilities of AM.

ExtendedObjects
Currently, ExtendedObjects is primarily a wrapper around the current Fe.Text, Fe.Image, Fe.ListBox objects with some helper functions to  make it easier to work with your layout objects.

ExtendedObjects has the typical .add_text, .add_image, .add_artwork, and .add_listbox functions, just with an addition of an object id as the first parameter. Returned to you is a new class of that object: ExtendedText, ExtendedImage, ExtendedArtwork and ExtendedListBox. One major difference in these new classes is you don't get or set variables directly:
obj.x becomes obj.getX() or obj.setX(x)
obj.y becomes obj.getY() or obj.setY(y)
...

This is so the extended objects class can do some stuff whenever variables are changed. My initial reason for doing this was to add animation to the objects (modify x and y), but it kind of grew from there.

Benefits

Custom Objects:
You can extend the new classes which not only will take advantage of the additions of ExtendedObjects but allow you to combine multiple objects as one. This would allow someone to create for instance a full marquee wheel that can then be its own object.

Layers:
With the addition of surfaces in 1.3, ExtendedObjects will create a layered system where you can add objects to different layers. This means you don't have to create objects in the order you want them displayed.

Debugging System:
I wrote a debug system that makes use of ExtendedObjects. When enabled, text boxes are overlayed over every object in your layout which can help with debugging.

Positioning:
A full set of functions to help you position objects, you can use something like obj.setPosition("center") instead of having to do something like (fe.layout.width / 2) - (obj.width / 2), (fe.layout.height / 2) - (obj.height / 2)

Animations:
Why I originally wrote this, you can add animation effects to any object.

Animation
As I played with the onTick and onTransition functions and looked at examples, I saw how powerful it could be. I thought it would be a pain to create some animation effects every time I wanted something in a layout, so I began building the animate extension.

I did a lot of research to get animation working, since I know very little about it :) I had to write a custom onTick and onTransition to handle everything and it includes all kinds of neat easing functions. Everything is pretty much done by just telling it which object to animate and providing a config table. It looks like this:

Code: [Select]
local animConfig = {
   which = "translate",
   when = Transition.FromOldSelection,
   duration = 1500,
   from = "offleft",
   to = "left"
}
obj.animate(animConfig);

Benefits

Builtin easing functions:
You can specify the animation "effects" using the easing and tween config options. For examples, you can look at something like:
http://matthewlein.com/experiments/easing.html

Pre-included animations:
I have two currently, property and translate. Property animates a property (like alpha, skew, size or rotation) and translate moves objects.

Custom animations:
I have a boiler-plate template for creating your own animations where all you initialize, then handle start, frame and stop functions. There is an example animations on github to check out.

Animation sets:
I haven't done much with this yet, but intend on creating some already put together configs for common animations, for instance fade out a snapshot on transition, then fade it back in.

Particle animations:
A new animation I am working on which will essentially mirror the particle effects of HyperTheme. It's pretty cool.

Feedback
I'm still trying to figure out what all to do with this thing, but I want it to be user friendly and provide helpful functions to make creating layouts easier. If you get a chance to play around with it, I'd love to hear some feedback. It's fairly well documented on the github page, but as I make changes, some things might not have been updated. Let me know if you have any issues or questions!

442
Scripting / Learning Squirrel
« on: June 04, 2014, 07:22:42 PM »
Here is a great walkthrough to quickly learning squirrel:

http://electricimp.com/docs/resources/squirrelcrib/

Pages: 1 ... 28 29 [30]