-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
optimize and switch to single-sample processing
- Loading branch information
Showing
7 changed files
with
221 additions
and
130 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
header = [[ | ||
// THIS FILE IS AUTOGENERATED // | ||
// DO NOT EDIT THIS MANUALLY // | ||
#pragma once | ||
const float lut_expo_256[256] = { | ||
]] | ||
|
||
footer = "\n};\n" | ||
|
||
-- expects values 0..255 | ||
-- outputs must be 0.f~1.f | ||
function expo(i) | ||
local c = i / 255 -- convert 0,255 into 0,1 | ||
-- return 2 ^ (10 * (c-1)) -- expo approximation (obvs could do real expo if we want?) | ||
return 1 - math.sqrt(1 - c^2) -- expo as a quarter circle for max smoothness | ||
end | ||
|
||
function logo(i) | ||
local c = i / 255 -- convert 0,255 into 0,1 | ||
-- return 1 - (2 ^ (-10 * c)) -- log approximation (obvs could do real expo if we want?) | ||
return math.sqrt(2*c - c^2) -- log as a quarter circle for max smoothness | ||
end | ||
|
||
function build_table() | ||
s = header | ||
t = {} | ||
for i=0,255 do | ||
t[i+1] = expo(i) | ||
end | ||
print(t[1]) | ||
print(t[2]) | ||
print(t[3]) | ||
print(t[4]) | ||
print(t[127]) | ||
print(t[128]) | ||
print(t[255]) | ||
print(t[256]) | ||
s = s .. table.concat(t, ", ") | ||
return s .. footer | ||
end | ||
|
||
local out_file = arg[1] | ||
|
||
-- build_table() | ||
|
||
do | ||
f = io.open(out_file, 'w') | ||
f:write(build_table()) | ||
f:close() | ||
end | ||
|
||
-- example usage: | ||
-- lua scripts/lin2exp.lua lib/lin2exp.h |
Oops, something went wrong.