Moved shaders to cyberarm_engine, patched up settings menu, updated gems.

This commit is contained in:
2023-01-08 17:29:31 -06:00
parent 580c9d79ce
commit 8f2d7ff905
8 changed files with 90 additions and 259 deletions

View File

@@ -1,9 +1,8 @@
GIT
remote: https://github.com/cyberarm/cyberarm_engine
revision: ab9f9e8e7a4e02df7fefbb9b5add248b7629a2f7
revision: d1d87db070578fefe97f275b63157b4212a44a89
specs:
cyberarm_engine (0.21.0)
clipboard (~> 1.3)
cyberarm_engine (0.22.0)
excon (~> 0.88)
gosu (~> 1.1)
gosu_more_drawables (~> 0.3)
@@ -21,26 +20,26 @@ GIT
GEM
remote: https://rubygems.org/
specs:
clipboard (1.3.6)
concurrent-ruby (1.1.10)
cri (2.1.0)
excon (0.92.3)
gosu (1.4.3)
excon (0.96.0)
gosu (1.4.5)
gosu_more_drawables (0.3.1)
i18n (1.11.0)
i18n (1.12.0)
concurrent-ruby (~> 1.0)
mini_portile2 (2.8.0)
nokogiri (1.13.6)
mini_portile2 (2.8.1)
nokogiri (1.14.0.rc1)
mini_portile2 (~> 2.8.0)
racc (~> 1.4)
ocra (1.3.11)
opengl-bindings (1.6.12)
racc (1.6.0)
opengl-bindings (1.6.13)
racc (1.6.2)
rake (13.0.6)
rubyzip (2.3.2)
PLATFORMS
ruby
x64-mingw-ucrt
x64-mingw32
DEPENDENCIES
@@ -55,4 +54,4 @@ DEPENDENCIES
rubyzip
BUNDLED WITH
2.3.17
2.4.1

View File

@@ -30,15 +30,17 @@ class IMICFPS
stack(width: 0.25, height: 1.0) do
end
stack(width: 0.5, height: 1.0) do
stack(width: 1.0, height: 0.25) do
title "Settings"
stack(fill: true, height: 1.0) do
title "Settings", width: 1.0, text_align: :center
stack(width: 1.0, height: 96) do
flow(width: 1.0) do
link I18n.t("menus.back"), width: nil do
pop_state
end
flow(fill: true)
button get_image("#{GAME_ROOT_PATH}/static/icons/settings_display.png"), image_width: 64, tip: I18n.t("settings.display") do
show_page(:display)
end
@@ -61,9 +63,12 @@ class IMICFPS
end
end
@page_container = stack(width: 1.0, height: 0.75, scroll: true) do
@page_container = stack(width: 1.0, fill: true, scroll: true, padding: 10) do
end
end
stack(width: 0.25, height: 1.0) do
end
end
# @categories.each do |category|
@@ -90,41 +95,42 @@ class IMICFPS
def page_display
label "Display", text_size: 50
label "Resolution"
flow do
stack do
label "Width"
label "Height"
stack(width: 1.0, height: 128) do
flow(width: 1.0) do
label "Width", width: 96
edit_line window.width.to_s, fill: true
end
stack do
edit_line window.width.to_s
edit_line window.height.to_s
flow(width: 1.0) do
label "Height", width: 96
edit_line window.height.to_s, fill: true
end
end
check_box "Fullscreen", margin_top: 25, margin_bottom: 25
# check_box "Fullscreen", margin_top: 25, margin_bottom: 25, width: 1.0
stack do
longest_string = "Gamma Correction"
flow do
label "Gamma Correction".ljust(longest_string.length, " ")
@display_gamma_correction = slider range: 0.0..1.0, value: 0.5
stack(width: 1.0, height: 128, margin_top: 20) do
flow(width: 1.0, fill: true) do
label "Gamma Correction", width: 256
@display_gamma_correction = slider range: 0.0..1.0, value: 0.5, fill: true
@display_gamma_correction.subscribe(:changed) do |_sender, value|
@display_gamma_correction_label.value = value.round(1).to_s
end
@display_gamma_correction_label = label "0.0"
end
flow do
label "Brightness".ljust(longest_string.length, " ")
@display_brightness = slider range: 0.0..1.0, value: 0.5
flow(width: 1.0, fill: true) do
label "Brightness", width: 256
@display_brightness = slider range: 0.0..1.0, value: 0.5, fill: true
@display_brightness.subscribe(:changed) do |_sender, value|
@display_brightness_label.value = value.round(1).to_s
end
@display_brightness_label = label "0.0"
end
flow do
label "Contrast".ljust(longest_string.length, " ")
@display_contrast = slider range: 0.0..1.0, value: 0.5
flow(width: 1.0, fill: true) do
label "Contrast", width: 256
@display_contrast = slider range: 0.0..1.0, value: 0.5, fill: true
@display_contrast.subscribe(:changed) do |_sender, value|
@display_contrast_label.value = value.round(1).to_s
end
@@ -135,29 +141,22 @@ class IMICFPS
def page_audio
label "Audio", text_size: 50
longest_string = "Dialogue".length
volumes = %i[master sound_effects music dialogue]
stack(width: 1.0) do
stack(width: 1.0, height: 48 * volumes.count) do
volumes.each do |volume|
config_value = window.config.get(:options, :audio, :"volume_#{volume}")
flow(width: 1.0, margin_bottom: 10) do
flow(width: 0.25) do
label volume.to_s.split("_").map(&:capitalize).join(" ").ljust(longest_string, " ")
flow(width: 1.0, fill: true, margin_bottom: 10) do
label volume.to_s.split("_").map(&:capitalize).join(" "), width: 172
instance_variable_set(:"@volume_#{volume}", slider(range: 0.0..1.0, value: config_value, fill: true))
instance_variable_get(:"@volume_#{volume}").subscribe(:changed) do |_sender, value|
instance_variable_get(:"@volume_#{volume}_label").value = format("%03.2f%%", value * 100.0)
window.config[:options, :audio, :"volume_#{volume}"] = value
end
flow(width: 0.5) do
instance_variable_set(:"@volume_#{volume}", slider(range: 0.0..1.0, value: config_value, width: 1.0))
instance_variable_get(:"@volume_#{volume}").subscribe(:changed) do |_sender, value|
instance_variable_get(:"@volume_#{volume}_label").value = format("%03.2f%%", value * 100.0)
window.config[:options, :audio, :"volume_#{volume}"] = value
end
end
flow(width: 0.25) do
instance_variable_set(:"@volume_#{volume}_label", label(format("%03.2f%%", config_value * 100.0)))
end
instance_variable_set(:"@volume_#{volume}_label", label(format("%03.2f%%", config_value * 100.0), width: 96, text_align: :right))
end
end
end
@@ -167,16 +166,16 @@ class IMICFPS
label "Controls", text_size: 50
InputMapper.keymap.each do |key, values|
flow do
label key.to_s
flow(width: 1.0, height: 64) do
label key.to_s, width: 0.5, max_width: 312
[values].flatten.each do |value|
if name = Gosu.button_name(value)
else
unless (name = Gosu.button_name(value))
name = Gosu.constants.find { |const| Gosu.const_get(const) == value }
name = name.to_s.capitalize.split("_").join(" ") if name
end
button name
button name, fill: true
end
end
end
@@ -185,61 +184,55 @@ class IMICFPS
def page_graphics
label "Graphics", text_size: 50
longest_string = "Surface Effect Detail"
check_box "V-Sync (Not Disableable, Yet.)", checked: true, enabled: false, width: 1.0
flow do
check_box "V-Sync (Not Disableable, Yet.)", checked: true, enabled: false
end
flow do
label "Field of View".ljust(longest_string.length, " ")
@fov = slider range: 70.0..110.0
flow(width: 1.0, height: 64) do
label "Field of View", width: 128
@fov = slider range: 70.0..110.0, fill: true
@fov.subscribe(:changed) do |_sender, value|
@fov_label.value = value.round.to_s
end
@fov_label = label "90.0"
end
flow do
label "Detail".ljust(longest_string.length, " ")
list_box items: %i[high medium low], width: 250
flow(width: 1.0, height: 64) do
label "Detail", width: 128
list_box items: %i[high medium low], fill: true
end
label ""
advanced_mode = check_box "Advanced Settings"
label ""
advanced_mode = check_box "Advanced Settings", margin_top: 20, margin_bottom: 20
advanced_settings = stack width: 1.0 do |element|
advanced_settings = stack(width: 1.0) do |element|
element.hide
stack do
flow do
label "Geometry Detail".ljust(longest_string.length, " ")
list_box items: %i[high medium low], width: 250
stack(width: 1.0, height: 64 * 7) do
flow(width: 1.0, height: 64) do
label "Geometry Detail", width: 312
list_box items: %i[high medium low], fill: true
end
flow do
label "Shadow Detail".ljust(longest_string.length, " ")
list_box items: %i[high medium low off], width: 250
flow(width: 1.0, height: 64) do
label "Shadow Detail", width: 312
list_box items: %i[high medium low off], fill: true
end
flow do
label "Texture Detail".ljust(longest_string.length, " ")
list_box items: %i[high medium low], width: 250
flow(width: 1.0, height: 64) do
label "Texture Detail", width: 312
list_box items: %i[high medium low], fill: true
end
flow do
label "Particle Detail".ljust(longest_string.length, " ")
list_box items: %i[high medium low off], width: 250
flow(width: 1.0, height: 64) do
label "Particle Detail", width: 312
list_box items: %i[high medium low off], fill: true
end
flow do
label "Surface Effect Detail".ljust(longest_string.length, " ")
list_box items: %i[high medium low], width: 250
flow(width: 1.0, height: 64) do
label "Surface Effect Detail", width: 312
list_box items: %i[high medium low], fill: true
end
flow do
label "Lighting Mode".ljust(longest_string.length, " ")
list_box items: %i[per_pixel per_vertex], width: 250
flow(width: 1.0, height: 64) do
label "Lighting Mode", width: 312
list_box items: %i[per_pixel per_vertex], fill: true
end
flow do
label "Texture Filtering".ljust(longest_string.length, " ")
list_box items: [:none], width: 250
flow(width: 1.0, height: 64) do
label "Texture Filtering", width: 312
list_box items: [:none], fill: true
end
end
end
@@ -253,10 +246,11 @@ class IMICFPS
def page_multiplayer
label "Multiplayer", text_size: 50
flow do
label "Player Name"
edit_line "player-#{SecureRandom.hex(2)}"
flow(width: 1.0, height: 64) do
label "Player Name", width: 172
edit_line "player-#{SecureRandom.hex(2)}", fill: true
end
check_box "Show player names"
end
end

View File

@@ -27,7 +27,6 @@ class IMICFPS
SettingsMenu.set_defaults
@renderer = Renderer.new
preload_default_shaders
@scene = TurnTableScene.new
@overlay = Overlay.new
@@ -42,18 +41,6 @@ class IMICFPS
@delta_time = Gosu.milliseconds
end
def preload_default_shaders
shaders = %w[g_buffer lighting]
shaders.each do |shader|
Shader.new(
name: shader,
includes_dir: "shaders/include",
vertex: "shaders/vertex/#{shader}.glsl",
fragment: "shaders/fragment/#{shader}.glsl"
)
end
end
def input_hijack=(hijacker)
@input_hijacker = hijacker

View File

@@ -1,30 +0,0 @@
# version 330 core
layout(location = 0) out vec3 fragPosition;
layout (location = 1) out vec4 fragColor;
layout (location = 2) out vec3 fragNormal;
layout (location = 3) out vec3 fragUV;
in vec3 outPosition, outColor, outNormal, outUV, outFragPos, outCameraPos;
out vec4 outputFragColor;
flat in int outHasTexture;
uniform sampler2D diffuse_texture;
void main() {
vec3 result;
if (outHasTexture == 0) {
result = outColor;
} else {
result = texture(diffuse_texture, outUV.xy).xyz + 0.25;
}
fragPosition = outPosition;
fragColor = vec4(result, 1.0);
fragNormal = outNormal;
fragUV = outUV;
float gamma = 2.2;
outputFragColor.rgb = pow(fragColor.rgb, vec3(1.0 / gamma));
}

View File

@@ -1,63 +0,0 @@
#version 330 core
out vec4 FragColor;
@include "light_struct"
const int DIRECTIONAL = 0;
const int POINT = 1;
const int SPOT = 2;
in vec2 outTexCoords;
flat in Light outLight[1];
uniform sampler2D diffuse, position, texcoord, normal, depth;
vec4 directionalLight(Light light) {
vec3 norm = normalize(texture(normal, outTexCoords).rgb);
vec3 diffuse_color = texture(diffuse, outTexCoords).rgb;
vec3 fragPos = texture(position, outTexCoords).rgb;
vec3 lightDir = normalize(light.position - fragPos);
float diff = max(dot(norm, lightDir), 0);
vec3 _ambient = light.ambient;
vec3 _diffuse = light.diffuse * diff;
vec3 _specular = light.specular;
return vec4(_diffuse + _ambient + _specular, 1.0);
}
vec4 pointLight(Light light) {
return vec4(0.25, 0.25, 0.25, 1);
}
vec4 spotLight(Light light) {
return vec4(0.5, 0.5, 0.5, 1);
}
vec4 calculateLighting(Light light) {
vec4 result;
// switch(light.type) {
// case DIRECTIONAL: {
// result = directionalLight(light);
// }
// case SPOT: {
// result = spotLight(light);
// }
// default: {
// result = pointLight(light);
// }
// }
if (light.type == DIRECTIONAL) {
result = directionalLight(light);
} else {
result = pointLight(light);
}
return result;
}
void main() {
FragColor = texture(diffuse, outTexCoords) * calculateLighting(outLight[0]);
}

View File

@@ -1,11 +0,0 @@
struct Light {
int type;
vec3 direction;
vec3 position;
vec3 diffuse;
vec3 ambient;
vec3 specular;
float intensity;
};

View File

@@ -1,28 +0,0 @@
# version 330 core
layout(location = 0) in vec3 inPosition;
layout(location = 1) in vec3 inColor;
layout(location = 2) in vec3 inNormal;
layout(location = 3) in vec3 inUV;
uniform mat4 projection, view, model;
uniform int hasTexture;
uniform vec3 cameraPos;
out vec3 outPosition, outColor, outNormal, outUV;
out vec3 outFragPos, outViewPos, outCameraPos;
flat out int outHasTexture;
void main() {
// projection * view * model * position
outPosition = inPosition;
outColor = inColor;
outNormal= normalize(transpose(inverse(mat3(model))) * inNormal);
outUV = inUV;
outHasTexture = hasTexture;
outCameraPos = cameraPos;
outFragPos = vec3(model * vec4(inPosition, 1.0));
gl_Position = projection * view * model * vec4(inPosition, 1.0);
}

View File

@@ -1,17 +0,0 @@
#version 330 core
@include "light_struct"
layout (location = 0) in vec3 inPosition;
layout (location = 1) in vec2 inTexCoords;
uniform sampler2D diffuse, position, texcoord, normal, depth;
uniform Light light[1];
out vec2 outTexCoords;
flat out Light outLight[1];
void main() {
gl_Position = vec4(inPosition.x, inPosition.y, inPosition.z, 1.0);
outTexCoords = inTexCoords;
outLight = light;
}