Skip to content

Commit

Permalink
(last?) changes for 0.7
Browse files Browse the repository at this point in the history
  • Loading branch information
RodZill4 committed Nov 24, 2019
1 parent cab8020 commit b153b33
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 80 deletions.
2 changes: 1 addition & 1 deletion addons/material_maker/engine/gen_material.gd
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,9 @@ func update_spatial_material(m, file_prefix = null) -> void:
m.set_shader_param("albedo", parameters.albedo_color)
m.set_shader_param("texture_albedo", get_generated_texture("albedo", file_prefix))
m.set_shader_param("metallic", parameters.metallic)
m.set_shader_param("roughness", parameters.roughness)
m.set_shader_param("texture_metallic", get_generated_texture("orm", file_prefix))
m.set_shader_param("metallic_texture_channel", PoolRealArray([0.0, 0.0, 1.0, 0.0]))
m.set_shader_param("roughness", parameters.roughness)
m.set_shader_param("texture_roughness", get_generated_texture("orm", file_prefix))
m.set_shader_param("roughness_texture_channel", PoolRealArray([0.0, 1.0, 0.0, 0.0]))
m.set_shader_param("emission_energy", parameters.emission_energy)
Expand Down
43 changes: 43 additions & 0 deletions addons/material_maker/import_plugin/tesselated.shader
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
shader_type spatial;
render_mode blend_mix,depth_draw_opaque,cull_back,diffuse_burley,specular_schlick_ggx,skip_vertex_transform;
uniform vec4 albedo : hint_color;
uniform sampler2D texture_albedo : hint_albedo;
uniform float specular;
uniform float metallic;
uniform float roughness : hint_range(0,1);
uniform float point_size : hint_range(0,128);
uniform sampler2D texture_metallic : hint_white;
uniform vec4 metallic_texture_channel;
uniform sampler2D texture_roughness : hint_white;
uniform vec4 roughness_texture_channel;
uniform sampler2D texture_emission : hint_black_albedo;
uniform vec4 emission : hint_color;
uniform float emission_energy;
uniform sampler2D texture_normal : hint_normal;
uniform float normal_scale : hint_range(-16,16);
uniform sampler2D texture_depth : hint_white;
uniform float depth_scale : hint_range(0,1);
uniform vec3 uv1_scale;
uniform vec3 uv1_offset;
uniform vec3 uv2_scale;
uniform vec3 uv2_offset;

void vertex() {
VERTEX = (MODELVIEW_MATRIX * vec4(VERTEX+NORMAL*depth_scale*(1.0-texture(texture_depth, UV).r), 1.0)).xyz;
UV=UV*uv1_scale.xy+uv1_offset.xy;
}

void fragment() {
vec2 base_uv = UV;
vec4 albedo_tex = texture(texture_albedo,base_uv);
ALBEDO = albedo.rgb * albedo_tex.rgb;
float metallic_tex = dot(texture(texture_metallic,base_uv),metallic_texture_channel);
METALLIC = metallic_tex * metallic;
float roughness_tex = dot(texture(texture_roughness,base_uv),roughness_texture_channel);
ROUGHNESS = roughness_tex * roughness;
SPECULAR = specular;
NORMALMAP = texture(texture_normal,base_uv).rgb;
NORMALMAP_DEPTH = normal_scale;
vec3 emission_tex = texture(texture_emission,base_uv).rgb;
EMISSION = (emission.rgb+emission_tex)*emission_energy;
}
35 changes: 17 additions & 18 deletions addons/material_maker/preview/preview_3d.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,16 @@
[ext_resource path="res://addons/material_maker/preview/panoramas/epping_forest_01.hdr" type="Texture" id=4]
[ext_resource path="res://addons/material_maker/preview/panoramas/studio_sky.tres" type="Environment" id=5]


[sub_resource type="PanoramaSky" id=2]
[sub_resource type="PanoramaSky" id=3]
resource_local_to_scene = true
panorama = ExtResource( 2 )

[sub_resource type="Environment" id=3]
[sub_resource type="Environment" id=4]
resource_local_to_scene = true
background_mode = 2
background_sky = SubResource( 2 )
background_sky = SubResource( 3 )

[sub_resource type="Animation" id=4]
[sub_resource type="Animation" id=5]
loop = true
tracks/0/type = "value"
tracks/0/path = NodePath("Objects:rotation_degrees")
Expand All @@ -31,27 +30,27 @@ tracks/0/keys = {
"values": [ Vector3( 0, 0, 0 ), Vector3( 0, 360, 0 ) ]
}

[sub_resource type="PanoramaSky" id=5]
[sub_resource type="PanoramaSky" id=1]
resource_local_to_scene = true
panorama = ExtResource( 4 )

[sub_resource type="Environment" id=6]
[sub_resource type="Environment" id=2]
background_mode = 2
background_sky = SubResource( 5 )
background_sky = SubResource( 1 )
background_energy = 1.5
ambient_light_color = Color( 1, 1, 1, 1 )
ambient_light_energy = 0.32
tonemap_mode = 2
tonemap_white = 16.0

[sub_resource type="CylinderMesh" id=7]
[sub_resource type="CylinderMesh" id=6]
top_radius = 5.0
bottom_radius = 5.0
height = 0.5

[sub_resource type="SpatialMaterial" id=8]
[sub_resource type="SpatialMaterial" id=7]

[sub_resource type="PlaneMesh" id=1]
[sub_resource type="PlaneMesh" id=8]
size = Vector2( 1000, 1000 )
subdivide_width = 10
subdivide_depth = 10
Expand All @@ -66,7 +65,7 @@ transform = Transform( 1, 0, 0, 0, 0.766044, 0.642788, 0, -0.642788, 0.766044, 0

[node name="Camera" type="Camera" parent="CameraPivot"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 3.5 )
environment = SubResource( 3 )
environment = SubResource( 4 )
current = true

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

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

[node name="Epping Forest" type="Spatial" parent="Environments"]
editor/display_folded = true
visible = false
script = ExtResource( 3 )
environment = SubResource( 6 )
environment = SubResource( 2 )

[node name="DirectionalLight" type="DirectionalLight" parent="Environments/Epping Forest"]
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 )
Expand All @@ -93,14 +92,14 @@ shadow_enabled = true
[node name="MeshInstance" type="MeshInstance" parent="Environments/Epping Forest"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -3.3343, 0 )
visible = false
mesh = SubResource( 7 )
material/0 = SubResource( 8 )
mesh = SubResource( 6 )
material/0 = SubResource( 7 )

[node name="Moonless Golf" type="Spatial" parent="Environments"]
editor/display_folded = true
visible = false
script = ExtResource( 3 )
environment = SubResource( 3 )
environment = SubResource( 4 )

[node name="DirectionalLight" type="DirectionalLight" parent="Environments/Moonless Golf"]
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 )
Expand All @@ -118,5 +117,5 @@ shadow_enabled = true

[node name="GroundPlane" type="MeshInstance" parent="Environments/Studio"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -1.05186, 0 )
mesh = SubResource( 1 )
mesh = SubResource( 8 )
material/0 = null
58 changes: 6 additions & 52 deletions addons/material_maker/preview/preview_objects.tscn
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[gd_scene load_steps=17 format=2]

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

[sub_resource type="CubeMesh" id=1]

Expand Down Expand Up @@ -47,70 +48,23 @@ size = Vector2( 12, 12 )
albedo_texture = ExtResource( 1 )
uv1_scale = Vector3( 4, 4, 4 )

[sub_resource type="Shader" id=14]
code = "shader_type spatial;
render_mode blend_mix,depth_draw_opaque,cull_back,diffuse_burley,specular_schlick_ggx,skip_vertex_transform;
uniform vec4 albedo : hint_color;
uniform sampler2D texture_albedo : hint_albedo;
uniform float specular;
uniform float metallic;
uniform float roughness : hint_range(0,1);
uniform float point_size : hint_range(0,128);
uniform sampler2D texture_metallic : hint_white;
uniform vec4 metallic_texture_channel;
uniform sampler2D texture_roughness : hint_white;
uniform vec4 roughness_texture_channel;
uniform sampler2D texture_emission : hint_black_albedo;
uniform vec4 emission : hint_color;
uniform float emission_energy;
uniform sampler2D texture_normal : hint_normal;
uniform float normal_scale : hint_range(-16,16);
uniform sampler2D texture_depth : hint_white;
uniform float depth_scale : hint_range(0,1);
uniform vec3 uv1_scale;
uniform vec3 uv1_offset;
uniform vec3 uv2_scale;
uniform vec3 uv2_offset;

void vertex() {
VERTEX = (MODELVIEW_MATRIX * vec4(VERTEX+NORMAL*depth_scale*(1.0-texture(texture_depth, UV).r), 1.0)).xyz;
UV=UV*uv1_scale.xy+uv1_offset.xy;
}

void fragment() {
vec2 base_uv = UV;
vec4 albedo_tex = texture(texture_albedo,base_uv);
ALBEDO = albedo.rgb * albedo_tex.rgb;
float metallic_tex = dot(texture(texture_metallic,base_uv),metallic_texture_channel);
METALLIC = metallic_tex * metallic;
float roughness_tex = dot(texture(texture_roughness,base_uv),roughness_texture_channel);
ROUGHNESS = roughness_tex * roughness;
SPECULAR = specular;
NORMALMAP = texture(texture_normal,base_uv).rgb;
NORMALMAP_DEPTH = normal_scale;
vec3 emission_tex = texture(texture_emission,base_uv).rgb;
EMISSION = (emission.rgb+emission_tex)*emission_energy;
}
"

[sub_resource type="ShaderMaterial" id=15]
shader = SubResource( 14 )
shader = ExtResource( 2 )
shader_param/albedo = Color( 1, 1, 1, 1 )
shader_param/specular = 0.5
shader_param/metallic = 0.0
shader_param/roughness = 1.0
shader_param/point_size = 1.0
shader_param/metallic_texture_channel = Plane( 1, 0, 0, 0 )
shader_param/roughness_texture_channel = Plane( 1, 0, 0, 0 )
shader_param/metallic_texture_channel = Plane( 0, 0, 1, 0 )
shader_param/roughness_texture_channel = Plane( 0, 1, 0, 0 )
shader_param/emission = Color( 0, 0, 0, 1 )
shader_param/emission_energy = 1.0
shader_param/normal_scale = 1.0
shader_param/depth_scale = null
shader_param/normal_scale = null
shader_param/depth_scale = 0.21
shader_param/uv1_scale = Vector3( 1, 1, 1 )
shader_param/uv1_offset = Vector3( 0, 0, 0 )
shader_param/uv2_scale = Vector3( 1, 1, 1 )
shader_param/uv2_offset = Vector3( 0, 0, 0 )
shader_param/texture_albedo = ExtResource( 1 )

[node name="Objects" type="Spatial"]
transform = Transform( -0.685898, 0, 0.727691, 0, 1, 0, -0.727691, 0, -0.685898, 0, 0, 0 )
Expand Down
Loading

0 comments on commit b153b33

Please sign in to comment.