Game files
This commit is contained in:
77
Scripts/Characters/cCharacter.gd
Normal file
77
Scripts/Characters/cCharacter.gd
Normal file
@@ -0,0 +1,77 @@
|
||||
class_name cCharacter
|
||||
extends Node
|
||||
|
||||
const Map = preload("res://Scripts/Levels/lsOffice.gd")
|
||||
|
||||
# --- Parameters ---
|
||||
@export_range(0, 20) var ai_level := 10
|
||||
|
||||
@export var min_interval := 8
|
||||
@export var max_interval := 12
|
||||
|
||||
@export var reset_after_climax := true
|
||||
|
||||
# --- Constants ---
|
||||
const MAX_STATE := 6
|
||||
const DEBUG := true
|
||||
|
||||
# --- Runtime ---
|
||||
var state: int = 0
|
||||
var current_location: int = Global.LocationID.POWER_STATION
|
||||
var move_timer := 0.0
|
||||
var stunted: bool = false
|
||||
|
||||
func get_room_presence(room_id):
|
||||
if current_location != room_id:
|
||||
return -1
|
||||
return state
|
||||
|
||||
func _ready() -> void:
|
||||
randomize()
|
||||
_set_next_interval()
|
||||
|
||||
# Pick the next random movement interval (3–5 sec)
|
||||
func _set_next_interval() -> void:
|
||||
move_timer = randf_range(min_interval, max_interval)
|
||||
|
||||
# Rolls to see if the character may move
|
||||
func try_move(delta: float) -> bool:
|
||||
move_timer -= delta
|
||||
if move_timer > 0.0:
|
||||
return false
|
||||
|
||||
# Interval completed → immediately pick the next one
|
||||
_set_next_interval()
|
||||
|
||||
# Roll 1–20 like OG FNAF
|
||||
var roll := randi_range(1, 20)
|
||||
|
||||
if DEBUG:
|
||||
print(name, " | AI:", ai_level, " | Roll:", roll)
|
||||
|
||||
return roll <= ai_level
|
||||
|
||||
func advance_state() -> void:
|
||||
if state >= MAX_STATE:
|
||||
if reset_after_climax:
|
||||
state = 0
|
||||
else:
|
||||
state += 1
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if try_move(delta):
|
||||
if(stunted):
|
||||
stunted = false
|
||||
return
|
||||
advance_state()
|
||||
if (randi_range(1, 20) > 10):
|
||||
stunted = true
|
||||
|
||||
match state:
|
||||
0: pass # dormant
|
||||
1: pass
|
||||
2: pass
|
||||
3: pass
|
||||
4: pass
|
||||
5: pass
|
||||
6: pass
|
||||
1
Scripts/Characters/cCharacter.gd.uid
Normal file
1
Scripts/Characters/cCharacter.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://tjwgfir0ecm6
|
||||
40
Scripts/Characters/cCharacter_Debug.gd
Normal file
40
Scripts/Characters/cCharacter_Debug.gd
Normal file
@@ -0,0 +1,40 @@
|
||||
extends Node2D
|
||||
|
||||
@export var target: Node
|
||||
@export var night_manager: NightManager
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
queue_redraw()
|
||||
|
||||
func _draw() -> void:
|
||||
if target == null:
|
||||
return
|
||||
|
||||
var nighttext := "TIME: %.2f\nHOUR: %d" % [
|
||||
night_manager.hour_timer,
|
||||
night_manager.current_hour
|
||||
]
|
||||
|
||||
|
||||
var text := "STATE: %s\nTIMER: %.2f\nLOCATION: %s" % [
|
||||
target.state,
|
||||
target.move_timer,
|
||||
target.current_location
|
||||
]
|
||||
|
||||
draw_string(
|
||||
ThemeDB.fallback_font,
|
||||
Vector2(10, -10),
|
||||
text,
|
||||
HORIZONTAL_ALIGNMENT_LEFT,
|
||||
-1,
|
||||
14
|
||||
)
|
||||
draw_string(
|
||||
ThemeDB.fallback_font,
|
||||
Vector2(10, -30),
|
||||
nighttext,
|
||||
HORIZONTAL_ALIGNMENT_LEFT,
|
||||
-1,
|
||||
14
|
||||
)
|
||||
1
Scripts/Characters/cCharacter_Debug.gd.uid
Normal file
1
Scripts/Characters/cCharacter_Debug.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://cntxldpts5png
|
||||
15
Scripts/Characters/cConstruct.gd
Normal file
15
Scripts/Characters/cConstruct.gd
Normal file
@@ -0,0 +1,15 @@
|
||||
class_name cConstruct extends cCharacter
|
||||
|
||||
signal location_changed(ai, old_location, new_location)
|
||||
signal state_changed(ai, old_state, new_state)
|
||||
|
||||
@export var night_manager: NightManager
|
||||
|
||||
func _ready():
|
||||
night_manager.hour_changed.connect(_on_hour_changed)
|
||||
|
||||
func _on_hour_changed(hour: int):
|
||||
if hour == 1:
|
||||
ai_level += 2
|
||||
if hour == 3:
|
||||
ai_level += 5
|
||||
1
Scripts/Characters/cConstruct.gd.uid
Normal file
1
Scripts/Characters/cConstruct.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://qp1x4i2r65hr
|
||||
7
Scripts/Effects/efStatic.gd
Normal file
7
Scripts/Effects/efStatic.gd
Normal file
@@ -0,0 +1,7 @@
|
||||
extends AnimatedSprite2D
|
||||
|
||||
@export var animationname: String = "default"
|
||||
|
||||
func _ready() -> void:
|
||||
self.play(animationname)
|
||||
print("Playing animation")
|
||||
1
Scripts/Effects/efStatic.gd.uid
Normal file
1
Scripts/Effects/efStatic.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://cw6yeu0c7lgr2
|
||||
27
Scripts/Effects/efVideoDistortion.gd
Normal file
27
Scripts/Effects/efVideoDistortion.gd
Normal file
@@ -0,0 +1,27 @@
|
||||
extends ColorRect
|
||||
|
||||
@export var amount_base := 0.15 # minimum glitch
|
||||
@export var amount_amp := 0.25 # how strong the wave is
|
||||
@export var amount_speed := 1.2 # speed of oscillation
|
||||
|
||||
var time := 0.0
|
||||
@onready var mat := material as ShaderMaterial
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if not mat:
|
||||
return
|
||||
|
||||
time += delta
|
||||
|
||||
# Animate seed (row randomness)
|
||||
mat.set_shader_parameter("seed", time * 10.0)
|
||||
|
||||
# Sine wave for amount
|
||||
var wave := (sin(time * amount_speed) + 1.0) * 0.5
|
||||
var amount := amount_base + wave * amount_amp
|
||||
|
||||
# random surge
|
||||
if randi() % 120 == 0:
|
||||
amount += 0.3
|
||||
|
||||
mat.set_shader_parameter("amount", amount)
|
||||
1
Scripts/Effects/efVideoDistortion.gd.uid
Normal file
1
Scripts/Effects/efVideoDistortion.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dauob2yqkuh6m
|
||||
14
Scripts/Levels/Rooms/crHallwayL.gd
Normal file
14
Scripts/Levels/Rooms/crHallwayL.gd
Normal file
@@ -0,0 +1,14 @@
|
||||
extends Room
|
||||
class_name HallWayL
|
||||
|
||||
func _ready():
|
||||
render_map = {
|
||||
"": preload("res://Renders/Camera/HallWayL/HallwayL0001.png"),
|
||||
"Yoshida:0": preload("res://Renders/Camera/HallWayL/HallwayL0001.png"),
|
||||
"Yoshida:1": preload("res://Renders/Camera/HallWayL/HallwayL0002.png"),
|
||||
"Yoshida:2": preload("res://Renders/Camera/HallWayL/HallwayL0003.png"),
|
||||
}
|
||||
room_id = Global.LocationID.POWER_STATION
|
||||
|
||||
func _process(_delta):
|
||||
super._process(_delta)
|
||||
1
Scripts/Levels/Rooms/crHallwayL.gd.uid
Normal file
1
Scripts/Levels/Rooms/crHallwayL.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://cfn4cgsc5amet
|
||||
17
Scripts/Levels/Rooms/crPowerRoom.gd
Normal file
17
Scripts/Levels/Rooms/crPowerRoom.gd
Normal file
@@ -0,0 +1,17 @@
|
||||
extends Room
|
||||
class_name PowerRoom
|
||||
|
||||
func _ready():
|
||||
render_map = {
|
||||
"default": preload("res://Renders/Camera/PowerStation/powerstation_1.png"),
|
||||
"cConstructBrain:0": preload("res://Renders/Camera/PowerStation/powerstation_wide_1.png"),
|
||||
"cConstructBrain:1": preload("res://Renders/Camera/PowerStation/powerstation_wide_2.png"),
|
||||
"cConstructBrain:2": preload("res://Renders/Camera/PowerStation/powerstation_wide_3.png"),
|
||||
"cConstructBrain:3": preload("res://Renders/Camera/PowerStation/powerstation_wide_4.png"),
|
||||
"cConstructBrain:4": preload("res://Renders/Camera/PowerStation/powerstation_wide_5.png"),
|
||||
"cConstructBrain:5": preload("res://Renders/Camera/PowerStation/powerstation_wide_6.png"),
|
||||
}
|
||||
room_id = Global.LocationID.POWER_STATION
|
||||
|
||||
func _process(_delta):
|
||||
super._process(_delta)
|
||||
1
Scripts/Levels/Rooms/crPowerRoom.gd.uid
Normal file
1
Scripts/Levels/Rooms/crPowerRoom.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://d1k3x55514fyq
|
||||
78
Scripts/Levels/lsOffice.gd
Normal file
78
Scripts/Levels/lsOffice.gd
Normal file
@@ -0,0 +1,78 @@
|
||||
class_name lsOffice extends Node
|
||||
|
||||
# Discrete places a monster can exist
|
||||
@export var officeLayer: CanvasLayer
|
||||
@export var cameraUnit: CanvasLayer
|
||||
@export var cameraAnimation: AnimatedSprite2D
|
||||
@export var cameraLayer: CanvasLayer
|
||||
|
||||
var camAnimPlaying: bool = false
|
||||
|
||||
func _ready() -> void:
|
||||
cameraLayer.hide()
|
||||
officeLayer.show()
|
||||
cameraUnit.hide()
|
||||
Global.currentPlayerState = Global.playerState.eState_Office
|
||||
|
||||
|
||||
func _on_camerabutton_mouse_entered() -> void:
|
||||
if(camAnimPlaying): return
|
||||
match Global.currentPlayerState:
|
||||
Global.playerState.eState_Menu:
|
||||
pass
|
||||
Global.playerState.eState_Office:
|
||||
Global.currentPlayerState = Global.playerState.eState_Camera
|
||||
_bringCameraUp()
|
||||
pass
|
||||
Global.playerState.eState_Camera:
|
||||
Global.currentPlayerState = Global.playerState.eState_Office
|
||||
_bringCameraDown()
|
||||
pass
|
||||
Global.playerState.eState_Dead:
|
||||
pass
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
func _on_camerabutton_mouse_exited() -> void:
|
||||
if(camAnimPlaying): return
|
||||
match Global.currentPlayerState:
|
||||
Global.playerState.eState_Menu:
|
||||
pass
|
||||
Global.playerState.eState_Office:
|
||||
pass
|
||||
Global.playerState.eState_Camera:
|
||||
pass
|
||||
Global.playerState.eState_Dead:
|
||||
pass
|
||||
pass # Replace with function body.
|
||||
|
||||
func _bringCameraUp() -> int:
|
||||
cameraUnit.show()
|
||||
cameraAnimation.play("flipup")
|
||||
|
||||
camAnimPlaying = true
|
||||
await cameraAnimation.animation_finished
|
||||
camAnimPlaying = false
|
||||
|
||||
officeLayer.hide()
|
||||
cameraLayer.show()
|
||||
cameraUnit.hide()
|
||||
return 0
|
||||
|
||||
func _bringCameraDown() -> int:
|
||||
officeLayer.show()
|
||||
cameraUnit.show()
|
||||
|
||||
cameraAnimation.play("flipup", -1)
|
||||
cameraLayer.hide()
|
||||
|
||||
camAnimPlaying = true
|
||||
await cameraAnimation.animation_finished
|
||||
camAnimPlaying = false
|
||||
|
||||
cameraUnit.hide()
|
||||
return 0
|
||||
|
||||
|
||||
func _on_night_manager_night_completed() -> void:
|
||||
pass # Replace with function body.
|
||||
1
Scripts/Levels/lsOffice.gd.uid
Normal file
1
Scripts/Levels/lsOffice.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://vunrx4ig88oq
|
||||
12
Scripts/Levels/lsTitle.gd
Normal file
12
Scripts/Levels/lsTitle.gd
Normal file
@@ -0,0 +1,12 @@
|
||||
extends Node
|
||||
|
||||
var scene_office = "res://Levels/officeA.tscn"
|
||||
func _ready() -> void:
|
||||
pass
|
||||
|
||||
func _on_b_continue_pressed() -> void:
|
||||
pass
|
||||
|
||||
|
||||
func _on_b_new_game_pressed() -> void:
|
||||
get_tree().change_scene_to_file(scene_office)
|
||||
1
Scripts/Levels/lsTitle.gd.uid
Normal file
1
Scripts/Levels/lsTitle.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://cmf13qcy55iyu
|
||||
28
Scripts/Logic/NightManager.gd
Normal file
28
Scripts/Logic/NightManager.gd
Normal file
@@ -0,0 +1,28 @@
|
||||
class_name NightManager
|
||||
extends Node
|
||||
|
||||
signal hour_changed(new_hour)
|
||||
signal night_completed
|
||||
|
||||
@export var seconds_per_hour := 10.0 # FNAF-ish
|
||||
@export var start_hour := 12
|
||||
@export var end_hour := 6
|
||||
|
||||
var current_hour := start_hour
|
||||
var hour_timer := 0.0
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
hour_timer += delta
|
||||
if hour_timer >= seconds_per_hour:
|
||||
hour_timer = 0.0
|
||||
_advance_hour()
|
||||
|
||||
func _advance_hour() -> void:
|
||||
if current_hour == 12:
|
||||
current_hour = 1
|
||||
else:
|
||||
current_hour += 1
|
||||
emit_signal("hour_changed", current_hour)
|
||||
|
||||
if current_hour >= end_hour:
|
||||
emit_signal("night_completed")
|
||||
1
Scripts/Logic/NightManager.gd.uid
Normal file
1
Scripts/Logic/NightManager.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://ttgieweerpay
|
||||
47
Scripts/Logic/cCameraManager.gd
Normal file
47
Scripts/Logic/cCameraManager.gd
Normal file
@@ -0,0 +1,47 @@
|
||||
# CameraSystem.gd
|
||||
extends Node
|
||||
class_name CameraManager
|
||||
|
||||
@export var display: TextureRect
|
||||
var current_room: Room
|
||||
@export var rooms: Array[Room] = []
|
||||
|
||||
func select_room(room_id: Global.LocationID):
|
||||
for room in rooms:
|
||||
print(room, room.room_id)
|
||||
print("Comparing room id: ", room.room_id, " With: ", room_id)
|
||||
if room.room_id == room_id:
|
||||
current_room = room
|
||||
break
|
||||
|
||||
func force_room(index: int):
|
||||
if index >= 0 and index < rooms.size():
|
||||
current_room = rooms[index]
|
||||
else:
|
||||
print("force_room: invalid index ", index)
|
||||
|
||||
func _process(_delta):
|
||||
if current_room == null:
|
||||
current_room = rooms[0]
|
||||
if current_room:
|
||||
current_room._process(_delta)
|
||||
display.texture = current_room.getTexture()
|
||||
|
||||
|
||||
func _on_cam_pressed(id:int) -> void:
|
||||
print("Camera Change with: ", id)
|
||||
force_room(id)
|
||||
return
|
||||
var eRoom: Global.LocationID
|
||||
match id:
|
||||
0: eRoom = Global.LocationID.POWER_STATION
|
||||
1: eRoom = Global.LocationID.DINING_AREA
|
||||
2: eRoom = Global.LocationID.WEST_HALL
|
||||
3: eRoom = Global.LocationID.EAST_HALL
|
||||
4: eRoom = Global.LocationID.SUPPLY_CLOSET
|
||||
5: eRoom = Global.LocationID.BACKSTAGE
|
||||
6: eRoom = Global.LocationID.LIVING_AREA
|
||||
7: eRoom = Global.LocationID.OFFICE_LEFT_DOOR
|
||||
8: eRoom = Global.LocationID.OFFICE_RIGHT_DOOR
|
||||
9: eRoom = Global.LocationID.OFFICE
|
||||
select_room(eRoom)
|
||||
1
Scripts/Logic/cCameraManager.gd.uid
Normal file
1
Scripts/Logic/cCameraManager.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://cxj3fa512gs6r
|
||||
47
Scripts/Logic/cPlayerCamera.gd
Normal file
47
Scripts/Logic/cPlayerCamera.gd
Normal file
@@ -0,0 +1,47 @@
|
||||
extends Camera2D
|
||||
|
||||
var screenWidth = ProjectSettings.get_setting("display/window/size/viewport_width")
|
||||
var screenHeight = ProjectSettings.get_setting("display/window/size/viewport_height")
|
||||
|
||||
@export var scrollArea : int
|
||||
@export var scrollSpeed : float
|
||||
@export var scrollDivisions : int
|
||||
@export var officeSprite : Sprite2D
|
||||
|
||||
var officeWidth : int
|
||||
var officeHeight : int
|
||||
var distance : float
|
||||
var divisionSize : float
|
||||
var speedMultiplier : float
|
||||
|
||||
func _ready() -> void:
|
||||
make_current()
|
||||
print("Camera Running")
|
||||
if scrollDivisions == 0:
|
||||
scrollDivisions = 1
|
||||
divisionSize = scrollArea / scrollDivisions
|
||||
if officeSprite:
|
||||
officeWidth = officeSprite.texture.get_width() * officeSprite.scale.x
|
||||
position.x = officeSprite.position.x + (officeWidth - screenWidth) / 2
|
||||
officeHeight = officeSprite.texture.get_height() * officeSprite.scale.y
|
||||
position.y = officeSprite.position.y + (officeHeight - screenHeight) / 2
|
||||
|
||||
func _process(delta : float) -> void:
|
||||
if get_local_mouse_position().x < scrollArea:
|
||||
distance = scrollArea - get_local_mouse_position().x
|
||||
getSpeedMultiplier()
|
||||
position.x -= (scrollSpeed * speedMultiplier) * delta
|
||||
if get_local_mouse_position().x > screenWidth - scrollArea:
|
||||
distance = get_local_mouse_position().x - (screenWidth - scrollArea)
|
||||
getSpeedMultiplier()
|
||||
position.x += (scrollSpeed * speedMultiplier) * delta
|
||||
|
||||
if officeSprite:
|
||||
if position.x < officeSprite.position.x:
|
||||
position.x = officeSprite.position.x
|
||||
if (position.x - officeSprite.position.x) + screenWidth > officeWidth:
|
||||
position.x = officeWidth - screenWidth + officeSprite.position.x
|
||||
|
||||
func getSpeedMultiplier() -> void:
|
||||
speedMultiplier = clamp(floor(distance / divisionSize) + 1, 1, scrollDivisions)
|
||||
speedMultiplier /= scrollDivisions
|
||||
1
Scripts/Logic/cPlayerCamera.gd.uid
Normal file
1
Scripts/Logic/cPlayerCamera.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://c14ey58hfx7i8
|
||||
55
Scripts/Logic/cRoom.gd
Normal file
55
Scripts/Logic/cRoom.gd
Normal file
@@ -0,0 +1,55 @@
|
||||
extends Node
|
||||
class_name Room
|
||||
|
||||
#@export var visual: TextureRect
|
||||
|
||||
# One entry per valid combination
|
||||
# Key = sorted list of enemy IDs + their pose index
|
||||
#@export var render_map: Dictionary
|
||||
|
||||
@export var enemies: Array[cCharacter] # all AI that *could* appear here
|
||||
@export var room_id: Global.LocationID
|
||||
var last_key := ""
|
||||
var texture: Texture2D
|
||||
var render_map: Dictionary
|
||||
|
||||
#func _process(_delta):
|
||||
#var key := _build_render_key()
|
||||
#if key == last_key:
|
||||
#return
|
||||
#
|
||||
#last_key = key
|
||||
#
|
||||
#
|
||||
#if render_map.has(key):
|
||||
#visual.texture = render_map[key]
|
||||
#else:
|
||||
#visual.texture = null # or fallback
|
||||
|
||||
func _process(_delta):
|
||||
var key := _build_render_key()
|
||||
if key == null: texture = render_map[""]
|
||||
|
||||
if key == last_key:
|
||||
return
|
||||
#
|
||||
last_key = key
|
||||
#
|
||||
if render_map.has(key):
|
||||
texture = render_map[key]
|
||||
else:
|
||||
texture = render_map["default"]
|
||||
|
||||
func getTexture() -> Texture2D:
|
||||
return texture
|
||||
|
||||
func _build_render_key() -> String:
|
||||
var entries := []
|
||||
|
||||
for enemy in enemies:
|
||||
var presence : int = enemy.get_room_presence(room_id)
|
||||
if presence >= 0:
|
||||
entries.append("%s:%d" % [enemy.name, presence])
|
||||
|
||||
entries.sort()
|
||||
return "|".join(entries)
|
||||
1
Scripts/Logic/cRoom.gd.uid
Normal file
1
Scripts/Logic/cRoom.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://bh0j1ffo2peo0
|
||||
85
Scripts/Logic/video_distortion.gdshader
Normal file
85
Scripts/Logic/video_distortion.gdshader
Normal file
@@ -0,0 +1,85 @@
|
||||
shader_type canvas_item;
|
||||
|
||||
uniform sampler2D SCREEN_TEXTURE : hint_screen_texture, filter_linear_mipmap;
|
||||
uniform float amount : hint_range(0.0, 1.0) = 0.5;
|
||||
uniform float seed = 0.0;
|
||||
uniform float line_density : hint_range(0.0, 1.0) = 0.4;
|
||||
uniform float offset_mul : hint_range(0.0, 2.0) = 1.0;
|
||||
|
||||
uniform vec2 screen_offset = vec2(0.0);
|
||||
uniform vec2 screen_bend_amount = vec2(0.02, 0.02);
|
||||
|
||||
float hash1d(float p) {
|
||||
return fract(sin(127.1 * p) * 43758.5453123);
|
||||
}
|
||||
|
||||
void fragment() {
|
||||
/* ===============================
|
||||
Coordinate setup
|
||||
================================ */
|
||||
|
||||
vec2 uv = SCREEN_UV;
|
||||
uv += screen_offset;
|
||||
|
||||
// Screen bend (CRT-like)
|
||||
vec2 normal_uv = uv * 2.0 - 1.0;
|
||||
vec2 bend_add;
|
||||
bend_add.x = cos(1.5707963 * normal_uv.y) * normal_uv.x - normal_uv.x * 1.5;
|
||||
bend_add.y = cos(1.5707963 * normal_uv.x) * normal_uv.y - normal_uv.y * 1.5;
|
||||
uv += bend_add * screen_bend_amount;
|
||||
|
||||
vec4 base_color = texture(SCREEN_TEXTURE, uv);
|
||||
|
||||
vec2 virtual_coords = uv * 100.0;
|
||||
|
||||
/* ===============================
|
||||
Row-based randomization
|
||||
================================ */
|
||||
|
||||
float row_rand = hash1d(seed + floor(virtual_coords.y * 0.1));
|
||||
float y_mul = mix(0.05, 0.8, row_rand * row_rand);
|
||||
float rand_strength = hash1d(floor(virtual_coords.y * y_mul) + 100.0 + row_rand);
|
||||
|
||||
float final_amount = 0.0;
|
||||
float coord_add = 0.0;
|
||||
|
||||
if (rand_strength > (1.0 - line_density)) {
|
||||
float distort_amount = 0.15;
|
||||
|
||||
final_amount = amount * (
|
||||
0.5 +
|
||||
(hash1d(floor(virtual_coords.y * y_mul) + 1273.0 + floor(amount * 4.0)) * 2.0 - 1.0) * 0.5
|
||||
);
|
||||
|
||||
float ra = hash1d(floor(virtual_coords.y)) * 2.0 - 1.0;
|
||||
coord_add = ra * distort_amount * final_amount;
|
||||
coord_add += (hash1d(floor(virtual_coords.x * 0.25)) * 2.0 - 1.0) * distort_amount * 0.4;
|
||||
coord_add *= offset_mul;
|
||||
}
|
||||
|
||||
/* ===============================
|
||||
Intensity weighting
|
||||
================================ */
|
||||
|
||||
float intensity = dot(base_color.rgb, vec3(0.3, 0.58, 0.12));
|
||||
intensity = clamp(intensity, 0.0, 1.0);
|
||||
|
||||
float dual_intensity = abs(intensity * 2.0 - 1.0);
|
||||
dual_intensity *= dual_intensity;
|
||||
|
||||
/* ===============================
|
||||
Distortion sampling
|
||||
================================ */
|
||||
|
||||
vec4 samp1 = texture(SCREEN_TEXTURE, uv + vec2(coord_add * -0.65 * dual_intensity, 0.0));
|
||||
vec4 samp2 = texture(SCREEN_TEXTURE, uv + vec2(coord_add * 1.0 * dual_intensity, 0.0));
|
||||
vec4 distort_color = mix(samp1, samp2, 0.5);
|
||||
|
||||
/* ===============================
|
||||
Final output
|
||||
================================ */
|
||||
|
||||
float mix_amount = dual_intensity * final_amount;
|
||||
COLOR = mix(base_color, distort_color, mix_amount)
|
||||
+ vec4(vec3(intensity * final_amount * 0.05), 1.0);
|
||||
}
|
||||
1
Scripts/Logic/video_distortion.gdshader.uid
Normal file
1
Scripts/Logic/video_distortion.gdshader.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dy4tffth3v12b
|
||||
Reference in New Issue
Block a user