Archive for January, 2008



18
Jan
08

HLSL to GLSL

I’ve been attempting to convert an HLSL Pixel Shader from the VVVV website, into a GLSL Fragment Shader, with what could be termed ‘mixed success’.

I’ve managed to convert all the variables, and was hoping that the underlying algorithms, which I left exactly as they were, would produce a usable result. I haven’t managed to get anything like the screenshot on the website. I don’t understand the mathematics, so I have no idea where to start debugging it.

A useful exercise, maybe, but not entirely a successful one.

Advertisements
18
Jan
08

ScribeFire Test

Just testing ScribeFire, a blogging plugin for FireFox.I’m hoping it will solve my line/paragraph break annoyance.

16
Jan
08

Swizzling

My simplest effect yet. Simply mixes from original image to two different channel-shifted variants, then back to the original image.

The key is the ‘.’ swizzle operator, which allows the Red Blue, Green and Alpha channels of the image to be rearranged. Also notice that the Mix variable goes from 0.0 to just less than 3.0, and I use the fract function to extract the part of the number after the decimal point, and use this to mix between 2 variants, as well as to swap the start and end of the mix operation with values above 1.0 and 2.0.

Simple, but cool.

/*Inputs:
Image: input image
Mix: mix between original and channel-shifted variants. Range 0.0 > 2.999
*/

kernel vec4 swizzler(sampler Image, float Mix)
{
vec4 pix = unpremultiply(sample(Image, samplerCoord(Image)));
vec4 outPix = (Mix <= 1.0) ? mix(pix.rgba, pix.brga, fract(Mix)) : (Mix <= 2.0) ? mix(pix.brga, pix.gbra, fract(Mix)) : mix(pix.gbra, pix.rgba, fract(Mix)); return premultiply(outPix); }[/code]

15
Jan
08

slideTileTest150108

New FX.
This one is yet another slight variation on the theme of pixellation. In this permutation, the image ’tiles’ are moved around, either randomly, or based on the brightness of the pixel at the centre of each tile, yielding a surprisingly large range of glitchy effects.

slideTileTest150108 02slideTileTest150108 03
slideTileTest150108 04slideTileTest150108 07
slideTileTest150108 08slideTileTest150108 09

Here’s the CI Filter code:

/*
Inputs:
sampler Image: input image
sampler DisplaceImg: displacement image
vec2 Tile: X and Y tile size. Range, image width/height > 1.0
float Threshold: threshold value for Displacement image R and G color value below which image tile is moved. Range 0.0 > 1.0
float Randomise: Mix of noise and original image as displacement value. Rangle 0.0 > 1.0
*/

kernel vec4 tb_slideTile(sampler Image, sampler DisplaceImg, vec2 Tile, float Threshold, float Randomise)
{
// Current pixel pos. in pixels
vec2 xy = samplerCoord(Image);
// Dimensions of input image
vec2 dims = samplerSize(Image);
// Normalised pix coords
vec2 normCoord = xy / dims;

// Centre-point of current tile
vec2 tileCenter = (floor(normCoord / Tile) * Tile) + (0.5 * Tile);
// Displacement image pixel at center of current tile
vec4 displacePix = mix(unpremultiply(sample(Image, tileCenter * dims)), sample(DisplaceImg, tileCenter * dims), Randomise);

// Position of current pixel in current tile
vec2 tilePos = normCoord – (tileCenter – (0.5 * Tile));

// Calculte sample position based on R and G values of displacePix
vec2 samplePos = vec2(displacePix.r,displacePix.g);
// Clamp coords so they remain in screen bounds
samplePos = clamp(samplePos,vec2(0.0,0.0), vec2(1.0,1.0) – Tile);
// Increment coords to draw tile content
samplePos += tilePos;

// Coordinates to sample original input image
samplePos = (displacePix.r < Threshold) ? (displacePix.g < Threshold) ? samplePos : normCoord : normCoord; // Denormalise sample coords samplePos *= dims; // Output return sample(Image, samplePos); }[/code]

15
Jan
08

blurPixellate 1.0 (Tiger) Uploaded

Just uploaded a version of the blurry pixellation effect to Memo’s qcFX archive.

tb blurPixellate 1.0 (Tiger)

13
Jan
08

Blend Modes CIFilter

I’ve been investigating different ways of implementing various blending and compositing effects with a single filter patch. I initially began by converting some HLSL code I found that emulated the standard Photoshop layer blend modes, then discovered a list of alternative methods in the GLSL Orange Book. I got half-way through typing these into a CI Filter patch, when it occured to me that I could just as easily use the JavaScript option to apply the builtin system blend modes, like so:

CIKernel Code (top panel):

/*
Fades alpha of image.
*/
kernel vec4 alphaFade(sampler image, float Opacity)
{
vec4 pix =  sample(image, samplerCoord(image));
pix.a = pix.a * Opacity;
return pix;
}

JavaScript (bottom panel):

function __image main(__image Image, __image Background_Image, __index Mode, __number Opacity) {
// RIO, DOD
function myROIFunction(samplerIndex, dstRect, info) {
return dstRect;
}
// Dimensions of top image
var Width = Image.extent.width;
var Height = Image.extent.height;
var dodRect = new Vec(0.0, 0.0, Width, Height);

// Set opacity of top image
alphaFade.ROIHandler = myROIFunction;
Foreground_Image = alphaFade.apply(dodRect, dodRect, Image, Opacity);

// Set blend mode from Mode index
switch(Mode) {
case 0:
// Normal (Foreground and Background reversed, for some reason)
var result = Filter.CISourceOverCompositing(Foreground_Image, Background_Image);
break;
case 1:
// Darken
var result = Filter.CIDarkenBlendMode(Background_Image, Foreground_Image);
break;
case 2:
// Multiply
var result = Filter.CIMultiplyBlendMode(Background_Image, Foreground_Image);
break;
case 3:
// Color Burn
var result = Filter.CIColorBurnBlendMode(Background_Image, Foreground_Image);
break;
case 4:
// Lighten
var result = Filter.CILightenBlendMode(Background_Image, Foreground_Image);
break;
case 5:
// Screen
var result = Filter.CIScreenBlendMode(Background_Image, Foreground_Image);
break;
case 6:
// Color Dodge
var result = Filter.CIColorDodgeBlendMode(Background_Image, Foreground_Image);
break;
case 7:
// Add
var result = Filter.CIAdditionCompositing(Background_Image, Foreground_Image);
break;
case 8:
// Overlay
var result = Filter.CIOverlayBlendMode(Background_Image, Foreground_Image);
break;
case 9:
// Soft Light
var result = Filter.CISoftLightBlendMode(Background_Image, Foreground_Image);
break;
case 10:
// Hard Light
var result = Filter.CIHardLightBlendMode(Background_Image, Foreground_Image);
break;
case 11:
// Difference
var result = Filter.CIDifferenceBlendMode(Background_Image, Foreground_Image);
break;
case 12:
// Exclusion
var result = Filter.CIExclusionBlendMode(Background_Image, Foreground_Image);
break;
case 13:
// Hue
var result = Filter.CIHueBlendMode(Background_Image, Foreground_Image);
break;
case 14:
// Saturation
var result = Filter.CISaturationBlendMode(Background_Image, Foreground_Image);
break;
case 15:
// Color
var result = Filter.CIColorBlendMode(Background_Image, Foreground_Image);
break;
case 16:
// Luminosity
var result = Filter.CILuminosityBlendMode(Background_Image, Foreground_Image);
break;
}

// Output
return result;
}

The order of the modes in the list is based on the order they’re listed in the Photoshop Layer Blend Mode menu (though there isn’t an equivalent to all the Photoshop modes, as far as I can tell). I thought it made more sense to list them this way, rather than alphabetically, as the order in PS is based on the visual effect of each mode.

The ‘Labelled Indices’ Splitter patch option lets me create a named list of the available options, which is a nice touch, I think.

Blend Modes CIFilter

Obviously, this won’t work in Tiger, so I’ll probably complete the Orange Book-based one too, for downward-compatibility.

11
Jan
08

Vimeo

I’ve just created a Vimeo account for myself, so expect to see more movieclips soon!




Twitter

January 2008
M T W T F S S
« Dec   Feb »
 123456
78910111213
14151617181920
21222324252627
28293031  

Links

Blog Stats

  • 487,906 hits
Advertisements