Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
cross-shader
Advanced tools
⚔️ A cross compiler for shader languages. Convert between GLSL, HLSL, Metal Shader Language, or older versions of GLSL.
A cross compiler for shader languages. Convert between SPIR-V, GLSL / GLSL ES, HLSL, Metal Shader Language, or older versions of a given language. Cross Shader wraps glslang and SPIRV-Cross, exposing a simpler interface to transpile shaders.
npm i cross-shader -S
Note the use of dash-case
vs CamelCase
for the npm module name, this is to follow the JavaScript community's focus on making names that fit well with browser URLs.
Using this module will require Node 8.x or above, or a browser that supports WebAssembly.
First add the repo as a submodule in your dependencies folder such as external/
:
cd external
git submodule add https://github.com/alaingalvan/crossshader.git
Then in your CMakeLists.txt
file, include the following:
# ⬇ Add your dependency:
add_subdirectories(external/crossshader)
# 🔗 Link CrossShader to your project:
target_link_libraries(
${PROJECT_NAME}
CrossShader
)
This library exposes a single function compile(...)
and its config structs/enums, and returns either the output string, or throws an exception if there's an error compiling, with the error message exposed in the exception object.
TypeScript types are included, refer to cross-shader.d.ts
for more details.
Similar to other WebAssembly modules, importing the module gives you a promise to the compiled WebAssembly binary:
import xsdr from 'cross-shader';
xsdr.then(({ compile, ShaderFormat, ShaderStage }) => {
const ioptions = {
format: ShaderFormat.GLSL,
stage: ShaderStage.Vertex,
es: false,
glslVersion: 450
};
const ooptions = {
format: ShaderFormat.GLSL,
es: true,
glslVersion: 100
}
let outputString = compile(inputString, ioptions, ooptions);
});
Refer to src/CrossShader/CrossShader.h
for more details.
#include "CrossShader/CrossShader.h"
void main()
{
xsdr::InputOptions ioptions;
ioptions.format = xsdr::ShaderFormat::GLSL;
ioptions.stage = xsdr::ShaderStage::Vertex;
ioptions.es = false;
ioptions.glslVersion = 110;
xsdr::OutputOptions ooptions;
ooptions.format = xsdr::ShaderFormat::GLSL;
ooptions.es = true;
ooptions.glslVersion = 100;
std::string out = xsdr::compile(vertSource, ioptions, ooptions);
}
Be sure to have:
And type the following in any folder:
# 🐑 Clone the repo
git clone https://github.com/alaingalvan/crossshader.git --recurse-submodules
# 💿 go inside the folder
cd crossshader
# 👯 If you forget to `recurse-submodules` you can always run:
git submodule update --init
From there we'll need to set up our build files. Be sure to have the following installed:
An IDE such as Visual Studio, XCode, or a compiler such as GCC.
Then type the following in your terminal from the repo folder:
# 👷 Make a build folder
mkdir build
cd build
# 🖼️ To build your Visual Studio solution on Windows x64
cmake .. -A x64
# 🍎 To build your XCode project on Mac OS
cmake .. -G Xcode
# 🐧 To build your MakeFile on Linux
cmake ..
# 🔨 Build on any platform:
cmake --build .
Whenever you add new files to the project, run cmake ..
from your solution/project folder, and if you edit the CMakeLists.txt
file be sure to delete the generated files and run Cmake again.
Note: if you're on Windows, I would highly recommend using the Windows Subsystem for Linux.
First, install the latest version of Emscripten via the Emscripten SDK. Make sure to add it's Emscripten installation to your PATH
, then:
# ⚠️ Possible dependencies you might need:
sudo apt-get update
sudo apt-get install cmake build-essential llvm
# 🏃 Then run the following:
mkdir wasm
cd wasm
emcmake cmake ..
emmake make CrossShader -j
CrossShader is licensed as either MIT or Apache-2.0, whichever you would prefer.
FAQs
⚔️ A cross compiler for shader languages. Convert between GLSL, HLSL, Metal Shader Language, or older versions of GLSL.
The npm package cross-shader receives a total of 0 weekly downloads. As such, cross-shader popularity was classified as not popular.
We found that cross-shader demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.