Skip to content

Commit b153b33

Browse files
committed
(last?) changes for 0.7
1 parent cab8020 commit b153b33

File tree

6 files changed

+76
-80
lines changed

6 files changed

+76
-80
lines changed

addons/material_maker/engine/gen_material.gd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,9 @@ func update_spatial_material(m, file_prefix = null) -> void:
219219
m.set_shader_param("albedo", parameters.albedo_color)
220220
m.set_shader_param("texture_albedo", get_generated_texture("albedo", file_prefix))
221221
m.set_shader_param("metallic", parameters.metallic)
222-
m.set_shader_param("roughness", parameters.roughness)
223222
m.set_shader_param("texture_metallic", get_generated_texture("orm", file_prefix))
224223
m.set_shader_param("metallic_texture_channel", PoolRealArray([0.0, 0.0, 1.0, 0.0]))
224+
m.set_shader_param("roughness", parameters.roughness)
225225
m.set_shader_param("texture_roughness", get_generated_texture("orm", file_prefix))
226226
m.set_shader_param("roughness_texture_channel", PoolRealArray([0.0, 1.0, 0.0, 0.0]))
227227
m.set_shader_param("emission_energy", parameters.emission_energy)
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
shader_type spatial;
2+
render_mode blend_mix,depth_draw_opaque,cull_back,diffuse_burley,specular_schlick_ggx,skip_vertex_transform;
3+
uniform vec4 albedo : hint_color;
4+
uniform sampler2D texture_albedo : hint_albedo;
5+
uniform float specular;
6+
uniform float metallic;
7+
uniform float roughness : hint_range(0,1);
8+
uniform float point_size : hint_range(0,128);
9+
uniform sampler2D texture_metallic : hint_white;
10+
uniform vec4 metallic_texture_channel;
11+
uniform sampler2D texture_roughness : hint_white;
12+
uniform vec4 roughness_texture_channel;
13+
uniform sampler2D texture_emission : hint_black_albedo;
14+
uniform vec4 emission : hint_color;
15+
uniform float emission_energy;
16+
uniform sampler2D texture_normal : hint_normal;
17+
uniform float normal_scale : hint_range(-16,16);
18+
uniform sampler2D texture_depth : hint_white;
19+
uniform float depth_scale : hint_range(0,1);
20+
uniform vec3 uv1_scale;
21+
uniform vec3 uv1_offset;
22+
uniform vec3 uv2_scale;
23+
uniform vec3 uv2_offset;
24+
25+
void vertex() {
26+
VERTEX = (MODELVIEW_MATRIX * vec4(VERTEX+NORMAL*depth_scale*(1.0-texture(texture_depth, UV).r), 1.0)).xyz;
27+
UV=UV*uv1_scale.xy+uv1_offset.xy;
28+
}
29+
30+
void fragment() {
31+
vec2 base_uv = UV;
32+
vec4 albedo_tex = texture(texture_albedo,base_uv);
33+
ALBEDO = albedo.rgb * albedo_tex.rgb;
34+
float metallic_tex = dot(texture(texture_metallic,base_uv),metallic_texture_channel);
35+
METALLIC = metallic_tex * metallic;
36+
float roughness_tex = dot(texture(texture_roughness,base_uv),roughness_texture_channel);
37+
ROUGHNESS = roughness_tex * roughness;
38+
SPECULAR = specular;
39+
NORMALMAP = texture(texture_normal,base_uv).rgb;
40+
NORMALMAP_DEPTH = normal_scale;
41+
vec3 emission_tex = texture(texture_emission,base_uv).rgb;
42+
EMISSION = (emission.rgb+emission_tex)*emission_energy;
43+
}

addons/material_maker/preview/preview_3d.tscn

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,16 @@
66
[ext_resource path="res://addons/material_maker/preview/panoramas/epping_forest_01.hdr" type="Texture" id=4]
77
[ext_resource path="res://addons/material_maker/preview/panoramas/studio_sky.tres" type="Environment" id=5]
88

9-
10-
[sub_resource type="PanoramaSky" id=2]
9+
[sub_resource type="PanoramaSky" id=3]
1110
resource_local_to_scene = true
1211
panorama = ExtResource( 2 )
1312

14-
[sub_resource type="Environment" id=3]
13+
[sub_resource type="Environment" id=4]
1514
resource_local_to_scene = true
1615
background_mode = 2
17-
background_sky = SubResource( 2 )
16+
background_sky = SubResource( 3 )
1817

19-
[sub_resource type="Animation" id=4]
18+
[sub_resource type="Animation" id=5]
2019
loop = true
2120
tracks/0/type = "value"
2221
tracks/0/path = NodePath("Objects:rotation_degrees")
@@ -31,27 +30,27 @@ tracks/0/keys = {
3130
"values": [ Vector3( 0, 0, 0 ), Vector3( 0, 360, 0 ) ]
3231
}
3332

34-
[sub_resource type="PanoramaSky" id=5]
33+
[sub_resource type="PanoramaSky" id=1]
3534
resource_local_to_scene = true
3635
panorama = ExtResource( 4 )
3736

38-
[sub_resource type="Environment" id=6]
37+
[sub_resource type="Environment" id=2]
3938
background_mode = 2
40-
background_sky = SubResource( 5 )
39+
background_sky = SubResource( 1 )
4140
background_energy = 1.5
4241
ambient_light_color = Color( 1, 1, 1, 1 )
4342
ambient_light_energy = 0.32
4443
tonemap_mode = 2
4544
tonemap_white = 16.0
4645

47-
[sub_resource type="CylinderMesh" id=7]
46+
[sub_resource type="CylinderMesh" id=6]
4847
top_radius = 5.0
4948
bottom_radius = 5.0
5049
height = 0.5
5150

52-
[sub_resource type="SpatialMaterial" id=8]
51+
[sub_resource type="SpatialMaterial" id=7]
5352

54-
[sub_resource type="PlaneMesh" id=1]
53+
[sub_resource type="PlaneMesh" id=8]
5554
size = Vector2( 1000, 1000 )
5655
subdivide_width = 10
5756
subdivide_depth = 10
@@ -66,7 +65,7 @@ transform = Transform( 1, 0, 0, 0, 0.766044, 0.642788, 0, -0.642788, 0.766044, 0
6665

6766
[node name="Camera" type="Camera" parent="CameraPivot"]
6867
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 3.5 )
69-
environment = SubResource( 3 )
68+
environment = SubResource( 4 )
7069
current = true
7170

7271
[node name="RemoteTransform" type="RemoteTransform" parent="CameraPivot/Camera"]
@@ -75,15 +74,15 @@ remote_path = NodePath("../../../../../../ProjectsPane/BackgroundPreview/Viewpor
7574
[node name="ObjectRotate" type="AnimationPlayer" parent="."]
7675
autoplay = "rotate"
7776
playback_speed = 0.1
78-
anims/rotate = SubResource( 4 )
77+
anims/rotate = SubResource( 5 )
7978

8079
[node name="Environments" type="Spatial" parent="."]
8180

8281
[node name="Epping Forest" type="Spatial" parent="Environments"]
8382
editor/display_folded = true
8483
visible = false
8584
script = ExtResource( 3 )
86-
environment = SubResource( 6 )
85+
environment = SubResource( 2 )
8786

8887
[node name="DirectionalLight" type="DirectionalLight" parent="Environments/Epping Forest"]
8988
transform = Transform( 0.976272, -0.0494319, -0.21083, 0.216548, 0.222856, 0.950496, -8.69534e-009, -0.973597, 0.228272, -5.08826, 21.6274, 5.3744 )
@@ -93,14 +92,14 @@ shadow_enabled = true
9392
[node name="MeshInstance" type="MeshInstance" parent="Environments/Epping Forest"]
9493
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -3.3343, 0 )
9594
visible = false
96-
mesh = SubResource( 7 )
97-
material/0 = SubResource( 8 )
95+
mesh = SubResource( 6 )
96+
material/0 = SubResource( 7 )
9897

9998
[node name="Moonless Golf" type="Spatial" parent="Environments"]
10099
editor/display_folded = true
101100
visible = false
102101
script = ExtResource( 3 )
103-
environment = SubResource( 3 )
102+
environment = SubResource( 4 )
104103

105104
[node name="DirectionalLight" type="DirectionalLight" parent="Environments/Moonless Golf"]
106105
transform = Transform( 0.569388, 0.170928, 0.804103, 0.171359, -0.981336, 0.087263, 0.804011, 0.088104, -0.588051, 91.9658, 9.62053, -85.1176 )
@@ -118,5 +117,5 @@ shadow_enabled = true
118117

119118
[node name="GroundPlane" type="MeshInstance" parent="Environments/Studio"]
120119
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -1.05186, 0 )
121-
mesh = SubResource( 1 )
120+
mesh = SubResource( 8 )
122121
material/0 = null

addons/material_maker/preview/preview_objects.tscn

Lines changed: 6 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
[gd_scene load_steps=17 format=2]
22

33
[ext_resource path="res://rodz_labs_logo.png" type="Texture" id=1]
4+
[ext_resource path="res://addons/material_maker/import_plugin/tesselated.shader" type="Shader" id=2]
45

56
[sub_resource type="CubeMesh" id=1]
67

@@ -47,70 +48,23 @@ size = Vector2( 12, 12 )
4748
albedo_texture = ExtResource( 1 )
4849
uv1_scale = Vector3( 4, 4, 4 )
4950

50-
[sub_resource type="Shader" id=14]
51-
code = "shader_type spatial;
52-
render_mode blend_mix,depth_draw_opaque,cull_back,diffuse_burley,specular_schlick_ggx,skip_vertex_transform;
53-
uniform vec4 albedo : hint_color;
54-
uniform sampler2D texture_albedo : hint_albedo;
55-
uniform float specular;
56-
uniform float metallic;
57-
uniform float roughness : hint_range(0,1);
58-
uniform float point_size : hint_range(0,128);
59-
uniform sampler2D texture_metallic : hint_white;
60-
uniform vec4 metallic_texture_channel;
61-
uniform sampler2D texture_roughness : hint_white;
62-
uniform vec4 roughness_texture_channel;
63-
uniform sampler2D texture_emission : hint_black_albedo;
64-
uniform vec4 emission : hint_color;
65-
uniform float emission_energy;
66-
uniform sampler2D texture_normal : hint_normal;
67-
uniform float normal_scale : hint_range(-16,16);
68-
uniform sampler2D texture_depth : hint_white;
69-
uniform float depth_scale : hint_range(0,1);
70-
uniform vec3 uv1_scale;
71-
uniform vec3 uv1_offset;
72-
uniform vec3 uv2_scale;
73-
uniform vec3 uv2_offset;
74-
75-
void vertex() {
76-
VERTEX = (MODELVIEW_MATRIX * vec4(VERTEX+NORMAL*depth_scale*(1.0-texture(texture_depth, UV).r), 1.0)).xyz;
77-
UV=UV*uv1_scale.xy+uv1_offset.xy;
78-
}
79-
80-
void fragment() {
81-
vec2 base_uv = UV;
82-
vec4 albedo_tex = texture(texture_albedo,base_uv);
83-
ALBEDO = albedo.rgb * albedo_tex.rgb;
84-
float metallic_tex = dot(texture(texture_metallic,base_uv),metallic_texture_channel);
85-
METALLIC = metallic_tex * metallic;
86-
float roughness_tex = dot(texture(texture_roughness,base_uv),roughness_texture_channel);
87-
ROUGHNESS = roughness_tex * roughness;
88-
SPECULAR = specular;
89-
NORMALMAP = texture(texture_normal,base_uv).rgb;
90-
NORMALMAP_DEPTH = normal_scale;
91-
vec3 emission_tex = texture(texture_emission,base_uv).rgb;
92-
EMISSION = (emission.rgb+emission_tex)*emission_energy;
93-
}
94-
"
95-
9651
[sub_resource type="ShaderMaterial" id=15]
97-
shader = SubResource( 14 )
52+
shader = ExtResource( 2 )
9853
shader_param/albedo = Color( 1, 1, 1, 1 )
9954
shader_param/specular = 0.5
10055
shader_param/metallic = 0.0
10156
shader_param/roughness = 1.0
10257
shader_param/point_size = 1.0
103-
shader_param/metallic_texture_channel = Plane( 1, 0, 0, 0 )
104-
shader_param/roughness_texture_channel = Plane( 1, 0, 0, 0 )
58+
shader_param/metallic_texture_channel = Plane( 0, 0, 1, 0 )
59+
shader_param/roughness_texture_channel = Plane( 0, 1, 0, 0 )
10560
shader_param/emission = Color( 0, 0, 0, 1 )
10661
shader_param/emission_energy = 1.0
107-
shader_param/normal_scale = 1.0
108-
shader_param/depth_scale = null
62+
shader_param/normal_scale = null
63+
shader_param/depth_scale = 0.21
10964
shader_param/uv1_scale = Vector3( 1, 1, 1 )
11065
shader_param/uv1_offset = Vector3( 0, 0, 0 )
11166
shader_param/uv2_scale = Vector3( 1, 1, 1 )
11267
shader_param/uv2_offset = Vector3( 0, 0, 0 )
113-
shader_param/texture_albedo = ExtResource( 1 )
11468

11569
[node name="Objects" type="Spatial"]
11670
transform = Transform( -0.685898, 0, 0.727691, 0, 1, 0, -0.727691, 0, -0.685898, 0, 0, 0 )

0 commit comments

Comments
 (0)