mirror of
https://github.com/Relintai/material-maker.git
synced 2024-11-13 06:27:18 +01:00
Fixed normal map and updated 3d preview
This commit is contained in:
parent
28654f3eba
commit
477eec692b
3
addons/material_maker/environment.gd
Normal file
3
addons/material_maker/environment.gd
Normal file
@ -0,0 +1,3 @@
|
||||
extends Spatial
|
||||
|
||||
export var environment : Environment
|
@ -1 +1 @@
|
||||
{"connections":[{"from":"nm_convolution","from_port":0,"to":"nm_postprocess","to_port":0},{"from":"nm_postprocess","from_port":0,"to":"gen_outputs","to_port":0},{"from":"gen_inputs","from_port":0,"to":"buffer","to_port":0},{"from":"buffer","from_port":0,"to":"nm_convolution","to_port":0}],"label":"Normal Map","name":"normal_map","node_position":{"x":0,"y":0},"nodes":[{"mask":3,"name":"gen_inputs","node_position":{"x":-839.25,"y":177.25},"parameters":{"size":4},"ports":[{"name":"in","type":"rgba"}],"type":"ios"},{"mask":3,"name":"gen_outputs","node_position":{"x":-434.25,"y":318.25},"parameters":{"size":4},"ports":[{"name":"in","type":"rgba"}],"type":"ios"},{"convolution_params":{"input_type":"f","matrix":[[[-1,-1,0],[0,-2,0],[1,-1,0]],[[-2,0,0],0,[2,0,0]],[[-1,1,0],[0,2,0],[1,1,0]]],"output_type":"rgb","x":1,"y":1},"name":"nm_convolution","node_position":{"x":-669.25,"y":245.25},"parameters":{"size":5},"type":"shader"},{"name":"nm_postprocess","node_position":{"x":-678.25,"y":315.25},"parameters":{"amount":0.99,"size":5},"shader_model":{"global":"","inputs":[{"default":"vec3(0.0)","label":"","name":"in","type":"rgb"}],"instance":"","name":"NormalMapPostProcess","outputs":[{"rgb":"0.5*normalize($in($uv)*$amount*$size/128.0-vec3(0.0, 0.0, 1.0))+vec3(0.5)","type":"rgb"}],"parameters":[{"default":9,"first":4,"label":"","last":11,"name":"size","type":"size"},{"default":1,"label":"","max":2,"min":0,"name":"amount","step":0.005,"type":"float"}]},"type":"shader"},{"name":"buffer","node_position":{"x":-669.663818,"y":174.60614},"parameters":{"size":5},"type":"buffer"},{"name":"gen_parameters","node_position":{"x":-713.910156,"y":24.083313},"parameters":{"param0":5,"param1":0.99},"type":"remote","widgets":[{"label":"Unnamed","linked_widgets":[{"node":"buffer","widget":"size"},{"node":"nm_convolution","widget":"size"},{"node":"nm_postprocess","widget":"size"}],"type":"linked_control"},{"label":"Unnamed","linked_widgets":[{"node":"nm_postprocess","widget":"amount"}],"type":"linked_control"}]}],"parameters":{"amount":0.35,"param0":5,"param1":0.99,"size":4},"type":"graph"}
|
||||
{"connections":[{"from":"nm_convolution","from_port":0,"to":"nm_postprocess","to_port":0},{"from":"nm_postprocess","from_port":0,"to":"gen_outputs","to_port":0},{"from":"gen_inputs","from_port":0,"to":"buffer","to_port":0},{"from":"buffer","from_port":0,"to":"nm_convolution","to_port":0}],"label":"Normal Map","name":"normal_map","node_position":{"x":0,"y":0},"nodes":[{"name":"gen_inputs","node_position":{"x":-839.25,"y":177.25},"parameters":{"size":4},"ports":[{"name":"in","type":"rgba"}],"type":"ios"},{"name":"gen_outputs","node_position":{"x":-434.25,"y":318.25},"parameters":{"size":4},"ports":[{"name":"in","type":"rgba"}],"type":"ios"},{"convolution_params":{"input_type":"f","matrix":[[[-1,-1,0],[0,-2,0],[1,-1,0]],[[-2,0,0],0,[2,0,0]],[[-1,1,0],[0,2,0],[1,1,0]]],"output_type":"rgb","x":1,"y":1},"name":"nm_convolution","node_position":{"x":-666.25,"y":246.25},"parameters":{"size":6},"type":"shader"},{"name":"nm_postprocess","node_position":{"x":-667.25,"y":320.25},"parameters":{"amount":0.95,"size":6},"shader_model":{"code":"","global":"","inputs":[{"default":"vec3(0.0)","label":"","name":"in","type":"rgb"}],"instance":"","name":"NormalMapPostProcess","outputs":[{"rgb":"0.5*normalize($in($uv)*$amount*vec3(-1.0, 1.0, 1.0)*$size/128.0-vec3(0.0, 0.0, 1.0))+vec3(0.5)","type":"rgb"}],"parameters":[{"default":8,"first":4,"label":"","last":11,"name":"size","type":"size"},{"default":1,"label":"","max":2,"min":0,"name":"amount","step":0.005,"type":"float"}]},"type":"shader"},{"name":"buffer","node_position":{"x":-669.663818,"y":174.60614},"parameters":{"size":6},"type":"buffer"},{"name":"gen_parameters","node_position":{"x":-713.910156,"y":24.083313},"parameters":{"param0":6,"param1":0.99},"type":"remote","widgets":[{"label":"Unnamed","linked_widgets":[{"node":"buffer","widget":"size"},{"node":"nm_convolution","widget":"size"},{"node":"nm_postprocess","widget":"size"}],"type":"linked_control"},{"label":"Unnamed","linked_widgets":[{"node":"nm_postprocess","widget":"amount"}],"type":"linked_control"}]}],"parameters":{"amount":0.5,"param0":6,"param1":0.99,"size":4},"type":"graph"}
|
BIN
addons/material_maker/panoramas/epping_forest_01.hdr
Normal file
BIN
addons/material_maker/panoramas/epping_forest_01.hdr
Normal file
Binary file not shown.
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
BIN
addons/material_maker/panoramas/moonless_golf.hdr
Normal file
BIN
addons/material_maker/panoramas/moonless_golf.hdr
Normal file
Binary file not shown.
File diff suppressed because one or more lines are too long
Binary file not shown.
File diff suppressed because one or more lines are too long
@ -10,24 +10,35 @@ const ENVIRONMENTS = [
|
||||
onready var objects = $MaterialPreview/Preview3d/Objects
|
||||
onready var current_object = objects.get_child(0)
|
||||
|
||||
onready var environments = $MaterialPreview/Preview3d/Environments
|
||||
onready var current_environment = environments.get_child(0)
|
||||
|
||||
signal need_update
|
||||
signal show_background_preview
|
||||
|
||||
func _ready():
|
||||
current_object.visible = true
|
||||
$Config/Model.clear()
|
||||
for o in objects.get_children():
|
||||
var m = o.get_surface_material(0)
|
||||
o.set_surface_material(0, m.duplicate())
|
||||
$Config/Model.add_item(o.name)
|
||||
call_deferred("_on_Model_item_selected", 0)
|
||||
$Config/Environment.clear()
|
||||
for e in environments.get_children():
|
||||
$Config/Environment.add_item(e.name)
|
||||
call_deferred("_on_Environment_item_selected", 0)
|
||||
$MaterialPreview/Preview3d/ObjectRotate.play("rotate")
|
||||
$Preview2D.material = $Preview2D.material.duplicate(true)
|
||||
_on_Environment_item_selected($Config/Environment.selected)
|
||||
_on_Preview_resized()
|
||||
$MaterialPreview/Preview3d/CameraPivot/Camera/RemoteTransform.set_remote_node("../../../../../../../ProjectsPane/BackgroundPreview/Viewport/Camera")
|
||||
|
||||
func _on_Environment_item_selected(id):
|
||||
$MaterialPreview/Preview3d/WorldEnvironment.environment.background_sky.panorama = load("res://addons/material_maker/panoramas/"+ENVIRONMENTS[id]+".hdr")
|
||||
current_environment.visible = false
|
||||
current_environment = environments.get_child(id)
|
||||
print(current_environment.environment)
|
||||
$MaterialPreview/Preview3d/CameraPivot/Camera.set_environment(current_environment.environment)
|
||||
get_node("../../ProjectsPane/BackgroundPreview/Viewport/Camera").set_environment(current_environment.environment)
|
||||
current_environment.visible = true
|
||||
|
||||
func _on_Model_item_selected(id):
|
||||
current_object.visible = false
|
||||
@ -62,6 +73,9 @@ func on_gui_input(event):
|
||||
if event is InputEventMouseButton:
|
||||
$MaterialPreview/Preview3d/ObjectRotate.stop()
|
||||
elif event is InputEventMouseMotion:
|
||||
if event.button_mask != 0:
|
||||
if event.button_mask & BUTTON_MASK_LEFT:
|
||||
$MaterialPreview/Preview3d/Objects.rotation.y += 0.01*event.relative.x
|
||||
$MaterialPreview/Preview3d/Objects.rotation.x += 0.01*event.relative.y
|
||||
elif event.button_mask & BUTTON_MASK_RIGHT:
|
||||
$MaterialPreview/Preview3d/CameraPivot.rotation.y += 0.01*event.relative.x
|
||||
$MaterialPreview/Preview3d/CameraPivot.rotation.x -= 0.01*event.relative.y
|
||||
|
@ -55,12 +55,12 @@ selected = 0
|
||||
|
||||
[node name="Environment" type="OptionButton" parent="Config"]
|
||||
margin_left = 104.0
|
||||
margin_right = 204.0
|
||||
margin_right = 231.0
|
||||
margin_bottom = 20.0
|
||||
rect_min_size = Vector2( 100, 0 )
|
||||
text = "Park"
|
||||
items = [ "Experiment", null, false, 0, null, "Lobby", null, false, 1, null, "Night", null, false, 2, null, "Park", null, false, 3, null, "Schelde", null, false, 4, null ]
|
||||
selected = 3
|
||||
text = "Epping Forest"
|
||||
items = [ "Epping Forest", null, false, -1, null, "Moonless Golf", null, false, -1, null ]
|
||||
selected = 0
|
||||
|
||||
[node name="Button" type="Button" parent="Config"]
|
||||
margin_left = 372.0
|
||||
|
@ -1,15 +1,17 @@
|
||||
[gd_scene load_steps=6 format=2]
|
||||
[gd_scene load_steps=14 format=2]
|
||||
|
||||
[ext_resource path="res://addons/material_maker/preview_objects.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://addons/material_maker/panoramas/park.hdr" type="Texture" id=2]
|
||||
[ext_resource path="res://addons/material_maker/environment.gd" type="Script" id=2]
|
||||
[ext_resource path="res://addons/material_maker/panoramas/epping_forest_01.hdr" type="Texture" id=3]
|
||||
[ext_resource path="res://addons/material_maker/panoramas/moonless_golf.hdr" type="Texture" id=4]
|
||||
|
||||
[sub_resource type="PanoramaSky" id=1]
|
||||
radiance_size = 2
|
||||
panorama = ExtResource( 2 )
|
||||
|
||||
[sub_resource type="Environment" id=2]
|
||||
background_mode = 2
|
||||
background_sky = SubResource( 1 )
|
||||
ambient_light_color = Color( 0.992157, 1, 0.709804, 1 )
|
||||
ambient_light_energy = 0.3
|
||||
|
||||
[sub_resource type="Animation" id=3]
|
||||
loop = true
|
||||
@ -26,18 +28,36 @@ tracks/0/keys = {
|
||||
"values": [ Vector3( 0, 0, 0 ), Vector3( 0, 360, 0 ) ]
|
||||
}
|
||||
|
||||
[sub_resource type="PanoramaSky" id=4]
|
||||
resource_local_to_scene = true
|
||||
panorama = ExtResource( 3 )
|
||||
|
||||
[sub_resource type="Environment" id=5]
|
||||
background_mode = 2
|
||||
background_sky = SubResource( 4 )
|
||||
|
||||
[sub_resource type="SpatialMaterial" id=6]
|
||||
flags_unshaded = true
|
||||
|
||||
[sub_resource type="SphereMesh" id=7]
|
||||
material = SubResource( 6 )
|
||||
radius = 0.25
|
||||
height = 0.5
|
||||
|
||||
[sub_resource type="PanoramaSky" id=8]
|
||||
resource_local_to_scene = true
|
||||
panorama = ExtResource( 4 )
|
||||
|
||||
[sub_resource type="Environment" id=9]
|
||||
resource_local_to_scene = true
|
||||
background_mode = 2
|
||||
background_sky = SubResource( 8 )
|
||||
|
||||
[node name="Preview3d" type="Spatial"]
|
||||
|
||||
[node name="Objects" parent="." instance=ExtResource( 1 )]
|
||||
transform = Transform( -0.799512, 0, 0.60065, 0, 1, 0, -0.60065, 0, -0.799512, 0, 0, 0 )
|
||||
|
||||
[node name="OmniLight" type="OmniLight" parent="."]
|
||||
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0.345557, 2.74973, -3.97441 )
|
||||
omni_range = 6.46518
|
||||
|
||||
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
|
||||
environment = SubResource( 2 )
|
||||
|
||||
[node name="CameraPivot" type="Spatial" parent="."]
|
||||
transform = Transform( 1, 0, 0, 0, 0.766044, 0.642788, 0, -0.642788, 0.766044, 0, 0, 0 )
|
||||
|
||||
@ -53,3 +73,47 @@ remote_path = NodePath("../../../../../../ProjectsPane/BackgroundPreview/Viewpor
|
||||
autoplay = "rotate"
|
||||
playback_speed = 0.1
|
||||
anims/rotate = SubResource( 3 )
|
||||
|
||||
[node name="Environments" type="Spatial" parent="."]
|
||||
|
||||
[node name="Epping Forest" type="Spatial" parent="Environments"]
|
||||
script = ExtResource( 2 )
|
||||
environment = SubResource( 5 )
|
||||
|
||||
[node name="Light" type="OmniLight" parent="Environments/Epping Forest"]
|
||||
transform = Transform( 0.999755, 0.0162074, -0.0150931, 0, 0.681502, 0.731816, 0.0221468, -0.731637, 0.681335, -0.0821358, 3.98251, -2.64581 )
|
||||
light_energy = 4.9
|
||||
omni_range = 12.9508
|
||||
|
||||
[node name="Mesh" type="MeshInstance" parent="Environments/Epping Forest/Light"]
|
||||
transform = Transform( 1, 1.11759e-008, -1.30385e-008, -1.86265e-009, 1, -4.17233e-007, 0, 0, 1, 0, 0, 0 )
|
||||
cast_shadow = 0
|
||||
mesh = SubResource( 7 )
|
||||
material/0 = null
|
||||
|
||||
[node name="Moonless Golf" type="Spatial" parent="Environments"]
|
||||
visible = false
|
||||
script = ExtResource( 2 )
|
||||
environment = SubResource( 9 )
|
||||
|
||||
[node name="Light1" type="OmniLight" parent="Environments/Moonless Golf"]
|
||||
transform = Transform( 0.999755, 0.0162074, -0.0150931, 0, 0.681502, 0.731816, 0.0221468, -0.731637, 0.681335, -2.22238, 3.98251, -2.64581 )
|
||||
light_energy = 4.9
|
||||
omni_range = 12.9508
|
||||
|
||||
[node name="Mesh" type="MeshInstance" parent="Environments/Moonless Golf/Light1"]
|
||||
transform = Transform( 1, 1.11759e-008, -1.39698e-008, -1.86265e-009, 1, -4.17233e-007, 0, 0, 1, 0, 0, 0 )
|
||||
cast_shadow = 0
|
||||
mesh = SubResource( 7 )
|
||||
material/0 = null
|
||||
|
||||
[node name="Light2" type="OmniLight" parent="Environments/Moonless Golf"]
|
||||
transform = Transform( 0.999755, 0.0162074, -0.0150931, 0, 0.681502, 0.731816, 0.0221468, -0.731637, 0.681335, 2.34329, 3.98251, -2.64581 )
|
||||
light_energy = 4.9
|
||||
omni_range = 12.9508
|
||||
|
||||
[node name="Mesh" type="MeshInstance" parent="Environments/Moonless Golf/Light2"]
|
||||
transform = Transform( 1, 1.11759e-008, -1.39698e-008, -1.86265e-009, 1, -4.17233e-007, 0, 0, 1, 0, 0, 0 )
|
||||
cast_shadow = 0
|
||||
mesh = SubResource( 7 )
|
||||
material/0 = null
|
||||
|
@ -43,7 +43,6 @@ uv1_scale = Vector3( 4, 4, 4 )
|
||||
transform = Transform( -0.685898, 0, 0.727691, 0, 1, 0, -0.727691, 0, -0.685898, 0, 0, 0 )
|
||||
|
||||
[node name="Cube" type="MeshInstance" parent="."]
|
||||
visible = false
|
||||
mesh = SubResource( 1 )
|
||||
material/0 = SubResource( 2 )
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user