generated from krampus/template-godot4
Improved gunk material
This commit is contained in:
parent
3230afe301
commit
f1a9feca39
BIN
assets/debug_mask.png
(Stored with Git LFS)
Normal file
BIN
assets/debug_mask.png
(Stored with Git LFS)
Normal file
Binary file not shown.
35
assets/debug_mask.png.import
Normal file
35
assets/debug_mask.png.import
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://8cm835h4gxwe"
|
||||||
|
path.s3tc="res://.godot/imported/debug_mask.png-fd2bc783338ed9439fe81a4eef9d86da.s3tc.ctex"
|
||||||
|
metadata={
|
||||||
|
"imported_formats": ["s3tc_bptc"],
|
||||||
|
"vram_texture": true
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://assets/debug_mask.png"
|
||||||
|
dest_files=["res://.godot/imported/debug_mask.png-fd2bc783338ed9439fe81a4eef9d86da.s3tc.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=2
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
mipmaps/generate=true
|
||||||
|
mipmaps/limit=-1
|
||||||
|
roughness/mode=0
|
||||||
|
roughness/src_normal=""
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
process/hdr_as_srgb=false
|
||||||
|
process/hdr_clamp_exposure=false
|
||||||
|
process/size_limit=0
|
||||||
|
detect_3d/compress_to=0
|
31
assets/materials/gunk_material.tres
Normal file
31
assets/materials/gunk_material.tres
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
[gd_resource type="ShaderMaterial" load_steps=6 format=3 uid="uid://kkyg6jrp3d53"]
|
||||||
|
|
||||||
|
[ext_resource type="Shader" path="res://src/shaders/gunk.gdshader" id="1_euy6e"]
|
||||||
|
[ext_resource type="FastNoiseLite" uid="uid://cnlvdtx68giv6" path="res://assets/materials/gunk_noise.tres" id="2_u4cba"]
|
||||||
|
|
||||||
|
[sub_resource type="CompressedTexture2D" id="CompressedTexture2D_ow0bp"]
|
||||||
|
load_path = "res://.godot/imported/debug_mask.png-fd2bc783338ed9439fe81a4eef9d86da.s3tc.ctex"
|
||||||
|
|
||||||
|
[sub_resource type="NoiseTexture2D" id="NoiseTexture2D_txccq"]
|
||||||
|
seamless = true
|
||||||
|
noise = ExtResource("2_u4cba")
|
||||||
|
|
||||||
|
[sub_resource type="NoiseTexture2D" id="NoiseTexture2D_yr68k"]
|
||||||
|
invert = true
|
||||||
|
seamless = true
|
||||||
|
as_normal_map = true
|
||||||
|
bump_strength = 32.0
|
||||||
|
noise = ExtResource("2_u4cba")
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
render_priority = 0
|
||||||
|
shader = ExtResource("1_euy6e")
|
||||||
|
shader_parameter/color_1 = Color(0, 0.03, 0.1, 1)
|
||||||
|
shader_parameter/color_2 = Color(0, 0.1, 0.3, 1)
|
||||||
|
shader_parameter/roughness = 0.15
|
||||||
|
shader_parameter/specular_contribution = 0.2
|
||||||
|
shader_parameter/uv_scale = Vector2(8, 8)
|
||||||
|
shader_parameter/edge_bleed = 0.1
|
||||||
|
shader_parameter/gunk_mask = SubResource("CompressedTexture2D_ow0bp")
|
||||||
|
shader_parameter/gunk_noise = SubResource("NoiseTexture2D_txccq")
|
||||||
|
shader_parameter/gunk_normal_map = SubResource("NoiseTexture2D_yr68k")
|
8
assets/materials/gunk_noise.tres
Normal file
8
assets/materials/gunk_noise.tres
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
[gd_resource type="FastNoiseLite" format=3 uid="uid://cnlvdtx68giv6"]
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
frequency = 0.0025
|
||||||
|
fractal_type = 2
|
||||||
|
fractal_octaves = 4
|
||||||
|
fractal_gain = 0.667
|
||||||
|
domain_warp_type = 2
|
@ -1,34 +1,7 @@
|
|||||||
[gd_resource type="StandardMaterial3D" load_steps=8 format=3 uid="uid://byyjoruj8mwe0"]
|
[gd_resource type="StandardMaterial3D" load_steps=2 format=3 uid="uid://byyjoruj8mwe0"]
|
||||||
|
|
||||||
[ext_resource type="Shader" path="res://src/shaders/gunk.gdshader" id="1_dot5s"]
|
[ext_resource type="Material" uid="uid://kkyg6jrp3d53" path="res://assets/materials/gunk_material.tres" id="1_8bovt"]
|
||||||
|
|
||||||
[sub_resource type="PlaceholderTexture2D" id="PlaceholderTexture2D_pinpy"]
|
|
||||||
size = Vector2(256, 256)
|
|
||||||
|
|
||||||
[sub_resource type="FastNoiseLite" id="FastNoiseLite_f8h21"]
|
|
||||||
|
|
||||||
[sub_resource type="NoiseTexture2D" id="NoiseTexture2D_dj5ow"]
|
|
||||||
seamless = true
|
|
||||||
noise = SubResource("FastNoiseLite_f8h21")
|
|
||||||
|
|
||||||
[sub_resource type="FastNoiseLite" id="FastNoiseLite_1ennl"]
|
|
||||||
|
|
||||||
[sub_resource type="NoiseTexture2D" id="NoiseTexture2D_kkru7"]
|
|
||||||
seamless = true
|
|
||||||
as_normal_map = true
|
|
||||||
noise = SubResource("FastNoiseLite_1ennl")
|
|
||||||
|
|
||||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_0jkcp"]
|
|
||||||
render_priority = 0
|
|
||||||
shader = ExtResource("1_dot5s")
|
|
||||||
shader_parameter/color_1 = Color(0, 0.03, 0.1, 1)
|
|
||||||
shader_parameter/color_2 = Color(0, 0.1, 0.3, 1)
|
|
||||||
shader_parameter/roughness = 0.15
|
|
||||||
shader_parameter/specular_contribution = 0.2
|
|
||||||
shader_parameter/gunk_mask = SubResource("PlaceholderTexture2D_pinpy")
|
|
||||||
shader_parameter/gunk_noise = SubResource("NoiseTexture2D_dj5ow")
|
|
||||||
shader_parameter/gunk_normal_map = SubResource("NoiseTexture2D_kkru7")
|
|
||||||
|
|
||||||
[resource]
|
[resource]
|
||||||
next_pass = SubResource("ShaderMaterial_0jkcp")
|
next_pass = ExtResource("1_8bovt")
|
||||||
albedo_color = Color(1, 0.403922, 1, 1)
|
albedo_color = Color(1, 0.403922, 1, 1)
|
||||||
|
File diff suppressed because one or more lines are too long
@ -6,20 +6,47 @@ uniform vec4 color_2: source_color = vec4(0.0, 0.1, 0.3, 1.0);
|
|||||||
uniform float roughness: hint_range(0.0, 1.0) = 0.15;
|
uniform float roughness: hint_range(0.0, 1.0) = 0.15;
|
||||||
uniform float specular_contribution = 0.2;
|
uniform float specular_contribution = 0.2;
|
||||||
|
|
||||||
|
// Used ONLY by the gunk, does not affect the gunk mask.
|
||||||
|
uniform vec2 uv_scale = vec2(1.0);
|
||||||
|
|
||||||
|
uniform float edge_bleed = 0.1;
|
||||||
|
|
||||||
uniform sampler2D gunk_mask;
|
uniform sampler2D gunk_mask;
|
||||||
|
|
||||||
uniform highp sampler2D gunk_noise;
|
uniform highp sampler2D gunk_noise;
|
||||||
uniform highp sampler2D gunk_normal_map;
|
uniform highp sampler2D gunk_normal_map;
|
||||||
|
|
||||||
|
|
||||||
|
float hardstep(float value) {
|
||||||
|
float x = clamp(value, 0.0, 1.0);
|
||||||
|
return 0.5 * tanh( (20.0 * x - 10.0) * inversesqrt(x - x * x) ) + 0.5;
|
||||||
|
}
|
||||||
|
|
||||||
void fragment() {
|
void fragment() {
|
||||||
float value = texture(gunk_noise, UV).r;
|
vec2 local_uv = UV * uv_scale;
|
||||||
|
float value = texture(gunk_noise, local_uv).r;
|
||||||
vec4 color = mix(color_1, color_2, value);
|
vec4 color = mix(color_1, color_2, value);
|
||||||
float roughness_mix = value * roughness;
|
float roughness_mix = value * roughness;
|
||||||
|
|
||||||
ALBEDO = color.rgb;
|
ALBEDO = color.rgb;
|
||||||
ROUGHNESS = roughness_mix;
|
ROUGHNESS = roughness_mix;
|
||||||
SPECULAR = 0.5 * inversesqrt(specular_contribution);
|
SPECULAR = 0.5 * inversesqrt(specular_contribution);
|
||||||
NORMAL_MAP = texture(gunk_normal_map, UV).xyz;
|
NORMAL_MAP = texture(gunk_normal_map, local_uv).xyz;
|
||||||
ALPHA = 1.0 - texture(gunk_mask, UV).r;
|
|
||||||
|
float mask = texture(gunk_mask, UV).r;
|
||||||
|
|
||||||
|
// soften edges
|
||||||
|
NORMAL_MAP *= smoothstep(1.0, 0.0, mask);
|
||||||
|
|
||||||
|
/*
|
||||||
|
// Hard edge
|
||||||
|
if(mask + edge_bleed < 0.5) {
|
||||||
|
ALPHA = 1.0;
|
||||||
|
} else {
|
||||||
|
ALPHA = 0.0;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Hardish edge
|
||||||
|
ALPHA = hardstep(1.0 - mask + edge_bleed);
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user