private void LoadLightingShaders()
        {
            var depthVert = ReadEmbeddedShader("shadow-depth.vert");
            var depthFrag = ReadEmbeddedShader("shadow-depth.frag");

            _fovCalculationProgram = _compileProgram(depthVert, depthFrag, "Shadow Depth Program");

            var debugShader = _resourceCache.GetResource <ShaderSourceResource>("/Shaders/Internal/depth-debug.swsl");

            _fovDebugShaderInstance = (ClydeShaderInstance)InstanceShader(debugShader.ClydeHandle);
        }
        public ShaderInstance InstanceShader(ClydeHandle handle)
        {
            var newHandle = AllocRid();
            var loaded    = new LoadedShaderInstance
            {
                ShaderHandle = handle
            };
            var instance = new ClydeShaderInstance(newHandle, this);

            _shaderInstances.Add(newHandle, loaded);
            return(instance);
        }
        private void LoadStockShaders()
        {
            _shaderWrapCodeDefaultFrag = ReadEmbeddedShader("base-default.frag");
            _shaderWrapCodeDefaultVert = ReadEmbeddedShader("base-default.vert");

            _shaderWrapCodeRawVert = ReadEmbeddedShader("base-raw.vert");
            _shaderWrapCodeRawFrag = ReadEmbeddedShader("base-raw.frag");

            var defaultLoadedShader = _resourceCache
                                      .GetResource <ShaderSourceResource>("/Shaders/Internal/default-sprite.swsl").ClydeHandle;

            _defaultShader = (ClydeShaderInstance)InstanceShader(defaultLoadedShader);

            _queuedShader = _defaultShader.Handle;
        }
Beispiel #4
0
        private void _loadStockShaders()
        {
            _shaderWrapCodeSpriteFrag = _readFile("/Shaders/Internal/sprite.frag");
            _shaderWrapCodeSpriteVert = _readFile("/Shaders/Internal/sprite.vert");


            var defaultLoadedShader = _resourceCache
                                      .GetResource <ShaderSourceResource>("/Shaders/Internal/default-sprite.swsl").ClydeHandle;

            _defaultShader = (ClydeShaderInstance)InstanceShader(defaultLoadedShader);

            _queuedShader = _defaultShader.Handle;

            var lightVert = _readFile("/Shaders/Internal/light.vert");
            var lightFrag = _readFile("/Shaders/Internal/light.frag");

            _lightShader = _compileProgram(lightVert, lightFrag, "_lightShader");
        }
        private void LoadLightingShaders()
        {
            var depthVert = ReadEmbeddedShader("shadow-depth.vert");
            var depthFrag = ReadEmbeddedShader("shadow-depth.frag");

            _fovCalculationProgram = _compileProgram(depthVert, depthFrag, "Shadow Depth Program");

            var debugShader = _resourceCache.GetResource <ShaderSourceResource>("/Shaders/Internal/depth-debug.swsl");

            _fovDebugShaderInstance = (ClydeShaderInstance)InstanceShader(debugShader.ClydeHandle);

            ClydeHandle LoadShaderHandle(string path)
            {
                try
                {
                    var shaderSource = _resourceCache.GetResource <ShaderSourceResource>(path);
                    return(shaderSource.ClydeHandle);
                }
                catch (Exception ex)
                {
                    Logger.Warning($"Can't load shader {path}\n{ex.GetType().Name}: {ex.Message}");
                    return(default);
        private void LoadLightingShaders()
        {
            var depthVert = ReadEmbeddedShader("shadow-depth.vert");
            var depthFrag = ReadEmbeddedShader("shadow-depth.frag");

            _fovCalculationProgram = _compileProgram(depthVert, depthFrag, "Shadow Depth Program");

            var debugShader = _resourceCache.GetResource <ShaderSourceResource>("/Shaders/Internal/depth-debug.swsl");

            _fovDebugShaderInstance = (ClydeShaderInstance)InstanceShader(debugShader.ClydeHandle);

            ClydeHandle LoadShaderHandle(string path)
            {
                var shaderSource = _resourceCache.GetResource <ShaderSourceResource>(path);

                return(shaderSource.ClydeHandle);
            }

            _lightShaderHandle          = LoadShaderHandle("/Shaders/Internal/light.swsl");
            _fovShaderHandle            = LoadShaderHandle("/Shaders/Internal/fov.swsl");
            _fovLightShaderHandle       = LoadShaderHandle("/Shaders/Internal/fov-lighting.swsl");
            _wallBleedBlurShaderHandle  = LoadShaderHandle("/Shaders/Internal/wall-bleed-blur.swsl");
            _mergeWallLayerShaderHandle = LoadShaderHandle("/Shaders/Internal/wall-merge.swsl");
        }