adding extra assets and playing with crt shader

This commit is contained in:
derek
2024-07-24 14:18:17 -05:00
parent 6e8666db74
commit f645d44243
11 changed files with 457 additions and 1 deletions

Binary file not shown.

View File

@@ -0,0 +1,50 @@
[remap]
importer="scene"
importer_version=1
type="PackedScene"
uid="uid://bbu2xjd7fgvty"
path="res://.godot/imported/DecorationAssetsPt1.blend-26f0eb7c9a0f67d7939542f54c17e659.scn"
[deps]
source_file="res://assets/Models/DecorationAssetsPt1.blend"
dest_files=["res://.godot/imported/DecorationAssetsPt1.blend-26f0eb7c9a0f67d7939542f54c17e659.scn"]
[params]
nodes/root_type=""
nodes/root_name=""
nodes/apply_root_scale=true
nodes/root_scale=1.0
meshes/ensure_tangents=true
meshes/generate_lods=true
meshes/create_shadow_meshes=true
meshes/light_baking=1
meshes/lightmap_texel_size=0.2
meshes/force_disable_compression=false
skins/use_named_skins=true
animation/import=true
animation/fps=30
animation/trimming=false
animation/remove_immutable_tracks=true
import_script/path=""
_subresources={}
gltf/naming_version=1
gltf/embedded_image_handling=1
blender/nodes/visible=0
blender/nodes/punctual_lights=true
blender/nodes/cameras=true
blender/nodes/custom_properties=true
blender/nodes/modifiers=1
blender/meshes/colors=false
blender/meshes/uvs=true
blender/meshes/normals=true
blender/meshes/tangents=true
blender/meshes/skins=2
blender/meshes/export_bones_deforming_mesh_only=false
blender/materials/unpack_enabled=true
blender/materials/export_materials=1
blender/animation/limit_playback=true
blender/animation/always_sample=true
blender/animation/group_tracks=true

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

View File

@@ -0,0 +1,35 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://cmgjp40fnd7cl"
path.s3tc="res://.godot/imported/watertower1.albedo.png-7db6a66956c97ddf5fa0caa1496788d7.s3tc.ctex"
metadata={
"imported_formats": ["s3tc_bptc"],
"vram_texture": true
}
[deps]
source_file="res://assets/Models/watertower1.albedo.png"
dest_files=["res://.godot/imported/watertower1.albedo.png-7db6a66956c97ddf5fa0caa1496788d7.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

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

View File

@@ -0,0 +1,35 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://c6pmgc2a6jhrv"
path.s3tc="res://.godot/imported/watertower1.rough.png-21d3b03262dbc201846f13a08c9b5a23.s3tc.ctex"
metadata={
"imported_formats": ["s3tc_bptc"],
"vram_texture": true
}
[deps]
source_file="res://assets/Models/watertower1.rough.png"
dest_files=["res://.godot/imported/watertower1.rough.png-21d3b03262dbc201846f13a08c9b5a23.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

231
assets/crtTest.gdshader Normal file
View File

@@ -0,0 +1,231 @@
/*
Shader from Godot Shaders - the free shader library.
godotshaders.com/shader/VHS-and-CRT-monitor-effect
This shader is under CC0 license. Feel free to use, improve and
change this shader according to your needs and consider sharing
the modified result to godotshaders.com.
*/
shader_type canvas_item;
//*** IMPORTANT! ***/
// - If you are using this shader to affect the node it is applied to set 'overlay' to false (unchecked in the instepctor).
// - If you are using this shader as an overlay, and want the shader to affect the nodes below in the Scene hierarchy,
// set 'overlay' to true (checked in the inspector).
// On Mac there is potentially a bug causing this to not work properly. If that is the case and you want to use the shader as an overlay
// change all "overlay ? SCREEN_TEXTURE : TEXTURE" to only "SCREEN_TEXTURE" on lines 129-140, and "vec2 uv = overlay ? warp(SCREEN_UV) : warp(UV);"
// to "vec2 uv = warp(SCREEN_UV);" on line 98.
uniform bool overlay = true;
uniform sampler2D SCREEN_TEXTURE : hint_screen_texture, filter_linear_mipmap;
uniform float scanlines_opacity : hint_range(0.0, 1.0) = 0.4;
uniform float scanlines_width : hint_range(0.0, 0.5) = 0.25;
uniform float grille_opacity : hint_range(0.0, 1.0) = 0.3;
uniform vec2 resolution = vec2(640.0, 480.0); // Set the number of rows and columns the texture will be divided in. Scanlines and grille will make a square based on these values
uniform bool pixelate = true; // Fill each square ("pixel") with a sampled color, creating a pixel look and a more accurate representation of how a CRT monitor would work.
uniform bool roll = true;
uniform float roll_speed = 8.0; // Positive values are down, negative are up
uniform float roll_size : hint_range(0.0, 100.0) = 15.0;
uniform float roll_variation : hint_range(0.1, 5.0) = 1.8; // This valie is not an exact science. You have to play around with the value to find a look you like. How this works is explained in the code below.
uniform float distort_intensity : hint_range(0.0, 0.2) = 0.05; // The distortion created by the rolling effect.
uniform float noise_opacity : hint_range(0.0, 1.0) = 0.4;
uniform float noise_speed = 5.0; // There is a movement in the noise pattern that can be hard to see first. This sets the speed of that movement.
uniform float static_noise_intensity : hint_range(0.0, 1.0) = 0.06;
uniform float aberration : hint_range(-1.0, 1.0) = 0.03; // Chromatic aberration, a distortion on each color channel.
uniform float brightness = 1.4; // When adding scanline gaps and grille the image can get very dark. Brightness tries to compensate for that.
uniform bool discolor = true; // Add a discolor effect simulating a VHS
uniform float warp_amount :hint_range(0.0, 5.0) = 1.0; // Warp the texture edges simulating the curved glass of a CRT monitor or old TV.
uniform bool clip_warp = false;
uniform float vignette_intensity = 0.4; // Size of the vignette, how far towards the middle it should go.
uniform float vignette_opacity : hint_range(0.0, 1.0) = 0.5;
// Used by the noise functin to generate a pseudo random value between 0.0 and 1.0
vec2 random(vec2 uv){
uv = vec2( dot(uv, vec2(127.1,311.7) ),
dot(uv, vec2(269.5,183.3) ) );
return -1.0 + 2.0 * fract(sin(uv) * 43758.5453123);
}
// Generate a Perlin noise used by the distortion effects
float noise(vec2 uv) {
vec2 uv_index = floor(uv);
vec2 uv_fract = fract(uv);
vec2 blur = smoothstep(0.0, 1.0, uv_fract);
return mix( mix( dot( random(uv_index + vec2(0.0,0.0) ), uv_fract - vec2(0.0,0.0) ),
dot( random(uv_index + vec2(1.0,0.0) ), uv_fract - vec2(1.0,0.0) ), blur.x),
mix( dot( random(uv_index + vec2(0.0,1.0) ), uv_fract - vec2(0.0,1.0) ),
dot( random(uv_index + vec2(1.0,1.0) ), uv_fract - vec2(1.0,1.0) ), blur.x), blur.y) * 0.5 + 0.5;
}
// Takes in the UV and warps the edges, creating the spherized effect
vec2 warp(vec2 uv){
vec2 delta = uv - 0.5;
float delta2 = dot(delta.xy, delta.xy);
float delta4 = delta2 * delta2;
float delta_offset = delta4 * warp_amount;
return uv + delta * delta_offset;
}
// Adds a black border to hide stretched pixel created by the warp effect
float border (vec2 uv){
float radius = min(warp_amount, 0.08);
radius = max(min(min(abs(radius * 2.0), abs(1.0)), abs(1.0)), 1e-5);
vec2 abs_uv = abs(uv * 2.0 - 1.0) - vec2(1.0, 1.0) + radius;
float dist = length(max(vec2(0.0), abs_uv)) / radius;
float square = smoothstep(0.96, 1.0, dist);
return clamp(1.0 - square, 0.0, 1.0);
}
// Adds a vignette shadow to the edges of the image
float vignette(vec2 uv){
uv *= 1.0 - uv.xy;
float vignette = uv.x * uv.y * 15.0;
return pow(vignette, vignette_intensity * vignette_opacity);
}
void fragment()
{
vec2 uv = overlay ? warp(SCREEN_UV) : warp(UV); // Warp the uv. uv will be used in most cases instead of UV to keep the warping
vec2 text_uv = uv;
vec2 roll_uv = vec2(0.0);
float time = roll ? TIME : 0.0;
// Pixelate the texture based on the given resolution.
if (pixelate)
{
text_uv = ceil(uv * resolution) / resolution;
}
// Create the rolling effect. We need roll_line a bit later to make the noise effect.
// That is why this runs if roll is true OR noise_opacity is over 0.
float roll_line = 0.0;
if (roll || noise_opacity > 0.0)
{
// Create the areas/lines where the texture will be distorted.
roll_line = smoothstep(0.3, 0.9, sin(uv.y * roll_size - (time * roll_speed) ) );
// Create more lines of a different size and apply to the first set of lines. This creates a bit of variation.
roll_line *= roll_line * smoothstep(0.3, 0.9, sin(uv.y * roll_size * roll_variation - (time * roll_speed * roll_variation) ) );
// Distort the UV where where the lines are
roll_uv = vec2(( roll_line * distort_intensity * (1.-UV.x)), 0.0);
}
vec4 text;
if (roll)
{
// If roll is true distort the texture with roll_uv. The texture is split up into RGB to
// make some chromatic aberration. We apply the aberration to the red and green channels accorging to the aberration parameter
// and intensify it a bit in the roll distortion.
text.r = texture(SCREEN_TEXTURE, text_uv + roll_uv * 0.8 + vec2(aberration, 0.0) * .1).r;
text.g = texture(SCREEN_TEXTURE, text_uv + roll_uv * 1.2 - vec2(aberration, 0.0) * .1 ).g;
text.b = texture(SCREEN_TEXTURE, text_uv + roll_uv).b;
text.a = 1.0;
}
else
{
// If roll is false only apply the aberration without any distorion. The aberration values are very small so the .1 is only
// to make the slider in the Inspector less sensitive.
text.r = texture(SCREEN_TEXTURE, text_uv + vec2(aberration, 0.0) * .1).r;
text.g = texture(SCREEN_TEXTURE, text_uv - vec2(aberration, 0.0) * .1).g;
text.b = texture(SCREEN_TEXTURE, text_uv).b;
text.a = 1.0;
}
float r = text.r;
float g = text.g;
float b = text.b;
uv = warp(UV);
// CRT monitors don't have pixels but groups of red, green and blue dots or lines, called grille. We isolate the texture's color channels
// and divide it up in 3 offsetted lines to show the red, green and blue colors next to each other, with a small black gap between.
if (grille_opacity > 0.0){
float g_r = smoothstep(0.85, 0.95, abs(sin(uv.x * (resolution.x * 3.14159265))));
r = mix(r, r * g_r, grille_opacity);
float g_g = smoothstep(0.85, 0.95, abs(sin(1.05 + uv.x * (resolution.x * 3.14159265))));
g = mix(g, g * g_g, grille_opacity);
float b_b = smoothstep(0.85, 0.95, abs(sin(2.1 + uv.x * (resolution.x * 3.14159265))));
b = mix(b, b * b_b, grille_opacity);
}
// Apply the grille to the texture's color channels and apply Brightness. Since the grille and the scanlines (below) make the image very dark you
// can compensate by increasing the brightness.
text.r = clamp(r * brightness, 0.0, 1.0);
text.g = clamp(g * brightness, 0.0, 1.0);
text.b = clamp(b * brightness, 0.0, 1.0);
// Scanlines are the horizontal lines that make up the image on a CRT monitor.
// Here we are actual setting the black gap between each line, which I guess is not the right definition of the word, but you get the idea
float scanlines = 0.5;
if (scanlines_opacity > 0.0)
{
// Same technique as above, create lines with sine and applying it to the texture. Smoothstep to allow setting the line size.
scanlines = smoothstep(scanlines_width, scanlines_width + 0.5, abs(sin(uv.y * (resolution.y * 3.14159265))));
text.rgb = mix(text.rgb, text.rgb * vec3(scanlines), scanlines_opacity);
}
// Apply the banded noise.
if (noise_opacity > 0.0)
{
// Generate a noise pattern that is very stretched horizontally, and animate it with noise_speed
float noise = smoothstep(0.4, 0.5, noise(uv * vec2(2.0, 200.0) + vec2(10.0, (TIME * (noise_speed))) ) );
// We use roll_line (set above) to define how big the noise should be vertically (multiplying cuts off all black parts).
// We also add in some basic noise with random() to break up the noise pattern above. The noise is sized according to
// the resolution value set in the inspector. If you don't like this look you can
// change "ceil(uv * resolution) / resolution" to only "uv" to make it less pixelated. Or multiply resolution with som value
// greater than 1.0 to make them smaller.
roll_line *= noise * scanlines * clamp(random((ceil(uv * resolution) / resolution) + vec2(TIME * 0.8, 0.0)).x + 0.8, 0.0, 1.0);
// Add it to the texture based on noise_opacity
text.rgb = clamp(mix(text.rgb, text.rgb + roll_line, noise_opacity), vec3(0.0), vec3(1.0));
}
// Apply static noise by generating it over the whole screen in the same way as above
if (static_noise_intensity > 0.0)
{
text.rgb += clamp(random((ceil(uv * resolution) / resolution) + fract(TIME)).x, 0.0, 1.0) * static_noise_intensity;
}
// Apply a black border to hide imperfections caused by the warping.
// Also apply the vignette
text.rgb *= border(uv);
text.rgb *= vignette(uv);
// Hides the black border and make that area transparent. Good if you want to add the the texture on top an image of a TV or monitor.
if (clip_warp)
{
text.a = border(uv);
}
// Apply discoloration to get a VHS look (lower saturation and higher contrast)
// You can play with the values below or expose them in the Inspector.
float saturation = 0.1;
float contrast = 1.1;
if (discolor)
{
// Saturation
vec3 greyscale = vec3(text.r + text.g + text.b) / 3.;
text.rgb = mix(text.rgb, greyscale, saturation);
// Contrast
float midpoint = pow(0.5, 2.2);
text.rgb = (text.rgb - vec3(midpoint)) * contrast + midpoint;
}
COLOR = text;
}

View File

@@ -0,0 +1,5 @@
[gd_scene load_steps=2 format=3 uid="uid://qd8nve0hrbic"]
[ext_resource type="PackedScene" uid="uid://bbu2xjd7fgvty" path="res://assets/Models/DecorationAssetsPt1.blend" id="1_l0n6l"]
[node name="DecorationAssetsPt1" instance=ExtResource("1_l0n6l")]

62
assets/water_tower.tscn Normal file

File diff suppressed because one or more lines are too long

View File

@@ -1,4 +1,4 @@
[gd_scene load_steps=51 format=3 uid="uid://dyop6vk3rgkkb"] [gd_scene load_steps=54 format=3 uid="uid://dyop6vk3rgkkb"]
[ext_resource type="Script" path="res://scripts/LevelManager.gd" id="1_orhgl"] [ext_resource type="Script" path="res://scripts/LevelManager.gd" id="1_orhgl"]
[ext_resource type="Texture2D" uid="uid://dqs06ic3vjtwk" path="res://assets/Models/asphalt1.albedo.jpg" id="1_w4rag"] [ext_resource type="Texture2D" uid="uid://dqs06ic3vjtwk" path="res://assets/Models/asphalt1.albedo.jpg" id="1_w4rag"]
@@ -10,6 +10,8 @@
[ext_resource type="PackedScene" uid="uid://bpkmyd3wvqi5p" path="res://assets/boombox.tscn" id="6_xrg7k"] [ext_resource type="PackedScene" uid="uid://bpkmyd3wvqi5p" path="res://assets/boombox.tscn" id="6_xrg7k"]
[ext_resource type="AudioStream" uid="uid://jo4n05go5hdt" path="res://assets/Audio/train-pass-by-steady-loop-SBA-300156766.wav" id="7_00j8j"] [ext_resource type="AudioStream" uid="uid://jo4n05go5hdt" path="res://assets/Audio/train-pass-by-steady-loop-SBA-300156766.wav" id="7_00j8j"]
[ext_resource type="PackedScene" uid="uid://cnfc8rtk6l1d8" path="res://assets/crate1.tscn" id="8_b57j8"] [ext_resource type="PackedScene" uid="uid://cnfc8rtk6l1d8" path="res://assets/crate1.tscn" id="8_b57j8"]
[ext_resource type="Shader" path="res://assets/crtTest.gdshader" id="13_ur1vy"]
[ext_resource type="PackedScene" uid="uid://by3n26uvps8tb" path="res://assets/water_tower.tscn" id="14_o37f0"]
[ext_resource type="PackedScene" uid="uid://c7vrpfdh603kr" path="res://assets/bottle_1.tscn" id="15_3iv0j"] [ext_resource type="PackedScene" uid="uid://c7vrpfdh603kr" path="res://assets/bottle_1.tscn" id="15_3iv0j"]
[ext_resource type="PackedScene" uid="uid://c6bpysq1tjhy4" path="res://vendingmahcine.tscn" id="16_4ykdi"] [ext_resource type="PackedScene" uid="uid://c6bpysq1tjhy4" path="res://vendingmahcine.tscn" id="16_4ykdi"]
@@ -415,6 +417,30 @@ _data = {
[sub_resource type="BoxShape3D" id="BoxShape3D_82n8k"] [sub_resource type="BoxShape3D" id="BoxShape3D_82n8k"]
size = Vector3(16.265, 5.07275, 15.3267) size = Vector3(16.265, 5.07275, 15.3267)
[sub_resource type="ShaderMaterial" id="ShaderMaterial_kcxpj"]
shader = ExtResource("13_ur1vy")
shader_parameter/overlay = true
shader_parameter/scanlines_opacity = 0.4
shader_parameter/scanlines_width = 0.25
shader_parameter/grille_opacity = 0.3
shader_parameter/resolution = Vector2(640, 480)
shader_parameter/pixelate = true
shader_parameter/roll = true
shader_parameter/roll_speed = 8.0
shader_parameter/roll_size = 15.0
shader_parameter/roll_variation = 1.8
shader_parameter/distort_intensity = 0.05
shader_parameter/noise_opacity = 0.4
shader_parameter/noise_speed = 5.0
shader_parameter/static_noise_intensity = 0.06
shader_parameter/aberration = 0.03
shader_parameter/brightness = 1.4
shader_parameter/discolor = true
shader_parameter/warp_amount = 1.0
shader_parameter/clip_warp = false
shader_parameter/vignette_intensity = 0.4
shader_parameter/vignette_opacity = 0.5
[node name="Test Level 2" type="Node3D" node_paths=PackedStringArray("player")] [node name="Test Level 2" type="Node3D" node_paths=PackedStringArray("player")]
script = ExtResource("1_orhgl") script = ExtResource("1_orhgl")
player = NodePath("Player") player = NodePath("Player")
@@ -425,6 +451,7 @@ gun_2 = ExtResource("3_sxsd3")
[node name="Player" parent="." instance=ExtResource("2_f87c2")] [node name="Player" parent="." instance=ExtResource("2_f87c2")]
transform = Transform3D(-0.866025, 0, -0.5, 0, 1, 0, 0.5, 0, -0.866025, -16.0295, 1.4435, 12.1166) transform = Transform3D(-0.866025, 0, -0.5, 0, 1, 0, 0.5, 0, -0.866025, -16.0295, 1.4435, 12.1166)
AUDIO = false
weapon_sway_amount = 0.07 weapon_sway_amount = 0.07
weapon_rotation_amount = 0.07 weapon_rotation_amount = 0.07
@@ -613,3 +640,14 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2.69462, 1.16757, 11.2398)
[node name="vendingmahcine" parent="." instance=ExtResource("16_4ykdi")] [node name="vendingmahcine" parent="." instance=ExtResource("16_4ykdi")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.992526, 41.9909, -2.56906) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.992526, 41.9909, -2.56906)
[node name="ColorRect" type="ColorRect" parent="."]
visible = false
material = SubResource("ShaderMaterial_kcxpj")
use_parent_material = true
offset_right = 3840.0
offset_bottom = 2160.0
mouse_filter = 2
[node name="Water Tower" parent="." instance=ExtResource("14_o37f0")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -13.5814, 0.043795, 59.857)