YOUR ACCOUNT

Login or Register to post new topics or replies
Betis
The Blacksmith

Posts: 1207
Filters: 76
Workin on a heavy-sampleage DOF script. Due to the nature of per-pixel scripting this is actually the opposite of how DOF works in reality, but sometimes it looks good anyway. Anyway my point is I'm trying to compile this and all it gives me is "syntax error" at the bottom where it the second-to-last line. I assume it's with all the breaks and loops that I havne't mastered in LUA yet.

Quote
function prepare()
blur = get_slider_input(ASIZE)*16
qual = get_intslider_input(QUAL)
rad = (2*math.pi)/qual
end;

function get_sample(x, y)
-- Image generation code goes here.
local r, g, b, a = get_sample_map(x, y, INPUT)
local d = get_sample_grayscale(x, y, DEPTH)
local t = get_sample_grayscale(x, y, F_THRESH)

local i, r

for i = 0, qual do
for r = 1, 4 do
local s = math.sin( rad*i )*(blur/r)*d
local c = math.cos( rad*i )*(blur/r)*d

if( get_sample_grayscale(x+s, y+c, DEPTH) < d ) then
break
end;

if( get_sample_grayscale(x+s, y+c, t) == 0 ) then
break
end;

r, g, b, a += get_sample_map(x+s, y+c, INPUT)
end;
end;

return r, g, b, a
end;


Edit: I took of the semicolons at the end of the if statements/ for loops but I get the same problem
Roses are #FF0000
Violets are #0000FF
All my base are belong to you.
  Details E-Mail
Sphinx.
Filter Optimizer

Posts: 1750
Filters: 39
Post the filter and I'll take a look at it smile:) (I can't determine your input setup)
  Details E-Mail
Betis
The Blacksmith

Posts: 1207
Filters: 76
I would suggest loading an image and it's respective depth map to get a clearer understanding of the previous nodes smile:)

Faux Lens Blur.ffxml
Roses are #FF0000
Violets are #0000FF
All my base are belong to you.
  Details E-Mail
Betis
The Blacksmith

Posts: 1207
Filters: 76
Okay I've been working on it and this one compiles but gives unexpected results, what am I not seeing?

Quote
function prepare()
blur = get_slider_input(ASIZE)*1
qual = get_intslider_input(QUAL)
rads = (2*math.pi)/qual
end;

function get_sample(x, y)
-- Image generation code goes here.
local r, g, b, a = get_sample_map(x, y, INPUT)
local d = get_sample_grayscale(x, y, DEPTH)

local i, radius

for i = 0, qual do
for radius = 1, 4 do
local s = math.sin( rads*i )*(blur/radius)*d
local c = math.cos( rads*i )*(blur/radius)*d

if( get_sample_grayscale(x+c, y+s, DEPTH) < d ) then
break
end

r, g, b, a = r + get_sample_map(x+c, y+s, INPUT),g + get_sample_map(x+c, y+s, INPUT),b + get_sample_map(x+c, y+s, INPUT),a + get_sample_map(x+c, y+s, INPUT)
r, g, b, a = r/(4*qual),g/(4*qual),b/(4*qual),a /(4*qual)
end
end

return r, g, b, a
end;
Roses are #FF0000
Violets are #0000FF
All my base are belong to you.
  Details E-Mail
Sphinx.
Filter Optimizer

Posts: 1750
Filters: 39
The problem is in the inner loop - your "normalization" part is not correct, and the conditional exit caused discontinuities, so I removed that.

I cleaned up the script and moved various calculations to more appropriate places (i.e. out of the the inner loop smile:eek: ). I'm sure you'll see the point of it..

I don't see weird cutoff artifacts now, but the displacement could use some work.

Note that I bypassed all the threshold stuff as I don't understand its purpose smile:-D

Faux Lens Blur - Sphinx.ffxml
  Details E-Mail
Betis
The Blacksmith

Posts: 1207
Filters: 76
I've been working on it today and thank you so much for your help sphinx! I'm good with C++ and java but this lua syntax is definitely weird smile:D

Here's a sample image at maximum sampling and maximum macroness smile8)
It took 2.5 minutes
(Looks like I can fix up some things)

Roses are #FF0000
Violets are #0000FF
All my base are belong to you.
  Details E-Mail
Sphinx.
Filter Optimizer

Posts: 1750
Filters: 39
  Details E-Mail
Betis
The Blacksmith

Posts: 1207
Filters: 76
Here is the original :}

Roses are #FF0000
Violets are #0000FF
All my base are belong to you.
  Details E-Mail

Join Our Community!

Filter Forge has a thriving, vibrant, knowledgeable user community. Feel free to join us and have fun!

33,711 Registered Users
+18 new in 30 days!

153,533 Posts
+38 new in 30 days!

15,348 Topics
+73 new in year!

Create an Account

Online Users Last minute:

27 unregistered users.