Skip to content

Commit

Permalink
Merge pull request #38 from Calinou/tweak-texture-size-limits
Browse files Browse the repository at this point in the history
Tweak texture size limits for consistency, set default size to 1024x1024
  • Loading branch information
RodZill4 committed Oct 20, 2019
2 parents 93dd1ca + 893e544 commit ede29a9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion addons/material_maker/engine/gen_buffer.gd
Expand Up @@ -20,7 +20,7 @@ func get_type_name():
return "Buffer"

func get_parameter_defs():
return [ { name="size", type="size", first=4, last=11, default=4 } ]
return [ { name="size", type="size", first=4, last=12, default=4 } ]

func get_input_defs():
return [ { name="in", type="rgba" } ]
Expand Down
15 changes: 12 additions & 3 deletions addons/material_maker/engine/gen_material.gd
Expand Up @@ -15,6 +15,15 @@ const TEXTURE_LIST = [
{ port=6, texture="depth_texture" }
]

# The minimum allowed texture size as a power-of-two exponent
const TEXTURE_SIZE_MIN = 4 # 16x16

# The maximum allowed texture size as a power-of-two exponent
const TEXTURE_SIZE_MAX = 12 # 4096x4096

# The default texture size as a power-of-two exponent
const TEXTURE_SIZE_DEFAULT = 10 # 1024x1024

func _ready():
texture_list = TEXTURE_LIST
for t in texture_list:
Expand All @@ -39,7 +48,7 @@ func get_parameter_defs():
{ name="normal_scale", label="Normal", type="float", min=0.0, max=8.0, step=0.05, default=1.0 },
{ name="ao_light_affect", label="Ambient occlusion", type="float", min=0.0, max=1.0, step=0.05, default=1.0 },
{ name="depth_scale", label="Depth", type="float", min=0.0, max=1.0, step=0.05, default=1.0 },
{ name="size", label="Size", type="size", first=7, last=11, default=9 }
{ name="size", label="Size", type="size", first=TEXTURE_SIZE_MIN, last=TEXTURE_SIZE_MAX, default=TEXTURE_SIZE_DEFAULT }
]

func get_input_defs():
Expand All @@ -56,9 +65,9 @@ func get_input_defs():
func get_image_size():
var rv : int
if parameters.has("size"):
rv = int(pow(2, parameters.size+7))
rv = int(pow(2, parameters.size+TEXTURE_SIZE_MIN))
else:
rv = 512
rv = int(pow(2, TEXTURE_SIZE_DEFAULT))
return rv

func update_preview():
Expand Down
Expand Up @@ -3,7 +3,7 @@ extends HBoxContainer

var size_first = 0
var size_last = 12
var size_default = 8
var size_default = 10

func _ready():
update_size_configuration()
Expand Down

0 comments on commit ede29a9

Please sign in to comment.