Workflow

To work with Visual Studio, a C# class library can be used, with a class that contains a mainImage implementation for each pass. A common code could also be added as a base class for each pass, or as a static class referenced with a using static directive. The gap between GLSL built-in types and methods, and C# types, could be filled by including the Environment files.

The viewer could load C# code and convert it to GLSL with the help of a few built-in and language specific conversion rules. In addition to that, a few line and text conversion rules could also be applied in places where C# and GLSL are still not fully compatible.

The New Project templates can be used for creating C# projects. More C# projects examples can be found here.

Project Structure Example

Class Structure - Image.cs
namespace Shader1;

class Image : Common // access common members
{
    void mainImage(out vec4 fragColor, in vec2 fragCoord)
    {
        vec3 result = color; // access common uniform
        // ...

        result = linearToSrgb(result); // access common method
        fragColor = vec4(result, 1.0);
    }
}
Class Structure - Common.cs
namespace Shader1;

// internal class, with public or protected members
// accessible through inheritance
class Common
{
    //@uniform, type: linear-rgb
    protected vec3 color = vec3(0.5);

    protected vec3 linearToSrgb(vec3 color)
    {
        //@const
        float_ f = 1.0 / 2.2;
        return vec3(pow(color.r, f), pow(color.g, f), pow(color.b, f));
    }
}
Project Definition - Shader1.json
{
    "Common": "Common.cs",
    "Image": {
        "Source": "Image.cs",
        "Channel0": "Image",
        "Channel1": "Keyboard"
    }
}
C# Project - Shader1.csproj
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
    <LangVersion>10.0</LangVersion>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>disable</Nullable>
    <EnvironmentPath>...\path\to\Shaderlens\Resources\CSharpEnvironment</EnvironmentPath>
  </PropertyGroup>

  <Import Project="$(EnvironmentPath)\Build\Environment.targets" />
</Project>
C# Project File Structure
│   Shader1.sln                        -- Visual Studio solution
│   Shader1.csproj                     -- A class library project
│
│   Shader1.json                       -- Project definition
│
│   Common.cs                          -- Common code
│   Image.cs                           -- Image pass
│
├── Environment (hidden)               -- Linked Environment files
│       Float.cs
│       Vec2.cs
│       ...
│       Suppressions.cs
│       Uniforms.cs
│       Usings.cs
│
├── Properties
│       launchSettings.json            -- Enable Ctrl+F5 launch
│
└── obj\Debug\netstandard2.0 (hidden)
        Environment.Suppressions.g.cs  -- Auto generated suppressions