1 using System.Collections.Generic;
3 using SiliconStudio.Paradox.Effects.Data;
4 using SiliconStudio.Paradox.Extensions;
5 using SiliconStudio.Paradox.DataModel;
6 using SiliconStudio.Paradox.Graphics;
7 using SiliconStudio.Paradox.Shaders;
8 using SiliconStudio.Paradox.Shaders.Compiler;
10 namespace SiliconStudio.
Paradox.Effects
16 Flags |= EffectPluginFlags.StaticPermutation;
24 return new TessellationPluginPermutationKey((
Mesh)permutation);
32 var permutationKey =
new TessellationPluginPermutationKey(effectMesh.MeshData);
33 if (permutationKey != null && permutationKey.Tessellation != null)
35 int inputControlPointCount = 3;
37 BasicShaderPlugin.ApplyMixinClass(DefaultShaderPass.Shader, permutationKey.Tessellation,
true);
40 if (permutationKey.TessellationAEN)
42 BasicShaderPlugin.ApplyMixinClass(DefaultShaderPass.Shader,
new ShaderClassSource(
"TessellationDisplacementAEN"),
true);
43 DefaultShaderPass.SubMeshDataKey =
"TessellationAEN";
44 inputControlPointCount = 12;
47 DefaultShaderPass.Macros.Add(
new ShaderMacro(
"InputControlPointCount", inputControlPointCount));
48 DefaultShaderPass.Macros.Add(
new ShaderMacro(
"OutputControlPointCount", 3));
52 private class TessellationPluginPermutationKey
54 public TessellationPluginPermutationKey(
Mesh meshData)
56 if (meshData.
Draw == null)
59 Tessellation = meshData.EffectParameters.Get(EffectData.Tessellation);
60 if (Tessellation != null)
62 TessellationAEN = meshData.Material.Parameters.Get(EffectData.TessellationAEN);
67 public bool TessellationAEN {
get; set; }
69 protected bool Equals(TessellationPluginPermutationKey other)
71 return ShaderSourceComparer.Default.Equals(Tessellation, other.Tessellation)
72 && TessellationAEN.
Equals(other.TessellationAEN);
75 public override bool Equals(
object obj)
77 if (ReferenceEquals(null, obj))
return false;
78 if (ReferenceEquals(
this, obj))
return true;
79 if (obj.GetType() != typeof(TessellationPluginPermutationKey))
return false;
80 return Equals((TessellationPluginPermutationKey)obj);
83 public override int GetHashCode()
87 int hashCode = (Tessellation != null ? ShaderSourceComparer.Default.GetHashCode(Tessellation) : 0);
88 hashCode = (hashCode * 397) ^ TessellationAEN.GetHashCode();
SiliconStudio.Paradox.Shaders.ShaderMacro ShaderMacro
A mixin performing a combination of ShaderClassSource and other mixins.
override void SetupShaders(EffectMesh effectMesh)
Flags
Enumeration of the new Assimp's flags.
override bool Equals(object against)
Determines whether the specified System.Object is equal to this instance.
A shader class used for mixin.
object GenerateEffectKey(Dictionary< ParameterKey, object > permutations)
static ParameterKey< Mesh > Key