Accommodate sombrero unified shader and driver changes (#54)

* Unify FX and GLSL shader, working for both Breezy Vulkan and GNOME
This commit is contained in:
Wayne Heaney 2024-09-09 20:43:59 -07:00 committed by GitHub
parent 88ff0af4a9
commit 9e084ad7a4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 24 additions and 25 deletions

View File

@ -41,8 +41,8 @@ cp $VKBASALT_BUILD_DIR/builddir/src/libvkbasalt.so $PACKAGE_DIR/vkBasalt.64/
cp $VKBASALT_BUILD_DIR/builddir/config/vkBasalt.json $PACKAGE_DIR/vkBasalt.64/
cp $VKBASALT_BUILD_DIR/builddir.32/src/libvkbasalt.so $PACKAGE_DIR/vkBasalt.32/
# copy Sombrero FX, get ReShade headers
cp modules/sombrero/*.fx $PACKAGE_DIR
# copy Sombrero shader, get ReShade headers
cp modules/sombrero/*.frag $PACKAGE_DIR
cp modules/sombrero/*.png $PACKAGE_DIR
wget -P $PACKAGE_DIR https://raw.githubusercontent.com/crosire/reshade-shaders/384465d0287999caa6190b5ebea506200b4f4a0a/Shaders/ReShade.fxh
wget -P $PACKAGE_DIR https://raw.githubusercontent.com/crosire/reshade-shaders/384465d0287999caa6190b5ebea506200b4f4a0a/Shaders/ReShadeUI.fxh
@ -93,7 +93,7 @@ cp $XR_DRIVER_DIR/bin/xr_driver_setup $PACKAGE_DIR/bin
# include any file that doesn't get modified during setup (e.g. vkBasalt.json files)
pushd $PACKAGE_DIR
echo $XR_DRIVER_MANIFEST_LINE > manifest
sha256sum bin/breezy_vulkan_uninstall vkBasalt.64/libvkbasalt.so vkBasalt.32/libvkbasalt.so *.fx* *.png >> manifest
sha256sum bin/breezy_vulkan_uninstall vkBasalt.64/libvkbasalt.so vkBasalt.32/libvkbasalt.so *.frag *.fx* *.png >> manifest
popd
# bundle everything up

View File

@ -1 +0,0 @@
../../modules/sombrero/IMUAdjust.frag

1
gnome/src/Sombrero.frag Symbolic link
View File

@ -0,0 +1 @@
../../modules/sombrero/Sombrero.frag

View File

@ -52,8 +52,7 @@ const shaderUniformLocations = {
'imu_quat_data': null,
'look_ahead_cfg': null,
'look_ahead_ms': null,
'trim_width_percent': null,
'trim_height_percent': null,
'trim_percent': null,
'display_size': null,
'display_north_offset': null,
'lens_vector': null,
@ -141,9 +140,12 @@ function setIntermittentUniformVariables() {
const halfFovYRads = halfFovZRads * displayAspectRatio;
const fovHalfWidths = [Math.tan(halfFovYRads), Math.tan(halfFovZRads)];
const fovWidths = [fovHalfWidths[0] * 2, fovHalfWidths[1] * 2];
const lensDistanceRatio = dataViewFloat(dataView, LENS_DISTANCE_RATIO);
let lensFromCenter = 0.0;
let texcoordXLimits = [0.0, 1.0];
let texcoordXLimitsRight = [0.0, 1.0];
if (sbsEnabled) {
lensFromCenter = lensDistanceRatio / 3.0;
if (sbsContent) {
texcoordXLimits[1] = 0.5;
texcoordXLimitsRight[0] = 0.5;
@ -154,10 +156,10 @@ function setIntermittentUniformVariables() {
} else if (!sbsModeStretched) {
texcoordXLimits[0] = 0.25;
texcoordXLimits[1] = 0.75;
texcoordXLimitsRight[0] = 0.25;
texcoordXLimitsRight[1] = 0.75;
}
}
const lensDistanceRatio = dataViewFloat(dataView, LENS_DISTANCE_RATIO);
const lensFromCenter = lensDistanceRatio / 3.0;
const lensVector = [lensDistanceRatio, lensFromCenter, 0.0];
const lensVectorRight = [lensDistanceRatio, -lensFromCenter, 0.0];
@ -171,8 +173,7 @@ function setIntermittentUniformVariables() {
transferUniformFloat(this, 'lens_distance_ratio', dataView, LENS_DISTANCE_RATIO);
// computed values with no dataViewInfo, so we set these manually
setSingleFloat(this, 'trim_width_percent', trimWidthPercent);
setSingleFloat(this, 'trim_height_percent', trimHeightPercent);
this.set_uniform_float(shaderUniformLocations['trim_percent'], 2, [trimWidthPercent, trimHeightPercent]);
setSingleFloat(this, 'half_fov_z_rads', halfFovZRads);
setSingleFloat(this, 'half_fov_y_rads', halfFovYRads);
this.set_uniform_float(shaderUniformLocations['fov_half_widths'], 2, fovHalfWidths);
@ -191,7 +192,7 @@ function setIntermittentUniformVariables() {
if (enabled && this.widescreen_mode_state !== sbsEnabled) this.widescreen_mode_state = sbsEnabled;
// these variables are always in play, even if enabled is false
setSingleFloat(this, 'enabled', enabled ? 1.0 : 0.0);
setSingleFloat(this, 'virtual_display_enabled', enabled ? 1.0 : 0.0);
setSingleFloat(this, 'show_banner', imuResetState ? 1.0 : 0.0);
setSingleFloat(this, 'sbs_enabled', sbsEnabled ? 1.0 : 0.0);
setSingleFloat(this, 'custom_banner_enabled', dataViewUint8(dataView, CUSTOM_BANNER_ENABLED) !== 0 ? 1.0 : 0.0);
@ -345,8 +346,8 @@ export const XREffect = GObject.registerClass({
}
vfunc_build_pipeline() {
const code = getShaderSource(`${Globals.extension_dir}/IMUAdjust.frag`);
const main = 'PS_IMU_Transform(vec4(0, 0, 0, 0), cogl_tex_coord_in[0].xy, cogl_color_out);';
const code = getShaderSource(`${Globals.extension_dir}/Sombrero.frag`);
const main = 'PS_Sombrero(true, false, source_to_display_ratio, show_banner, cogl_tex_coord_in[0].xy, cogl_color_out);';
this.add_glsl_snippet(Shell.SnippetHook.FRAGMENT, code, main, false);
}
@ -358,12 +359,12 @@ export const XREffect = GObject.registerClass({
let buffer = new Uint8Array(data[1]).buffer;
this._dataView = new DataView(buffer);
if (!this._initialized) {
this.set_uniform_float(this.get_uniform_location('uDesktopTexture'), 1, [0]);
this.set_uniform_float(this.get_uniform_location('screenTexture'), 1, [0]);
this.get_pipeline().set_layer_texture(1, calibratingImage.get_texture());
this.get_pipeline().set_layer_texture(2, customBannerImage.get_texture());
this.get_pipeline().set_uniform_1i(this.get_uniform_location('uCalibratingTexture'), 1);
this.get_pipeline().set_uniform_1i(this.get_uniform_location('uCustomBannerTexture'), 2);
this.get_pipeline().set_uniform_1i(this.get_uniform_location('calibratingTexture'), 1);
this.get_pipeline().set_uniform_1i(this.get_uniform_location('customBannerTexture'), 2);
for (let key in shaderUniformLocations) {
shaderUniformLocations[key] = this.get_uniform_location(key);

@ -1 +1 @@
Subproject commit 920ef8967d328e80d9c5020a798f0f7afad97903
Subproject commit d7415dc00a29afb5db844fd5867de4f0cc09d85d

@ -1 +1 @@
Subproject commit ec3f82aa4834847adf1f0c640eba4b87b6f3ff65
Subproject commit 46b99881e066fdc8a90b36dd9f83cc9894ecffa0

View File

@ -8,10 +8,9 @@ file_paths=(
["bin/breezy_vulkan_uninstall"]="{bin_dir}/breezy_vulkan_uninstall"
["vkBasalt.64/libvkbasalt.so"]="{lib_dir}/libvkbasalt.so"
["vkBasalt.32/libvkbasalt.so"]="{lib32_dir}/libvkbasalt.so"
["IMUAdjust.fx"]="{reshade_config_dir}/Shaders/IMUAdjust.fx"
["Sombrero.frag"]="{reshade_config_dir}/Shaders/Sombrero.frag"
["ReShade.fxh"]="{reshade_config_dir}/Shaders/ReShade.fxh"
["ReShadeUI.fxh"]="{reshade_config_dir}/Shaders/ReShadeUI.fxh"
["Sideview.fx"]="{reshade_config_dir}/Shaders/Sideview.fx"
["calibrating.png"]="{reshade_config_dir}/Textures/calibrating.png"
["custom_banner.png"]="{reshade_config_dir}/Textures/custom_banner.png"
["xr_driver/manifest"]="{xr_driver_data_dir}/manifest"

View File

@ -124,11 +124,11 @@ fi
# copy the vkBasalt.conf file and make replacements
sed -e "s|/path/to/reshade-shaders|${RESHADE_CONFIG_DIR}|" \
-e "s|/path/to/virtual_display|${RESHADE_CONFIG_DIR}/Shaders/IMUAdjust.fx|" \
-e "s|/path/to/sideview|${RESHADE_CONFIG_DIR}/Shaders/Sideview.fx|" \
-e "s|/path/to/sombrero|${RESHADE_CONFIG_DIR}/Shaders/Sombrero.frag|" \
config/vkBasalt.conf > $VKBASALT_CONFIG_DIR/vkBasalt.conf
echo "Installing the Sombrero shaders and texture files to ${RESHADE_CONFIG_DIR}/{Shaders,Textures}"
cp *.frag $RESHADE_CONFIG_DIR/Shaders
cp *.fx* $RESHADE_CONFIG_DIR/Shaders
cp *.png $RESHADE_CONFIG_DIR/Textures

View File

@ -1,7 +1,6 @@
effects = sideview:virtual_display
effects = sombrero
virtual_display = /path/to/virtual_display
sideview = /path/to/sideview
sombrero = /path/to/sombrero
reshadeTexturePath = "/path/to/reshade-shaders/Textures"
reshadeIncludePath = "/path/to/reshade-shaders/Shaders"
depthCapture = off