Skip to content

Commit

Permalink
Merge pull request #21 from devendrn/laz
Browse files Browse the repository at this point in the history
Migrate to lazurite
  • Loading branch information
devendrn authored Jun 26, 2024
2 parents 5fea25f + fe079e7 commit ab5ede7
Show file tree
Hide file tree
Showing 142 changed files with 919 additions and 564 deletions.
2 changes: 1 addition & 1 deletion .clangd
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
If:
PathMatch: include/newb/functions/.*
PathMatch: src/newb/functions/.*

CompileFlags:
Add: [--include=../config.h, --include=../../../.lsp/bgfx.h]
Expand Down
93 changes: 64 additions & 29 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,62 +1,97 @@
name: build

on:
push:
branches:
- main
- devel
workflow_dispatch:
inputs:
subversion:
description: 'Sub-version (eg: 46)'
required: true
type: string

jobs:
windows:
runs-on: windows-2019
runs-on: windows-2022
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/cache@v4
with:
key: env-files-win
key: env-files-win-laz
path: |
${{ github.workspace }}/env
${{ github.workspace }}/data
- run: .\setup.bat
- run: ./pack.sh -w -p Windows
shell: bash
${{ github.workspace }}/tool/data
- uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: 'pip'
- run: pip install -r requirements.txt
- run: |
.\build.bat setup
.\build.bat pack -p windows -v ${{ inputs.subversion }} --no-zip
- uses: actions/upload-artifact@v4
with:
name: newb-x-windows
path: ./build/Windows/temp
path: ./build/pack-windows
android:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/cache@v4
with:
key: env-files-linux
key: env-files-linux-laz
path: |
${{ github.workspace }}/env
${{ github.workspace }}/data
- run: ./setup.sh
- run: ./pack.sh
${{ github.workspace }}/tool/data
- uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: 'pip'
- run: pip install -r requirements.txt
- run: |
./build.sh setup
./build.sh pack -p android -v ${{ inputs.subversion }} --no-zip
- uses: actions/upload-artifact@v4
with:
name: newb-x-android
path: ./build/Android/temp
path: ./build/pack-android
ios:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/cache@v4
with:
key: env-files-linux
key: env-files-linux-laz
path: |
${{ github.workspace }}/env
${{ github.workspace }}/data
- run: ./setup.sh
- run: ./build.sh -p iOS
${{ github.workspace }}/tool/data
- uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: 'pip'
- run: pip install -r requirements.txt
- run: |
./build.sh setup
./build.sh pack -p ios -v ${{ inputs.subversion }} --no-zip
- uses: actions/upload-artifact@v4
with:
name: newb-x-ios
path: ./build/pack-ios
merged:
runs-on: windows-2022
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
key: env-files-win-laz
path: |
${{ github.workspace }}/tool/data
- uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: 'pip'
- run: pip install -r requirements.txt
- run: |
.\build.bat setup
.\build.bat pack -p merged -v ${{ inputs.subversion }} --no-zip
- uses: actions/upload-artifact@v4
with:
name: newb-x-ios-materials
path: ./build/iOS
name: newb-x-merged
path: ./build/pack-merged
9 changes: 7 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
# ingnore dirs
build/
data/
env/
.bak/
tool/data/
tool/lib/
tool/__pycache__/
.venv
venv

# ignore files
copy.sh
*.bin
*.py[cod]

# eol
* text=lf
1 change: 1 addition & 0 deletions .lsp/bgfx.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ typedef struct mat2 {
EMPTY_STRUCT(sampler2D)

vec4 texture2D(sampler2D, vec2);
vec4 texture2DLod(sampler2D, vec2, float);

VEC_OPS(vec2)
VEC_OPS(vec3)
Expand Down
71 changes: 44 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Newb X Legacy

**Newb X Legacy** is a RenderDragon successor to the legacy GLSL shader, [Newb Shader](https://github.com/devendrn/newb-shader-mcbe). It is an enhanced vanilla shader that focuses on being lightweight and having soft aesthetics. It supports Minecraft Bedrock 1.20 (Windows/Android/*iOS).
**Newb X Legacy** is a RenderDragon successor to the legacy GLSL shader, [Newb Shader](https://github.com/devendrn/newb-shader-mcbe). It is an enhanced vanilla shader that focuses on being lightweight and having soft aesthetics. It supports Minecraft Bedrock 1.21 (Windows/Android/*iOS).

> [!WARNING]
> This is an experimental repository, breaking changes are made often.
Expand All @@ -17,7 +17,7 @@ Nightly builds for Android (ESSL) and Windows (DX) can be found at the [Discord
> Shaders are not officially supported on Minecraft Bedrock. The following are unofficial ways to load shaders.
**Linux:** [mcpelauncher-manifest](https://github.com/minecraft-linux/mcpelauncher-ui-manifest)
1. Extract material.bin files from shader mcpack / build materials manually
1. Extract material.bin files from shader mcpack / build materials from source.
2. Move these files to data root `mcpelauncher/versions/1.20.x/assets/renderer/materials/`. (Make sure to backup all files in this folder first)
3. Import the resource pack and activate it in global resources.

Expand All @@ -31,44 +31,61 @@ Nightly builds for Android (ESSL) and Windows (DX) can be found at the [Discord

## Building

**Windows:**
1. Setup build environment: `.\setup.bat`
2. Compile material src files: `.\build.bat`

**Linux:**
1. Setup build environment: `./setup.sh`
2. Compile material src files: `./build.sh`
### Install dependencies
- [Git](https://git-scm.com/)
- [Python](https://www.python.org/) 3.11 or higher required
- Python packages [lazurite](https://veka0.github.io/lazurite/#installation) and [rich](https://rich.readthedocs.io/en/stable/introduction.html#installation)

**Available parameters for the build script:**
| Option | Parameter description |
| :-: | :- |
| -p | Target platforms (Android, Windows, iOS, Merged) |
| -m | Materials to compile (if unspecified, builds all material files) |
| -t | Number of threads to use for compilation (default is CPU core count) |
### Get source code
```
git clone https://github.com/devendrn/newb-x-mcbe/
cd newb-x-mcbe
```

For example, to build only terrain for Android and Windows, use:
### Setup build environment
> [!NOTE]
> On Windows, you should use `.\build.bat` instead of `./build.sh` for all following commands.
```
.\build.bat -p Windows Android -m RenderChunk
./build.sh setup
```
Compiled material.bin files will be inside `build/<platform>/`
This will download shaderc binary and material data required to build shader.

### Pack
To build the final pack, including all subpacks, use `pack.sh`. If you are on Windows, use a bash shell like Git Bash to run this script file. (Make sure to use the -w tag when you are running the script from a Windows machine) 
### Compile specific shader materials
```
./build.sh mats
```
Compiled material.bin files will be inside `build/<platform>/`
**Command usage:**
```
usage: build mats [-h] [-p {android,windows,merged,ios}] [-m M [M ...]] [-s S]
options:
-h, --help show this help message and exit
-p {android,windows,ios}
build profile
-m M [M ...] build materials (eg: RenderChunk)
-s S subpack config to use (eg: ROUNDED_CLOUDS)
```

**Linux:**
### Compile and build full shader pack
```
./pack.sh -v 15.0
./build.sh pack
```
**Windows:**
The final mcpack will be inside `build/`
**Command usage:**
```
./pack.sh -w -v 15.0 -p Windows
./pack.sh -w -v 15.0 -p Android
usage: build pack [-h] [-p {android,windows,merged,ios}] [--no-zip] [-v V]
options:
-h, --help show this help message and exit
-p {android,windows,ios}
build profile
--no-zip don't make archive
-v V version number eg: 46
```
The final pack files will be inside `build/<platform>/temp/`

## Development

Clangd can be used to get code completion and error checks for source files inside include/newb. Fake bgfx header and clangd config are provided for the same.
- **Neovim** (NvChad): Install clangd LSP from Mason.
- **VSCode**: Install [vscode-clangd](https://marketplace.visualstudio.com/items?itemName=llvm-vs-code-extensions.vscode-clangd) extension.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
69 changes: 1 addition & 68 deletions build.bat
Original file line number Diff line number Diff line change
@@ -1,70 +1,3 @@
@echo off

set MBT=env\bin\MaterialBinTool-0.8.2-native-image.exe
set SHADERC=env\bin\shaderc.exe

set MBT_ARGS=--compile --shaderc %SHADERC% --include include/

set DATA_VER=1.20.0
set DATA_DIR=data/%DATA_VER%
set BUILD_DIR=build
set MATERIALS_DIR=materials

set MATERIALS=
set TARGETS=
set ARG_MODE=
:loop_args
if "%1" == "" goto :end_args
if "%1" == "-p" goto :set_arg
if "%1" == "-t" goto :set_arg
if "%1" == "-m" goto :set_arg

if "%ARG_MODE%" == "" (
goto :next_arg
)
if "%ARG_MODE%" == "-p" (
set TARGETS=%TARGETS% %1
goto :next_arg
)
if "%ARG_MODE%" == "-m" (
set MATERIALS=%MATERIALS% %MATERIALS_DIR%\%1
goto :next_arg
)
if "%ARG_MODE%" == "-t" (
set THREADS=%1
goto :next_arg
)
:set_arg
set ARG_MODE=%1
:next_arg
shift
goto :loop_args
:end_args

if "%TARGETS%" == "" (
set TARGETS=Windows
)

if "%MATERIALS%" == "" (
set MATERIALS=%MATERIALS_DIR%\*
)

if "%THREADS%" == "" (
set THREADS=%NUMBER_OF_PROCESSORS%
)

set MBT_ARGS=%MBT_ARGS% --threads %THREADS%

for %%f in (%MBT%) do echo %%~nxf
for %%p in (%TARGETS%) do (
echo ---------------------------
echo ^>^> Building materials - %%p %DATA_VER%:
if exist %DATA_DIR%\%%p (
for /d %%s in (%MATERIALS%) do (
echo - %%s
%MBT% %MBT_ARGS% --output %BUILD_DIR%\%%p --data %DATA_DIR%\%%p\%%~nxs %%s
)
) else (
echo Error: %DATA%\%%p not found
)
)
python tool %*
Loading

0 comments on commit ab5ede7

Please sign in to comment.