Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
EffectShaderAssetCompiler.cs
Go to the documentation of this file.
1 // Copyright (c) 2014 Silicon Studio Corp. (http://siliconstudio.co.jp)
2 // This file is distributed under GPL v3. See LICENSE.md for details.
3 using System.Collections.Concurrent;
4 using System.IO;
5 using SiliconStudio.Assets.Compiler;
6 using SiliconStudio.BuildEngine;
7 using SiliconStudio.Core;
8 using SiliconStudio.Core.IO;
9 using SiliconStudio.Paradox.Effects;
10 
11 namespace SiliconStudio.Paradox.Assets.Effect
12 {
13  /// <summary>
14  /// Entry point to compile an <see cref="EffectCompositorAsset"/>
15  /// </summary>
16  public class EffectShaderAssetCompiler : AssetCompilerBase<EffectShaderAsset>
17  {
18  public static readonly PropertyKey<ConcurrentDictionary<string, string>> ShaderLocationsKey = new PropertyKey<ConcurrentDictionary<string, string>>("ShaderPathsKey", typeof(EffectShaderAssetCompiler));
19 
20  protected override void Compile(AssetCompilerContext context, string urlInStorage, UFile assetAbsolutePath, EffectShaderAsset asset, AssetCompilerResult result)
21  {
22  var url = EffectSystem.DefaultSourceShaderFolder + "/" + Path.GetFileName(assetAbsolutePath);
23 
24  var originalSourcePath = asset.AbsoluteSourceLocation;
25  result.BuildSteps = new ListBuildStep { new ImportStreamCommand { SourcePath = originalSourcePath, Location = url, SaveSourcePath = true } };
26  var shaderLocations = (ConcurrentDictionary<string, string>)context.Properties.GetOrAdd(ShaderLocationsKey, key => new ConcurrentDictionary<string, string>());
27 
28  // Store directly this into the context TODO this this temporary
29  shaderLocations[url] = originalSourcePath;
30  }
31  }
32 }
Result of a compilation of assets when using IAssetCompiler.Compile
Describes a shader effect asset (pdxsl).
The context used when compiling an asset in a Package.
PropertyCollection Properties
Gets the attributes attached to this context.
override void Compile(AssetCompilerContext context, string urlInStorage, UFile assetAbsolutePath, EffectShaderAsset asset, AssetCompilerResult result)
A class that represents a tag propety.
Definition: PropertyKey.cs:17
Defines a normalized file path. See UPath for details. This class cannot be inherited.
Definition: UFile.cs:13