Skip to content

Instantly share code, notes, and snippets.

View AMZN-alexpete's full-sized avatar

Alex Peterson AMZN-alexpete

View GitHub Profile
@AMZN-alexpete
AMZN-alexpete / gist:a88892c25f82ee832a2b54ae2ed49bcf
Created September 4, 2020 23:26
Timing Git LFS operations
# turn off automatic lfs cloning
set GIT_LFS_SKIP_SMUDGE=1
# time cloning the repo without pulling LFS files
powershell -Command "Measure-Command {git clone https://example.com/repos/Lumberyard}"
# time pulling LFS files
cd Lumberyard
powershell -Command "Measure-Command {git lfs pull}"
@AMZN-alexpete
AMZN-alexpete / c.bat
Last active May 23, 2022 17:50
O3DE configure .bat file for use inside engine or project folder
@echo off
setlocal ENABLEDELAYEDEXPANSION
rem IMPORTANT, make sure this 3rdparty path is correct
set CMAKE_PARAMS=-DLY_3RDPARTY_PATH="f:/git/3rdparty" -DLY_RENDERDOC_ENABLED=ON -DLY_PIX_ENABLED=ON
rem find latest VS version available
pushd "c:\Program Files (x86)\Microsoft Visual Studio\Installer"
for /f "usebackq tokens=*" %%i in (`call "vswhere.exe" -latest -format value -property catalog_productLineVersion`) do (
set Params=%*
@AMZN-alexpete
AMZN-alexpete / b.bat
Last active August 31, 2022 22:10
Batch script for building an O3DE project or engine using common settings.
@echo off
setlocal ENABLEDELAYEDEXPANSION
rem find latest VS version available
pushd "c:\Program Files (x86)\Microsoft Visual Studio\Installer"
for /f "usebackq tokens=*" %%i in (`call "vswhere.exe" -latest -format value -property catalog_productLineVersion`) do (
set Params=%*
for /f "tokens=1*" %%a in ("!%%i!") do EndLocal & set %1=%%b
set VSVERSIONYEAR=%%i
)
@AMZN-alexpete
AMZN-alexpete / ThinLineRendering.md
Created April 6, 2022 20:50
Thin line rendering ala Avalanche

From https://www.humus.name/Articles/Persson_GraphicsGemsForGames.pdf Phone-wire AA Siggraph 2012 presentation, Emil Persson, Avalanche Studios

  • Phone wires are long cylinder shapes, define center points, normal and radius
  • Avoid going sub-pixel by clamping radius to half-pixel size, then fade with radius reduction ratio to simulate sub-pixel coverage.
  • Also useful for railings, bars, antenna towers etc.
  • Still need to apply MSAA or other AA solution on top to smooth jaggies
// compute view-space w
float w = dot(viewproj[3], float4(In.Position.xyz, 1.0f));
@AMZN-alexpete
AMZN-alexpete / GitRepoSetup.md
Created April 6, 2022 21:05
Typical Git (O3DE) Setup

Typical GitHub repository setup consists of at least two repositories, the upstream and the fork. Sometimes a third personal repository can also be useful. Here's how I typically name and setup my Git remote repositories:

  1. Clone the origin repository which is usually a fork where a team does work before merging it into the main upstream repository
λ git clone https://github.com/aws-lumberyard-dev/o3de.git
λ cd o3de
@AMZN-alexpete
AMZN-alexpete / v.bat
Last active November 21, 2023 17:29
Open O3DE visual studio solution from command line
@echo off
setlocal enabledelayedexpansion
REM open first .sln file in build/windows_vs2022 with VS 2022
for %%A in (build/windows_vs2022/*.sln) do (
powershell -Command "Start-Process -FilePath 'C:\Program Files\Microsoft Visual Studio\2022\Professional\Common7\IDE\devenv.exe' -ArgumentList '%CD%\build\windows_vs2022\%%A'"
GOTO finished
)
REM fall back to first .sln file in build/windows_vs2019 with VS 2019
@AMZN-alexpete
AMZN-alexpete / c.sh
Last active November 8, 2022 19:15
c.sh
#! /bin/bash
if [ -f "engine.json" ]; then
echo cmake -B build/linux -S. -G "Ninja Multi-Config" -DLY_PROJECTS=AutomatedTesting -DLY_3RDPARTY_PATH=$HOME/o3de-packages
time cmake -B build/linux -S. -G "Ninja Multi-Config" -DLY_PROJECTS=AutomatedTesting -DLY_3RDPARTY_PATH=$HOME/o3de-packages
else
echo cmake -B build/linux -S. -G "Ninja Multi-Config" -DLY_3RDPARTY_PATH=$HOME/o3de-packages
time cmake -B build/linux -S. -G "Ninja Multi-Config" -DLY_3RDPARTY_PATH=$HOME/o3de-packages
fi
@AMZN-alexpete
AMZN-alexpete / b.sh
Last active November 8, 2022 19:32
b.sh
#! /bin/bash
if [ -f "engine.json" ]; then
echo cmake --build build/linux --target Editor AutomatedTesting.GameLauncher --config profile -j 8
time cmake --build build/linux --target Editor AutomatedTesting.GameLauncher --config profile -j 8
elif [ -f "project.json" ]; then
project=$(grep -oP '(?<="project_name": ")[^"]*' project.json)
echo "cmake --build build/linux --target Editor ${project}.GameLauncher --config profile -j 8"
time cmake --build build/linux --target Editor ${project}.GameLauncher --config profile -j 8
else
@AMZN-alexpete
AMZN-alexpete / ebus.cpp
Created March 21, 2023 23:18
EBus Event Lambda Syntax Example
// Example of using a Lambda to perform multiple actions on an event bus (ebus)
SystemCursorState state;
AzFramework::InputSystemCursorRequestBus::Event( AzFramework::InputDeviceMouse::Id,
[&](auto requests)
{
systemCursorState = requests->GetSystemCursorState();
requests->SetSystemCursorState(AzFramework::SystemCursorState::UnconstrainedAndVisible);
}
);
@AMZN-alexpete
AMZN-alexpete / binary_size_tools.md
Created April 10, 2023 17:46
Tools for Diagnosing LIB/DLL/EXE sizes