kernel Glass < nameSpace: "f4f::Shaders"; vendor: "Manuel Bua"; version: 1; description: "Displace original pixels to simulate a glassy look-through"; > { parameter float displaceIntensity < minValue: 1.; maxValue: 100.; defaultValue: 30.; >; parameter float offsetX < minValue: -1.; maxValue: 1.; defaultValue: 0.; >; parameter float offsetY < minValue: -1.; maxValue: 1.; defaultValue: 0.; >; parameter float offsetScale < minValue: 1.; maxValue: 200.; defaultValue: 100.; >; parameter float displaceScale < minValue: .1; maxValue: 2.; defaultValue: .4; >; void evaluatePixel( in image4 img1, in image4 img2, out pixel4 result ) { float2 pos = outCoord(); float2 srcPos = pos; srcPos.x += offsetX * offsetScale; srcPos.y += offsetY * offsetScale; float4 normal = 2. * ( sampleLinear( img2, pos * displaceScale ) - .5 ); pixel4 res = sampleLinear( img1, srcPos + ( normal.xy * displaceIntensity ) ); res.a = normal.z; result = res;// + sampleLinear( img1, srcPos + ( normal.xy * displaceIntensity ) ) * .4; } }