Skip to main content

ShaderBridge

Convert Unity ShaderLab/HLSL shaders to Godot 4.x GDShader — CLI, Python API, and Web UI.

PyPI version Python 3.8+ License: MIT


Features

  • Full ShaderLab parser — Properties, SubShaders, Passes, CGPROGRAM/HLSLPROGRAM
  • HLSL → GDShader translator — types, functions, matrices, time, lighting
  • Surface shader support — surf() → fragment() with PBR output mapping
  • Compatibility checker — scores shaders 0–100%, flags unsupported features
  • Rich CLI — convert, batch, validate, info, watch, serve, pipe
  • Python API — import and use in your own tools
  • Web UI — browser-based editor with live validation and 3D preview
  • AI conversion — optional Groq LLM fallback for complex shaders

Install

# Core CLI only (no web server)
pip install shaderbridge

# With web UI server
pip install "shaderbridge[web]"

# With file-watch mode
pip install "shaderbridge[watch]"

# Everything
pip install "shaderbridge[all]"

CLI Usage

Convert a single shader

shaderbridge convert MyShader.shader
shaderbridge convert MyShader.shader -o out/MyShader.gdshader
shaderbridge convert MyShader.shader --validate --verbose --show-output

Batch convert a directory

shaderbridge batch ./Assets/Shaders/ -o ./GodotProject/shaders/
shaderbridge batch ./Assets/ -o ./out/ --validate --fail-fast

Validate compatibility

shaderbridge validate MyShader.shader
shaderbridge validate MyShader.shader --json

Inspect shader metadata

shaderbridge info MyShader.shader

Watch mode (auto-convert on save)

pip install "shaderbridge[watch]"
shaderbridge watch ./Assets/Shaders/ -o ./GodotProject/shaders/

Launch web UI

pip install "shaderbridge[web]"
shaderbridge serve
shaderbridge serve --port 8080 --no-browser

Pipe / stdin mode (CI-friendly)

cat MyShader.shader | shaderbridge pipe > MyShader.gdshader
cat MyShader.shader | shaderbridge pipe --validate --json

JSON output for scripting

shaderbridge convert MyShader.shader --json
shaderbridge batch ./shaders/ --json | jq '.results[] | select(.success == false)'

Python API

from shader_converter.parser.unity_shader_parser import UnityShaderParser
from shader_converter.generator.godot_shader_generator import AdvancedGodotShaderGenerator
from shader_converter.validator.compatibility_checker import DetailedCompatibilityChecker

unity_code = open("MyShader.shader").read()

# Parse
parser = UnityShaderParser()
ast = parser.parse(unity_code)

# Validate
checker = DetailedCompatibilityChecker()
report = checker.check_compatibility(ast)
print(f"Compatibility: {report['compatibility_score'] * 100:.0f}%")

# Generate
generator = AdvancedGodotShaderGenerator()
result = generator.generate(ast)

if result["success"]:
    open("MyShader.gdshader", "w").write(result["code"])
    print(result["code"])

What Gets Converted

Unity / HLSL Godot 4.x
float4, half4, fixed4 vec4
float3x3, float4x4 mat3, mat4
tex2D(tex, uv) texture(tex, uv)
lerp(a, b, t) mix(a, b, t)
saturate(x) clamp(x, 0.0, 1.0)
frac(x) fract(x)
ddx / ddy dFdx / dFdy
clip(x) if (x < 0.0) discard;
UNITY_MATRIX_MVP MODELVIEWPROJECTION_MATRIX
unity_ObjectToWorld MODEL_MATRIX
_Time.y TIME
UnityObjectToClipPos(v) MODELVIEWPROJECTION_MATRIX * vec4(v, 1.0)
TRANSFORM_TEX(uv, tex) uv * tex_ST.xy + tex_ST.zw
o.Albedo = ALBEDO =
o.Metallic = METALLIC =
o.Smoothness = ROUGHNESS = 1.0 -
o.Emission = EMISSION =
o.Normal = NORMAL_MAP =

Unsupported Features

These Unity features have no direct Godot equivalent and will be flagged:

  • Geometry shaders (#pragma geometry)
  • Tessellation (#pragma hull / #pragma domain)
  • Compute shaders (#pragma kernel)
  • GrabPass (use Godot viewport textures instead)
  • Ray tracing (RayQuery, RayDesc)
  • UAV / RW resources

Web UI

shaderbridge serve
# Opens http://localhost:5000

Features:

  • Side-by-side Unity / Godot editor
  • Live compatibility validation
  • 3D WebGL preview (Three.js)
  • AI-powered conversion (requires GROQ_API_KEY)
  • Conversion history
  • Download / copy output

Environment Variables

Variable Description
GROQ_API_KEY Groq API key for AI-powered conversion (optional)

Create a .env file in the project root:

GROQ_API_KEY=your_key_here

Development

git clone https://github.com/Sreejith-nair511/SWC-Redux-2033
pip install -e ".[all]"
pytest tests/ -v

License

MIT — see LICENSE

Metadata

Release files for shaderbridge 1.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for shaderbridge 1.0.2
File Size Uploaded Provenance Actions
shaderbridge-1.0.2.tar.gz 41.3 kB Without provenance Details for shaderbridge-1.0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for shaderbridge 1.0.2
File Interpreter ABI Platform Actions
shaderbridge-1.0.2-py3-none-any.whl Python 3 none any Details for shaderbridge-1.0.2-py3-none-any.whl

Total release size: 79.6 kB

Release files / shaderbridge-1.0.2.tar.gz

Download URL shaderbridge-1.0.2.tar.gz
Size 41.3 kB
Tags Source
SHA-256 checksum
How to use checksums
ad824f159e9f6c5d4e2fe4207a14fa4e41030c2f34d645210ac927b603bcebd9
BLAKE2b-256 checksum
How to use checksums
64b1e6d22b8800d2ff81128f8e38ebae1aa5644ad2fa270665926cf35446329c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.1

Release files / shaderbridge-1.0.2-py3-none-any.whl

Download URL shaderbridge-1.0.2-py3-none-any.whl
Size 38.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
335ecad13ed01b38374932402e8f2c434f0f63dad79df4d0f4f7df7f17ccd3ff
BLAKE2b-256 checksum
How to use checksums
db51e9a39163f22ab546cb8c70dc0a072c32581172d614a031c8aafcaa0ff1d6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.1

Security for shaderbridge 1.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page