private RasterizerState(GraphicsDevice device, RasterizerStateDescription rasterizerStateDescription) : base(device)
        {
            Description = rasterizerStateDescription;

#if !SILICONSTUDIO_PARADOX_GRAPHICS_API_OPENGLES
            polygonMode = Description.FillMode == FillMode.Solid ? PolygonMode.Fill : PolygonMode.Line;
#endif
            
            // TODO: DepthBiasClamp and various other properties are not fully supported yet
            if (Description.DepthBiasClamp != 0.0f) throw new NotSupportedException();
        }
示例#2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RasterizerState"/> class.
 /// </summary>
 /// <param name="graphicsDevice">The graphics device.</param>
 /// <param name="rasterizerStateDescription">The rasterizer state description.</param>
 public static RasterizerState New(GraphicsDevice graphicsDevice, RasterizerStateDescription rasterizerStateDescription)
 {
     RasterizerState rasterizerState;
     lock (graphicsDevice.CachedRasterizerStates)
     {
         if (graphicsDevice.CachedRasterizerStates.TryGetValue(rasterizerStateDescription, out rasterizerState))
         {
             // TODO: Appropriate destroy
             rasterizerState.AddReferenceInternal();
         }
         else
         {
             rasterizerState = new RasterizerState(graphicsDevice, rasterizerStateDescription);
             graphicsDevice.CachedRasterizerStates.Add(rasterizerStateDescription, rasterizerState);
         }
     }
     return rasterizerState;
 }
示例#3
0
 /// <summary>
 /// Create a new fake rasterizer state for serialization.
 /// </summary>
 /// <param name="description">The description of the rasterizer state</param>
 /// <returns>The fake rasterizer state</returns>
 public static RasterizerState NewFake(RasterizerStateDescription description)
 {
     return new RasterizerState(description);
 }
示例#4
0
 // For FakeRasterizerState.
 private RasterizerState(RasterizerStateDescription description)
 {
     Description = description;
 }
 public RasterizerState(GraphicsDevice graphicsDevice, RasterizerStateDescription rasterizerStateDescription)
 {
     throw new NotImplementedException();
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="RasterizerState"/> class.
        /// </summary>
        /// <param name="device">The device.</param>
        /// <param name="name">The name.</param>
        /// <param name="rasterizerStateDescription">The rasterizer state description.</param>
        private RasterizerState(GraphicsDevice device, RasterizerStateDescription rasterizerStateDescription) : base(device)
        {
            Description = rasterizerStateDescription;

            CreateNativeDeviceChild();
        }
示例#7
0
        public override void VisitFeature(MaterialGeneratorContext context)
        {
            // Push overrides of this attributes
            context.PushOverrides(Overrides);

            // Order is important, as some features are dependent on other
            // (For example, Specular can depend on Diffuse in case of Metalness)
            // We may be able to describe a dependency system here, but for now, assume 
            // that it won't change much so it is hardcoded

            // Diffuse
            context.Visit(Diffuse);
            context.Visit(DiffuseModel);

            // Surface Geometry
            context.Visit(Tessellation);
            context.Visit(Displacement);
            context.Visit(Surface);
            context.Visit(MicroSurface);

            // If Specular has energy conservative, copy this to the diffuse lambertian model
            // TODO: Should we apply it to any Diffuse Model?
            bool isEnergyConservative = (Specular is MaterialSpecularMapFeature && ((MaterialSpecularMapFeature)Specular).IsEnergyConservative);

            var lambert = DiffuseModel as MaterialDiffuseLambertModelFeature;
            if (lambert != null)
            {
                lambert.IsEnergyConservative = isEnergyConservative;
            }

            // Specular 
            context.Visit(Specular);
            context.Visit(SpecularModel);

            // Misc
            context.Visit(Occlusion);
            context.Visit(Emissive);
            context.Visit(Transparency);

            // Pop overrides
            context.PopOverrides();

            // Set the culling mode for the material
            var cullModeDesc = new RasterizerStateDescription(CullMode);
            context.Parameters.Set(Effect.RasterizerStateKey, RasterizerState.NewFake(cullModeDesc));
        }
示例#8
0
 public FakeRasterizerState(RasterizerStateDescription description) : base(description)
 {
 }
示例#9
0
 // For FakeRasterizerState.
 protected RasterizerState(RasterizerStateDescription description)
 {
     Description = description;
 }
示例#10
0
 /// <summary>
 /// Create a new fake rasterizer state for serialization.
 /// </summary>
 /// <param name="description">The description of the rasterizer state</param>
 /// <returns>The fake rasterizer state</returns>
 public static RasterizerState NewFake(RasterizerStateDescription description)
 {
     return(new RasterizerState(description));
 }
示例#11
0
 // For FakeRasterizerState.
 private RasterizerState(RasterizerStateDescription description)
 {
     Description = description;
 }