コード例 #1
0
 private void Material_OnMaterialPropertyChanged(object sender, MaterialPropertyChanged e)
 {
     if (e.PropertyName.Equals(nameof(material.DiffuseMap)))
     {
         CreateTextureView(material.DiffuseMap, ref this.texDiffuseMapView);
     }
     else if (e.PropertyName.Equals(nameof(material.NormalMap)))
     {
         CreateTextureView(material.NormalMap, ref this.texNormalMapView);
     }
     else if (e.PropertyName.Equals(nameof(material.DisplacementMap)))
     {
         CreateTextureView(material.DisplacementMap, ref this.texDisplacementMapView);
     }
     else if (e.PropertyName.Equals(nameof(material.DiffuseAlphaMap)))
     {
         CreateTextureView(material.DiffuseAlphaMap, ref this.texDiffuseAlphaMapView);
     }
     else if (e.PropertyName.Equals(nameof(material.SpecularMap)))
     {
         CreateTextureView(material.SpecularMap, ref this.texSpecularMapView);
     }
     else if (e.PropertyName.Equals(nameof(material.EmissiveMap)))
     {
         CreateTextureView(material.EmissiveMap, ref this.texEmissiveMapView);
     }
     OnInvalidateRenderer?.Invoke(this, null);
 }
コード例 #2
0
        private bool SetAffectsRender <T>(ref T backingField, T value, [CallerMemberName] string propertyName = "")
        {
            if (EqualityComparer <T> .Default.Equals(backingField, value))
            {
                return(false);
            }

            backingField = value;
            this.RaisePropertyChanged(propertyName);
            needUpdate = true;
            OnInvalidateRenderer?.Invoke(this, EventArgs.Empty);
            return(true);
        }
コード例 #3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="manager"></param>
 /// <param name="material"></param>
 private DiffuseMaterialVariables(IEffectsManager manager, PhongMaterialCore material)
 {
     this.material             = material;
     needUpdate                = true;
     material.PropertyChanged += Material_OnMaterialPropertyChanged;
     texDiffuseSlot            = -1;
     samplerDiffuseSlot        = samplerShadowSlot = -1;
     textureManager            = manager.MaterialTextureManager;
     statePoolManager          = manager.StateManager;
     CreateTextureViews();
     CreateSamplers();
     this.PropertyChanged += (s, e) => { OnInvalidateRenderer?.Invoke(this, EventArgs.Empty); };
 }
コード例 #4
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="manager"></param>
 /// <param name="modelGuid"></param>
 public TextureSharedPhongMaterialVariables(IEffectsManager manager, Guid modelGuid)
 {
     ModelGuid = modelGuid;
     for (int i = 0; i < Constants.NumShaderStages; ++i)
     {
         TextureBindingMap[i] = new int[NUMTEXTURES];
         SamplerBindingMap[i] = new int[NUMSAMPLERS];
     }
     textureManager   = manager.MaterialTextureManager;
     statePoolManager = manager.StateManager;
     CreateTextureViews();
     CreateSamplers();
     this.PropertyChanged += (s, e) => { OnInvalidateRenderer?.Invoke(this, EventArgs.Empty); };
 }
コード例 #5
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="manager"></param>
 /// <param name="material"></param>
 public ColorStripeMaterialVariables(IEffectsManager manager, ColorStripeMaterialCore material)
 {
     this.material             = material;
     deviceResources           = manager;
     needUpdate                = true;
     material.PropertyChanged += Material_OnMaterialPropertyChanged;
     texStripeXSlot            = texStripeYSlot = -1;
     samplerDiffuseSlot        = -1;
     textureManager            = manager.MaterialTextureManager;
     statePoolManager          = manager.StateManager;
     CreateTextureViews();
     CreateSamplers();
     this.PropertyChanged += (s, e) => { OnInvalidateRenderer?.Invoke(this, EventArgs.Empty); };
 }
コード例 #6
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="manager"></param>
 /// <param name="material"></param>
 public TextureSharedPhongMaterialVariables(IEffectsManager manager, PhongMaterialCore material)
 {
     this.material             = material;
     needUpdate                = true;
     material.PropertyChanged += Material_OnMaterialPropertyChanged;
     texDiffuseSlot            = texAlphaSlot = texDisplaceSlot = texNormalSlot = -1;
     samplerDiffuseSlot        = samplerAlphaSlot = samplerDisplaceSlot = samplerNormalSlot = samplerShadowSlot = -1;
     textureManager            = manager.MaterialTextureManager;
     statePoolManager          = manager.StateManager;
     CreateTextureViews();
     CreateSamplers();
     EnableTessellation    = material.EnableTessellation;
     this.PropertyChanged += (s, e) => { OnInvalidateRenderer?.Invoke(this, EventArgs.Empty); };
 }
コード例 #7
0
 private void Material_OnMaterialPropertyChanged(object sender, PropertyChangedEventArgs e)
 {
     needUpdate = true;
     if (IsDisposed)
     {
         return;
     }
     if (e.PropertyName.Equals(nameof(PhongMaterialCore.DiffuseMap)))
     {
         CreateTextureView((sender as PhongMaterialCore).DiffuseMap, DiffuseIdx);
     }
     else if (e.PropertyName.Equals(nameof(PhongMaterialCore.NormalMap)))
     {
         CreateTextureView((sender as PhongMaterialCore).NormalMap, NormalIdx);
     }
     else if (e.PropertyName.Equals(nameof(PhongMaterialCore.DisplacementMap)))
     {
         CreateTextureView((sender as PhongMaterialCore).DisplacementMap, DisplaceIdx);
     }
     else if (e.PropertyName.Equals(nameof(PhongMaterialCore.DiffuseAlphaMap)))
     {
         CreateTextureView((sender as PhongMaterialCore).DiffuseAlphaMap, AlphaIdx);
     }
     else if (e.PropertyName.Equals(nameof(PhongMaterialCore.DiffuseMapSampler)))
     {
         RemoveAndDispose(ref SamplerResources[DiffuseIdx]);
         SamplerResources[DiffuseIdx] = Collect(statePoolManager.Register((sender as PhongMaterialCore).DiffuseMapSampler));
     }
     else if (e.PropertyName.Equals(nameof(PhongMaterialCore.DiffuseAlphaMapSampler)))
     {
         RemoveAndDispose(ref SamplerResources[AlphaIdx]);
         SamplerResources[AlphaIdx] = Collect(statePoolManager.Register((sender as PhongMaterialCore).DiffuseAlphaMapSampler));
     }
     else if (e.PropertyName.Equals(nameof(PhongMaterialCore.DisplacementMapSampler)))
     {
         RemoveAndDispose(ref SamplerResources[DisplaceIdx]);
         SamplerResources[DisplaceIdx] = Collect(statePoolManager.Register((sender as PhongMaterialCore).DisplacementMapSampler));
     }
     else if (e.PropertyName.Equals(nameof(PhongMaterialCore.NormalMapSampler)))
     {
         RemoveAndDispose(ref SamplerResources[NormalIdx]);
         SamplerResources[NormalIdx] = Collect(statePoolManager.Register((sender as PhongMaterialCore).NormalMapSampler));
     }
     else if (e.PropertyName.Equals(nameof(PhongMaterialCore.EnableTessellation)))
     {
         EnableTessellation = material.EnableTessellation;
     }
     OnInvalidateRenderer?.Invoke(this, EventArgs.Empty);
 }
コード例 #8
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="manager"></param>
 public PhongMaterialVariables(IEffectsManager manager)
 {
     for (int i = 0; i < Constants.NumShaderStages; ++i)
     {
         TextureBindingMap[i] = new int[NUMTEXTURES];
         SamplerBindingMap[i] = new int[NUMSAMPLERS];
     }
     Device                        = manager.Device;
     statePoolManager              = manager.StateManager;
     TextureResources[DiffuseIdx]  = Collect(new ShaderResourceViewProxy(Device));
     TextureResources[NormalIdx]   = Collect(new ShaderResourceViewProxy(Device));
     TextureResources[DisplaceIdx] = Collect(new ShaderResourceViewProxy(Device));
     TextureResources[AlphaIdx]    = Collect(new ShaderResourceViewProxy(Device));
     CreateTextureViews();
     CreateSamplers();
     this.PropertyChanged += (s, e) => { OnInvalidateRenderer?.Invoke(this, new EventArgs()); };
 }
コード例 #9
0
        private void Material_OnMaterialPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            needUpdate = true;
            if (IsDisposed)
            {
                return;
            }
            if (e.PropertyName.Equals(nameof(ColorStripeMaterialCore.ColorStripeX)))
            {
                CreateTextureView((sender as ColorStripeMaterialCore).ColorStripeX, 0);
            }
            else if (e.PropertyName.Equals(nameof(ColorStripeMaterialCore.ColorStripeY)))
            {
                CreateTextureView((sender as ColorStripeMaterialCore).ColorStripeY, 1);
            }
            else if (e.PropertyName.Equals(nameof(ColorStripeMaterialCore.ColorStripeSampler)))
            {
                RemoveAndDispose(ref sampler);
                sampler = Collect(statePoolManager.Register((sender as ColorStripeMaterialCore).ColorStripeSampler));
            }

            OnInvalidateRenderer?.Invoke(this, EventArgs.Empty);
        }
コード例 #10
0
 /// <summary>
 /// Invalidates the renderer.
 /// </summary>
 protected void InvalidateRenderer()
 {
     OnInvalidateRenderer?.Invoke(this, EventArgs.Empty);
 }
コード例 #11
0
 public void InvalidateRenderer()
 {
     OnInvalidateRenderer?.Invoke(this, EventArgs.Empty);
 }