Environment

Shaderlens C# environment contains definitions for GLSL built in types and method, allowing C# shaders to build correctly. The implementation was left empty, so it could not be used to test shader execution behavior. The environment source files can be found here.

The environment files are included with the application, and can be imported to C# projects using the targets file at Resources\CSharpEnvironment\Build\Environment.targets.

The environment contains the following types and methods:

  • vec#, ivec#, uvec#, bvec#, mat# types, and static constructor methods.

  • sampler* types, and texture*(sampler*, ...) static methods.

  • Math static methods such as sin, abs, step, mix, etc.

  • A Float type, with _float, and float_ aliases, to implicitly convert between double literals and float primitives (see floating point workarounds for usage examples).

  • Built-in Uniforms static imports.

The environment contains global using declarations, for importing types, and static methods.

The environment also contains a build task for automatically generating a suppressions file with rules for mainImage methods usage, and uniforms modifiers suggestions (a project build is required for generating and updating these rules).

The environment targets file is imported by projects that are generated with C# templates (in the New Project dialog), and can also be imported manually by adding the following code to the .csproj file:

<PropertyGroup>
  <EnvironmentPath>...\path\to\Shaderlens\Resources\CSharpEnvironment</EnvironmentPath>
</PropertyGroup>

<Import Project="$(EnvironmentPath)\Build\Environment.targets" />