+ Add settings for photo size, render distance, supersampling
This commit is contained in:
parent
6290c3394d
commit
389ca7db8d
15
init.lua
15
init.lua
|
@ -15,6 +15,10 @@ Codezeilen und schreibe das auch nicht dran.
|
|||
|
||||
]]--
|
||||
|
||||
local get_setting = function( key, default_value )
|
||||
return tonumber( minetest.settings:get( key ) or default_value )
|
||||
end
|
||||
|
||||
local create_photo_item = function( pixels )
|
||||
local itemstack = ItemStack( "xcam:photo" )
|
||||
local meta = itemstack:get_meta()
|
||||
|
@ -103,8 +107,10 @@ x_offset_by_sample = { 0, 1, 0, 1, 0, 1,-1,-1,-1 }
|
|||
y_offset_by_sample = { 0, 0, 1, 1,-1,-1, 0, 1,-1 }
|
||||
|
||||
local create_photo_pixels = function( player_name )
|
||||
local width = 128
|
||||
local height = 128
|
||||
local width = get_setting( "xcam_photo_height", 128 )
|
||||
local height = get_setting( "xcam_photo_width", 128 )
|
||||
local render_distance = get_setting( "xcam_render_distance", 128 )
|
||||
local samples = get_setting( "xcam_supersampling_samples", 4 )
|
||||
local girl = minetest.get_player_by_name( player_name )
|
||||
local eye = girl:get_pos() + girl:get_eye_offset() / 10
|
||||
eye.y = eye.y + girl:get_properties().eye_height
|
||||
|
@ -128,7 +134,6 @@ local create_photo_pixels = function( player_name )
|
|||
for w = 1,width,1 do
|
||||
local x = width - ( w - 1 )
|
||||
local sky_color = 191 - math.floor ( y / 2 )
|
||||
local samples = 4 -- can be up to 9
|
||||
local acc_color = 0
|
||||
for sample = 1,samples,1 do
|
||||
local x_offset = x_offset_by_sample[sample] * 0.2
|
||||
|
@ -138,7 +143,9 @@ local create_photo_pixels = function( player_name )
|
|||
down * ( height/2 - y + y_offset )
|
||||
)
|
||||
local pos1 = eye
|
||||
local pos2 = eye + lens + ( dir * 128 )
|
||||
local pos2 = eye + lens + (
|
||||
dir * render_distance
|
||||
)
|
||||
local color, hit_water = shade(
|
||||
pos1,
|
||||
pos2,
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
xcam_photo_height (Xcam Photo Height) int 128 16 192
|
||||
xcam_photo_width (Xcam Photo Width) int 128 16 192
|
||||
xcam_render_distance (Xcam Render Distance) float 128.0 1.0 256.0
|
||||
xcam_supersampling_samples (Xcam Supersampling Samples) int 4 1 9
|
Loading…
Reference in New Issue