Skip to content

Instantly share code, notes, and snippets.

@tuket
Last active February 25, 2026 14:37
Show Gist options
  • Select an option

  • Save tuket/476240d5f048d7fa816d036fa388f36d to your computer and use it in GitHub Desktop.

Select an option

Save tuket/476240d5f048d7fa816d036fa388f36d to your computer and use it in GitHub Desktop.
Reverse the DepthFunctions of all RenderLayers of an Evergine project
# This script reverses all the RenderLayer's DepthFunctions of an Evergine project
import argparse
import sys
from pathlib import Path
def main():
parser = argparse.ArgumentParser(
description='This script will reverse the DepthFunction of all the RenderLayers in you Evergine project.',
formatter_class=argparse.RawDescriptionHelpFormatter,
epilog="""
Example:
python3 reverse_RenderLayer_DepthFunctions.py "C:\\path\\to\\my project.weproj"
"""
)
parser.add_argument(
'weproj_file',
help='Path to the .weproj file to process'
)
args = parser.parse_args()
weproj_path = Path(args.weproj_file)
validate_weproj_file(weproj_path)
folder_path = weproj_path.parent
visit_files_recursively(folder_path, ext='.werl', process_fn=process_render_layer_file)
def process_render_layer_file(file_path):
modified = False
txt = ""
with open(file_path, 'r+', encoding='utf-8') as f:
lines = f.readlines()
for line in lines:
if "DepthFunction" in line:
if "Greater" in line:
line = line.replace("Greater", "Less")
modified = True
elif "Less" in line:
line = line.replace("Less", "Greater")
modified = True
txt += line
if modified:
with open(file_path, "w") as f:
print(f"Fixed '{file_path}'")
f.write(txt)
def validate_weproj_file(path):
if not path.exists():
print(f"Error: File '{path}' does not exist.")
sys.exit(1)
if not path.is_file():
print(f"Error: '{path}' is not a file.")
sys.exit(1)
if path.suffix.lower() != '.weproj':
print(f"Error: '{path}' is not a .weproj file.")
sys.exit(1)
def is_bin_or_obj_folder(path):
return path.is_dir() and (path.name == 'bin' or path.name == 'obj')
def visit_files_recursively(folder_path, ext, process_fn):
try:
for item in folder_path.iterdir():
if item.name.startswith('.') or is_bin_or_obj_folder(item):
continue
if item.is_file() and item.suffix.lower() == ext:
process_fn(item)
elif item.is_dir():
visit_files_recursively(item, ext, process_fn)
except PermissionError as e:
print(f"Permission denied accessing '{folder_path}': {e}")
except Exception as e:
print(f"Error accessing '{folder_path}': {e}")
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment