MojoShader

MojoShader是一个库,用于在替代3D API和非Windows平台上与Direct3D着色器协同工作。其主要目标是在多种渲染后端中动态移动着色器,并允许开发者管理一套直接3D HLSL编写的着色器,同时通过减少运行时字节码复杂性来处理程序复杂性。该库提供简单的API将字节码转换为各种配置文件,并提供基本的渲染API来抽象运行时的着色器管理。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

http://icculus.org/mojoshader/


MojoShader

September 24th, 2008: Source code released to the world!

MojoShader is a library to work with Direct3D shaders on alternate 3D APIs and non-Windows platforms. The primary motivation is moving shaders to OpenGL languages on the fly. The developer deals with "profiles" that represent various target languages, such as GLSL or ARB_*_program.

This allows a developer to manage one set of shaders, presumably written in Direct3D HLSL, and use them across multiple rendering backends. This also means that the developer only has to worry about one (offline) compiler to manage program complexity, while MojoShader itself deals with the reduced complexity of the bytecode at runtime.

MojoShader provides both a simple API to convert bytecode to various profiles, and (optionally) basic glue to rendering APIs to abstract the management of the shaders at runtime.

Work is in progress to allow MojoShader to work as a replacement stack for the D3DX shader tools. The library already provides a preprocessor and an assembler to generate bytecode from low-level source, and construction of a full HLSL compiler is in progress.

The library is meant to be statically linked to an application (just add a few .c files and headers to your build), allows the app to optionally specify an allocator, and is thread safe (although OpenGL itself is not). It is meant to be embedded in games with a minimum of fuss.

Places MojoShader can be found in use:

  • Unreal Tournament 3 uses MojoShader with its OpenGL renderer.
  • Killing Floor uses MojoShader for OpenGL motion blur and bloom effects.
  • Unity uses MojoShader's preprocessor on their HLSL code before passing it to Cg.
  • Super Meat Boy uses MojoShader for its Mac and Linux ports.
  • Shank uses MojoShader on Mac and Linux to support Effect Framework files.
  • This benchmark uses MojoShader's assembler to test the benefits of offline compiling of shaders.
  • Psychonauts uses MojoShader on Mac and Linux, flexing its support for Shader Model 1.
  • Vessel uses MojoShader on Mac OS X and Linux.
  • MonoGame uses MojoShader for some of their Direct3D support code.
  • Urho3D is a game engine that uses MojoShader behind the scenes.
  • Guncraft uses MojoShader through MonoGame.
  • FNA is an XNA-compatible framework that uses MojoShader to deal with shaders and D3D Effects.
  • Hive uses MojoShader through FNA.
  • Khet 2.0 uses MojoShader through FNA.
  • Reversi uses MojoShader through FNA.
  • If you know of other software using MojoShader, drop me a line.

What works:

  • Parsing of bytecode for Shader Model 1 through 3.
  • Assembler to build bytecode from low-level (not HLSL) shader source code.
  • Preprocessor for programs with #include, #define, #if, etc.
  • "d3d" profile (Direct3D bytecode disassembler).
  • "bytecode" profile (outputs copy of Direct3D bytecode after verifying).
  • "glsl" profile (OpenGL Shading Language 1.10)
  • "glsl120" profile (OpenGL Shading Language 1.20)
  • "arb1" profile (GL_ARB_vertex_program/GL_ARB_fragment_program)
  • "nv2" profile (GL_NV_vertex_program2_option/GL_NV_fragment_program2)
  • "nv3" profile (GL_NV_vertex_program3/GL_NV_fragment_program2)
  • "nv4" profile (GL_NV_gpu_program4)
  • Simple OpenGL glue API to hide differences between different profiles at runtime.
  • Compiles/runs on GNU/Linux (x86 and x86-64 tested; gcc).
  • Compiles/runs on Windows NT/95/98/ME/2K/XP/Vista/etc (x86 tested; Visual Studio).
  • Compiles/runs on Mac OS X (PPC and x86 tested; gcc).
  • May compile and run elsewhere with little to no modification. Success stories and patches are welcome.

What doesn't work:
  • Shader Model 4 is not supported at all yet.
  • No support for HLSL source code yet (bytecode or assembly source only).
  • Other stuff scattered in FIXMEs.
  • Contributions of other ports are, of course, welcome.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值