public void TestMaterial() { var compiler = new EffectCompiler { UseFileSystem = true }; var currentPath = Core.PlatformFolders.ApplicationBinaryDirectory; compiler.SourceDirectories.Add(Path.Combine(currentPath, @"..\..\sources\engine\SiliconStudio.Xenko.Graphics\Shaders")); compiler.SourceDirectories.Add(Path.Combine(currentPath, @"..\..\sources\engine\SiliconStudio.Xenko.Engine\Rendering\Shaders")); compiler.SourceDirectories.Add(Path.Combine(currentPath, @"..\..\sources\engine\SiliconStudio.Xenko.Engine\Rendering\Core")); compiler.SourceDirectories.Add(Path.Combine(currentPath, @"..\..\sources\engine\SiliconStudio.Xenko.Engine\Rendering\Lights")); compiler.SourceDirectories.Add(Path.Combine(currentPath, @"..\..\sources\engine\SiliconStudio.Xenko.Engine\Rendering\Shadows")); compiler.SourceDirectories.Add(Path.Combine(currentPath, @"..\..\sources\engine\SiliconStudio.Xenko.Engine\Rendering\Materials\Shaders")); compiler.SourceDirectories.Add(Path.Combine(currentPath, @"..\..\sources\engine\SiliconStudio.Xenko.Engine\Rendering\Materials\ComputeColors\Shaders")); compiler.SourceDirectories.Add(Path.Combine(currentPath, @"..\..\sources\engine\SiliconStudio.Xenko.Engine\Rendering\Skinning")); compiler.SourceDirectories.Add(Path.Combine(currentPath, @"..\..\sources\engine\SiliconStudio.Xenko.Engine\Rendering\Shading")); compiler.SourceDirectories.Add(Path.Combine(currentPath, @"..\..\sources\engine\SiliconStudio.Xenko.Engine\Rendering\Transformation")); compiler.SourceDirectories.Add(Path.Combine(currentPath, @"..\..\sources\engine\SiliconStudio.Xenko.Engine\Rendering\Utils")); var compilerParameters = new CompilerParameters { EffectParameters = { Platform = GraphicsPlatform.OpenGL } }; var layers = new MaterialBlendLayers(); layers.Add(new MaterialBlendLayer { BlendMap = new ComputeFloat(0.5f), Material = AttachedReferenceManager.CreateProxyObject <Material>(AssetId.Empty, "fake") }); var materialAsset = new MaterialAsset { Attributes = new MaterialAttributes() { Diffuse = new MaterialDiffuseMapFeature() { DiffuseMap = new ComputeColor(Color4.White) }, DiffuseModel = new MaterialDiffuseLambertModelFeature() }, Layers = layers }; var fakeAsset = new MaterialAsset { Attributes = new MaterialAttributes() { Diffuse = new MaterialDiffuseMapFeature() { DiffuseMap = new ComputeColor(Color.Blue) }, } }; var context = new MaterialGeneratorContext { FindAsset = reference => fakeAsset }; var result = MaterialGenerator.Generate(new MaterialDescriptor { Attributes = materialAsset.Attributes, Layers = materialAsset.Layers }, context, "TestMaterial"); compilerParameters.Set(MaterialKeys.PixelStageSurfaceShaders, result.Material.Parameters.Get(MaterialKeys.PixelStageSurfaceShaders)); var directionalLightGroup = new ShaderClassSource("LightDirectionalGroup", 1); compilerParameters.Set(LightingKeys.DirectLightGroups, new ShaderSourceCollection { directionalLightGroup }); //compilerParameters.Set(LightingKeys.CastShadows, false); //compilerParameters.Set(MaterialParameters.HasSkinningPosition, true); //compilerParameters.Set(MaterialParameters.HasSkinningNormal, true); compilerParameters.Set(MaterialKeys.HasNormalMap, true); var results = compiler.Compile(new ShaderMixinGeneratorSource("XenkoEffectBase"), compilerParameters); Assert.IsFalse(results.HasErrors); }
public void TestMaterial() { var compiler = new EffectCompiler { UseFileSystem = true }; compiler.SourceDirectories.Add(@"..\..\sources\engine\SiliconStudio.Paradox.Graphics\Shaders"); compiler.SourceDirectories.Add(@"..\..\sources\engine\SiliconStudio.Paradox.Engine\Shaders"); compiler.SourceDirectories.Add(@"..\..\sources\shaders\Core"); compiler.SourceDirectories.Add(@"..\..\sources\shaders\Lights"); compiler.SourceDirectories.Add(@"..\..\sources\shaders\Materials"); compiler.SourceDirectories.Add(@"..\..\sources\shaders\Shadows"); compiler.SourceDirectories.Add(@"..\..\sources\shaders\ComputeColor"); compiler.SourceDirectories.Add(@"..\..\sources\shaders\Skinning"); compiler.SourceDirectories.Add(@"..\..\sources\shaders\Shading"); compiler.SourceDirectories.Add(@"..\..\sources\shaders\Transformation"); compiler.SourceDirectories.Add(@"..\..\sources\shaders\Utils"); var compilerParameters = new CompilerParameters { Platform = GraphicsPlatform.Direct3D11 }; var layers = new MaterialBlendLayers(); layers.Add(new MaterialBlendLayer { BlendMap = new ComputeFloat(0.5f), Material = AttachedReferenceManager.CreateSerializableVersion <Material>(Guid.Empty, "fake") }); var materialAsset = new MaterialAsset { Attributes = new MaterialAttributes() { Diffuse = new MaterialDiffuseMapFeature() { DiffuseMap = new ComputeColor(Color4.White) }, DiffuseModel = new MaterialDiffuseLambertModelFeature() }, Layers = layers }; var fakeAsset = new MaterialAsset { Attributes = new MaterialAttributes() { Diffuse = new MaterialDiffuseMapFeature() { DiffuseMap = new ComputeColor(Color.Blue) }, } }; var context = new MaterialGeneratorContext { FindAsset = reference => fakeAsset }; var result = MaterialGenerator.Generate(new MaterialDescriptor { Attributes = materialAsset.Attributes, Layers = materialAsset.Layers }, context, "TestMaterial"); compilerParameters.Set(MaterialKeys.PixelStageSurfaceShaders, result.Material.Parameters.Get(MaterialKeys.PixelStageSurfaceShaders)); var directionalLightGroup = new ShaderClassSource("LightDirectionalGroup", 1); compilerParameters.Set(LightingKeys.DirectLightGroups, new List <ShaderSource> { directionalLightGroup }); //compilerParameters.Set(LightingKeys.CastShadows, false); //compilerParameters.Set(MaterialParameters.HasSkinningPosition, true); //compilerParameters.Set(MaterialParameters.HasSkinningNormal, true); compilerParameters.Set(MaterialKeys.HasNormalMap, true); var results = compiler.Compile(new ShaderMixinGeneratorSource("ParadoxEffectBase"), compilerParameters); Assert.IsFalse(results.HasErrors); }
public void TestMaterial() { var compiler = new EffectCompiler { UseFileSystem = true }; compiler.SourceDirectories.Add(@"..\..\sources\engine\SiliconStudio.Paradox.Graphics\Shaders"); compiler.SourceDirectories.Add(@"..\..\sources\engine\SiliconStudio.Paradox.Engine\Shaders"); compiler.SourceDirectories.Add(@"..\..\sources\shaders\Core"); compiler.SourceDirectories.Add(@"..\..\sources\shaders\Lights"); compiler.SourceDirectories.Add(@"..\..\sources\shaders\Materials"); compiler.SourceDirectories.Add(@"..\..\sources\shaders\Shadows"); compiler.SourceDirectories.Add(@"..\..\sources\shaders\ComputeColor"); compiler.SourceDirectories.Add(@"..\..\sources\shaders\Skinning"); compiler.SourceDirectories.Add(@"..\..\sources\shaders\Shading"); compiler.SourceDirectories.Add(@"..\..\sources\shaders\Transformation"); compiler.SourceDirectories.Add(@"..\..\sources\shaders\Utils"); var compilerParameters = new CompilerParameters { Platform = GraphicsPlatform.Direct3D11 }; var layers = new MaterialBlendLayers(); layers.Add(new MaterialBlendLayer { BlendMap = new ComputeFloat(0.5f), Material = AttachedReferenceManager.CreateSerializableVersion<Material>(Guid.Empty, "fake") }); var materialAsset = new MaterialAsset { Attributes = new MaterialAttributes() { Diffuse = new MaterialDiffuseMapFeature() { DiffuseMap = new ComputeColor(Color4.White) }, DiffuseModel = new MaterialDiffuseLambertModelFeature() }, Layers = layers }; var fakeAsset = new MaterialAsset { Attributes = new MaterialAttributes() { Diffuse = new MaterialDiffuseMapFeature() { DiffuseMap = new ComputeColor(Color.Blue) }, } }; var context = new MaterialGeneratorContext { FindAsset = reference => fakeAsset }; var result = MaterialGenerator.Generate(new MaterialDescriptor { Attributes = materialAsset.Attributes, Layers = materialAsset.Layers }, context, "TestMaterial"); compilerParameters.Set(MaterialKeys.PixelStageSurfaceShaders, result.Material.Parameters.Get(MaterialKeys.PixelStageSurfaceShaders)); var directionalLightGroup = new ShaderClassSource("LightDirectionalGroup", 1); compilerParameters.Set(LightingKeys.DirectLightGroups, new List<ShaderSource> { directionalLightGroup }); //compilerParameters.Set(LightingKeys.CastShadows, false); //compilerParameters.Set(MaterialParameters.HasSkinningPosition, true); //compilerParameters.Set(MaterialParameters.HasSkinningNormal, true); compilerParameters.Set(MaterialKeys.HasNormalMap, true); var results = compiler.Compile(new ShaderMixinGeneratorSource("ParadoxEffectBase"), compilerParameters); Assert.IsFalse(results.HasErrors); }