コード例 #1
0
        private void GenerateMaterialPreview(int selectedMaterial)
        {
            if (!isGeneratingPreview)
            {
                try
                {
                    isGeneratingPreview = true;
                    ClearObjects();

                    CustomMaterial currentMaterial = MaterialAssetLoader.CustomMaterialObjects[selectedMaterial];
                    if (currentMaterial != null)
                    {
                        customMaterialChanged?.Invoke(currentMaterial);
                        InitializePreviewObjects(currentMaterial, preview.transform);
                    }
                }
                catch (Exception ex)
                {
                    Logger.log.Error(ex);
                }
                finally
                {
                    isGeneratingPreview = false;
                }
            }
        }
コード例 #2
0
        private void InitializePreviewObjects(CustomMaterial customMaterial, Transform transform)
        {
            if (customMaterial.GameObject)
            {
                materialObject = CreatePreviewMaterial(customMaterial.GameObject, transform);

                if (materialObject)
                {
                    // Fix irregular model scales (in most cases)
                    foreach (Transform child in materialObject.GetComponentsInChildren <Transform>(false))
                    {
                        if (child)
                        {
                            child.localScale    = Vector3.one;
                            child.localPosition = Vector3.zero;
                        }
                    }

                    materialObject.transform.localScale = new Vector3(10f, 37.5f, 75f);
                    if (customMaterial.Descriptor.ReplaceMesh)
                    {
                        // Account for custom mesh scale being weird in previews
                        materialObject.transform.localScale *= 0.025f;
                    }

                    Renderer renderer = materialObject.gameObject?.GetComponentInChildren <Renderer>();
                    MaterialUtils.SetMaterialsColor(renderer?.materials, colorManager.GetObstacleEffectColor());
                }
            }
        }
コード例 #3
0
 public bool IsMaterialUseNormalMap()
 {
     if (CustomMaterial == null)
     {
         return(false);
     }
     return(CustomMaterial.HasProperty(SplatNormalPropertyName + "0"));
 }
コード例 #4
0
 void Start()
 {
     for (int i = 0; i < materials.Count; i++)
     {
         CustomMaterial temp = materials[i];
         copyMaterials.Add(temp);
     }
     RefreshUseCount();
 }
コード例 #5
0
 public void OnMaterialWasChanged(CustomMaterial customMaterial)
 {
     if (!string.IsNullOrWhiteSpace(customMaterial?.ErrorMessage))
     {
         errorDescription.gameObject.SetActive(true);
         errorDescription.SetText($"{customMaterial.Descriptor?.MaterialName}:\n\n{Utils.SafeUnescape(customMaterial.ErrorMessage)}");
     }
     else
     {
         errorDescription.gameObject.SetActive(false);
     }
 }
コード例 #6
0
        private void OnGameSceneLoaded()
        {
            MaterialUtils.CurrentColorManager = Resources.FindObjectsOfTypeAll <ColorManager>().LastOrDefault();

            CustomMaterial customMaterial = MaterialAssetLoader.CustomMaterialObjects[MaterialAssetLoader.SelectedMaterial];

            if (customMaterial.Descriptor.DisablesScore ||
                Configuration.UserDisabledScores)
            {
                BS_Utils.Gameplay.ScoreSubmission.DisableSubmission(PluginName);
                Logger.log.Info("ScoreSubmission has been disabled.");
            }
        }
コード例 #7
0
        private static CustomMaterial LoadEmbeddedMaterial(string fileName)
        {
            CustomMaterial customMaterial = null;

            try
            {
                byte[] resource = Utils.LoadFromResource($"CustomWalls.Resources.Materials.{fileName}");
                customMaterial = new CustomMaterial(resource, fileName);
            }
            catch (Exception ex)
            {
                Logger.log.Warn($"Failed to load an internal file: '{fileName}'");
                Logger.log.Warn(ex);
            }

            return(customMaterial);
        }
コード例 #8
0
        public bool deleteCustomMaterial(int customMaterialtID)
        {
            int count = 0;

            using (Entities.Entities ctx = new Entities.Entities())
            {
                CustomMaterial customMatrial = ctx.CustomMaterials.Find(customMaterialtID);
                if (customMatrial == null)
                {
                    return(false);
                }

                ctx.CustomMaterials.Remove(customMatrial);
                count = ctx.SaveChanges();
            }
            return(count > 0 ? true : false);
        }
コード例 #9
0
        private static void Postfix(ref ObstacleController __instance, StretchableObstacle ____stretchableObstacle, ref SimpleColorSO ____color)
        {
            try
            {
                CustomMaterial customMaterial = MaterialAssetLoader.CustomMaterialObjects[MaterialAssetLoader.SelectedMaterial];
                if (customMaterial.FileName != "DefaultMaterials")
                {
                    Renderer mesh  = __instance.gameObject.GetComponentInChildren <Renderer>();
                    Color    color = ____color.color;

                    if (customMaterial.Descriptor.Overlay)
                    {
                        GameObject overlay = MeshUtils.CreateOverlay(mesh, customMaterial.MaterialRenderer, customMaterial.Descriptor.OverlayOffset);
                        MaterialUtils.SetMaterialsColor(overlay?.GetComponent <Renderer>().materials, color);
                        if (customMaterial.Descriptor.ReplaceMesh)
                        {
                            MeshUtils.ReplaceMesh(overlay.GetComponent <MeshFilter>(), customMaterial.MaterialMeshFilter, customMaterial.Descriptor.MeshScaleMultiplier);
                            if (!customMaterial.Descriptor.ReplaceOnlyOverlayMesh)
                            {
                                MeshUtils.ReplaceMesh(__instance.gameObject.GetComponentInChildren <MeshFilter>(), customMaterial.MaterialMeshFilter, customMaterial.Descriptor.MeshScaleMultiplier);
                            }
                        }
                    }
                    else
                    {
                        MaterialUtils.ReplaceRenderer(mesh, customMaterial.MaterialRenderer);
                        MaterialUtils.SetMaterialsColor(mesh?.materials, color);
                        if (customMaterial.Descriptor.ReplaceMesh)
                        {
                            MeshUtils.ReplaceMesh(__instance.gameObject.GetComponentInChildren <MeshFilter>(), customMaterial.MaterialMeshFilter, customMaterial.Descriptor.MeshScaleMultiplier);
                        }
                    }
                }

                if (!Configuration.EnableObstacleFrame)
                {
                    ParametricBoxFrameController frame = ____stretchableObstacle.GetPrivateField <ParametricBoxFrameController>("_obstacleFrame");
                    frame.enabled = false;
                }
            }
            catch (Exception ex)
            {
                Logger.log.Error(ex);
            }
        }
コード例 #10
0
        public bool updateCustomMaterial(CustomMaterialViewModel customMaterialViewModel)
        {
            int count = 0;

            using (Entities.Entities ctx = new Entities.Entities())
            {
                CustomMaterial customMatrailEntity = ctx.CustomMaterials.Find(customMaterialViewModel.CustomMaterialID);

                customMatrailEntity.ReciveDate       = customMaterialViewModel.ReciveDate;
                customMatrailEntity.Name             = customMaterialViewModel.Name;
                customMatrailEntity.Description      = customMaterialViewModel.Description;
                customMatrailEntity.Cost             = customMaterialViewModel.Cost;
                customMatrailEntity.Payed            = customMaterialViewModel.payed == 1 ? true : false;
                ctx.Entry(customMatrailEntity).State = System.Data.Entity.EntityState.Modified;
                count = ctx.SaveChanges();
            }
            return(count > 0 ? true : false);
        }
コード例 #11
0
        public static void Init()
        {
            ShadowFilter.Init();

            GFXStateBlockData BL_ProjectedShadowSBData = new GFXStateBlockData("BL_ProjectedShadowSBData")
            {
                BlendDefined      = true,
                BlendEnable       = true,
                BlendSrc          = GFXBlend.GFXBlendDestColor,
                BlendDest         = GFXBlend.GFXBlendZero,
                ZDefined          = true,
                ZEnable           = true,
                ZWriteEnable      = false,
                SamplersDefined   = true,
                SamplerStates     = { [0] = CommonMaterialData.SamplerClampLinear },
                VertexColorEnable = true
            };

            BL_ProjectedShadowSBData.registerSingleton();

            new ShaderData("BL_ProjectedShadowShaderData")
            {
                DXVertexShaderFile  = "data/shaders/common/projectedShadowV.hlsl",
                DXPixelShaderFile   = "data/shaders/common/projectedShadowP.hlsl",
                OGLVertexShaderFile = "data/shaders/common/gl/projectedShadowV.glsl",
                OGLPixelShaderFile  = "data/shaders/common/gl/projectedShadowP.glsl",

                SamplerNames = { [0] = "inputTex" },

                PixVersion = 2.0f
            }.registerSingleton();

            CustomMaterial BL_ProjectedShadowMaterial = new CustomMaterial("BL_ProjectedShadowMaterial")
            {
                Shader     = "BL_ProjectedShadowShaderData",
                StateBlock = BL_ProjectedShadowSBData,
                Version    = 2.0f,
                ForwardLit = true
            };

            BL_ProjectedShadowMaterial.setFieldValue("sampler[inputTex]", "$miscbuff");
            BL_ProjectedShadowMaterial.registerSingleton();
        }
コード例 #12
0
        private static IList <CustomMaterial> LoadCustomMaterials(IEnumerable <string> customMaterialFiles)
        {
            IList <CustomMaterial> customMaterials = new List <CustomMaterial>
            {
                new CustomMaterial("DefaultMaterials"),
            };

            IEnumerable <string> embeddedFiles = new List <string>
            {
                "MysticalSnowWalls.pixie",
                "PixelWalls.pixie",
                "PlainWalls.pixie",
                "TransparentWalls.pixie"
            };

            foreach (string embeddedFile in embeddedFiles)
            {
                CustomMaterial customMaterial = LoadEmbeddedMaterial(embeddedFile);
                if (customMaterial != null)
                {
                    customMaterials.Add(customMaterial);
                }
            }

            foreach (string customMaterialFile in customMaterialFiles)
            {
                try
                {
                    CustomMaterial newMaterial = new CustomMaterial(customMaterialFile);
                    if (newMaterial != null)
                    {
                        customMaterials.Add(newMaterial);
                    }
                }
                catch (Exception ex)
                {
                    Logger.log.Warn($"Failed to load Custom Wall with name '{customMaterialFile}'.");
                    Logger.log.Warn(ex);
                }
            }

            return(customMaterials);
        }
コード例 #13
0
ファイル: ShadowViz.cs プロジェクト: lukaspj/Torque-BaseGame
        public static void Init()
        {
            ShaderData AL_ShadowVisualizeShader = new ShaderData("AL_ShadowVisualizeShader")
            {
                DXVertexShaderFile  = "data/shaders/common/guiMaterialV.hlsl",
                DXPixelShaderFile   = "data/shaders/common/lighting/advanced/dbgShadowVisualizeP.hlsl",
                OGLVertexShaderFile = "data/shaders/common/gl/guiMaterialV.glsl",
                OGLPixelShaderFile  = "data/shaders/common/lighting/advanced/gl/dbgShadowVisualizeP.glsl",
                SamplerNames        =
                {
                    [0] = "$shadowMap",
                    [1] = "$depthViz"
                },
                PixVersion = 2.0f
            };

            AL_ShadowVisualizeShader.registerSingleton();

            CustomMaterial AL_ShadowVisualizeMaterial = new CustomMaterial("AL_ShadowVisualizeMaterial")
            {
                Shader     = "AL_ShadowVisualizeShader",
                StateBlock = AL_DepthVisualize.AL_DepthVisualizeState,
                //todo PixVersion = 2.0
            };

            AL_ShadowVisualizeMaterial.setFieldValue("sampler[shadowMap]", "#AL_ShadowVizTexture");
            AL_ShadowVisualizeMaterial.setFieldValue("sampler[depthViz]", "depthviz");
            AL_ShadowVisualizeMaterial.registerSingleton();

            GuiControlProfile AL_ShadowLabelTextProfile = new GuiControlProfile("AL_ShadowLabelTextProfile")
            {
                FontColor      = ColorI.BLACK,
                AutoSizeWidth  = true,
                AutoSizeHeight = true,
                Justify        = GuiAlignmentType.Left,
                FontSize       = 14,
            };

            AL_ShadowLabelTextProfile.registerSingleton();
        }
コード例 #14
0
        public bool addNewCustomMaterial(CustomMaterialViewModel customMaterialViewModel)
        {
            int count = 0;

            using (Entities.Entities ctx = new Entities.Entities())
            {
                CustomMaterial customMatrailEntity = ctx.CustomMaterials.Create();

                customMatrailEntity.DoctorID    = customMaterialViewModel.DoctorID;
                customMatrailEntity.PatientID   = customMaterialViewModel.PatientID;
                customMatrailEntity.RequestDate = customMaterialViewModel.RequestDate;
                customMatrailEntity.Name        = customMaterialViewModel.Name;
                customMatrailEntity.Description = customMaterialViewModel.Description;
                customMatrailEntity.Cost        = customMaterialViewModel.Cost;
                customMatrailEntity.ClinicID    = customMaterialViewModel.clinecid;
                customMatrailEntity.Payed       = false;

                ctx.CustomMaterials.Add(customMatrailEntity);
                count = ctx.SaveChanges();
            }
            return(count > 0 ? true : false);
        }
コード例 #15
0
        public static void Init()
        {
            // Vector Light State
            GFXStateBlockData AL_VectorLightState = new GFXStateBlockData("AL_VectorLightState")
            {
                BlendDefined    = true,
                BlendEnable     = true,
                BlendSrc        = GFXBlend.GFXBlendOne,
                BlendDest       = GFXBlend.GFXBlendOne,
                BlendOp         = GFXBlendOp.GFXBlendOpAdd,
                ZDefined        = true,
                ZEnable         = false,
                ZWriteEnable    = false,
                SamplersDefined = true,
                SamplerStates   =
                {
                    [0] = CommonMaterialData.SamplerClampPoint, // G-buffer
                    // Shadow Map (Do not change this to linear, as all cards can not filter equally.)
                    [1] = CommonMaterialData.SamplerClampPoint,
                    [2] = CommonMaterialData.SamplerClampLinear, // SSAO Mask
                    [3] = CommonMaterialData.SamplerWrapPoint    // Random Direction Map
                },
                CullDefined    = true,
                CullMode       = GFXCullMode.GFXCullNone,
                StencilDefined = true,
                StencilEnable  = true,
                StencilFailOp  = GFXStencilOp.GFXStencilOpKeep,
                StencilZFailOp = GFXStencilOp.GFXStencilOpKeep,
                StencilPassOp  = GFXStencilOp.GFXStencilOpKeep,
                StencilFunc    = GFXCmpFunc.GFXCmpLess,
                StencilRef     = 0
            };

            AL_VectorLightState.setFieldValue("mSamplerNames[0]", "prePassBuffer"); //todo not used anywhere
            AL_VectorLightState.setFieldValue("mSamplerNames[1]", "shadowMap");
            AL_VectorLightState.setFieldValue("mSamplerNames[2]", "ssaoMask");
            AL_VectorLightState.registerSingleton();

            // Vector Light Material
            ShaderData AL_VectorLightShader = new ShaderData("AL_VectorLightShader")
            {
                DXVertexShaderFile  = Globals.GetString("Core::CommonShaderPath") + "/lighting/advanced/farFrustumQuadV.hlsl",
                DXPixelShaderFile   = Globals.GetString("Core::CommonShaderPath") + "/lighting/advanced/vectorLightP.hlsl",
                OGLVertexShaderFile =
                    Globals.GetString("Core::CommonShaderPath") + "/lighting/advanced/gl/farFrustumQuadV.glsl",
                OGLPixelShaderFile = Globals.GetString("Core::CommonShaderPath") + "/lighting/advanced/gl/vectorLightP.glsl",
                SamplerNames       =
                {
                    [0] = "$prePassBuffer",
                    [1] = "$shadowMap",
                    [2] = "$dynamicShadowMap",
                    [3] = "$ssaoMask",
                    [4] = "$gTapRotationTex",
                    [5] = "$lightBuffer",
                    [6] = "$colorBuffer",
                    [7] = "$matInfoBuffer"
                },
                PixVersion = 3.0f
            };

            AL_VectorLightShader.registerSingleton();

            CustomMaterial AL_VectorLightMaterial = new CustomMaterial("AL_VectorLightMaterial")
            {
                Shader     = "AL_VectorLightShader",
                StateBlock = AL_VectorLightState,
                Target     = "lightinfo"

                             //todo pixVersion 3.0f
            };

            AL_VectorLightMaterial.setFieldValue("sampler[prepassBuffer]", "#prepass");
            AL_VectorLightMaterial.setFieldValue("sampler[shadowMap]", "$dynamiclight");
            AL_VectorLightMaterial.setFieldValue("sampler[dynamicShadowMap]", "$dynamicShadowMap");
            AL_VectorLightMaterial.setFieldValue("sampler[ssaoMask]", "#ssaoMask");
            AL_VectorLightMaterial.setFieldValue("sampler[lightBuffer]", "#lightinfo");
            AL_VectorLightMaterial.setFieldValue("sampler[colorBuffer]", "#color");
            AL_VectorLightMaterial.setFieldValue("sampler[matInfoBuffer]", "#matinfo");
            AL_VectorLightMaterial.registerSingleton();

            //------------------------------------------------------------------------------

            // Convex-geometry light states
            GFXStateBlockData AL_ConvexLightState = new GFXStateBlockData("AL_ConvexLightState")
            {
                BlendDefined    = true,
                BlendEnable     = true,
                BlendSrc        = GFXBlend.GFXBlendOne,
                BlendDest       = GFXBlend.GFXBlendOne,
                BlendOp         = GFXBlendOp.GFXBlendOpAdd,
                ZDefined        = true,
                ZEnable         = true,
                ZWriteEnable    = false,
                SamplersDefined = true,
                SamplerStates   =
                {
                    [0] = CommonMaterialData.SamplerClampPoint, // G-buffer
                    [1] = CommonMaterialData.SamplerClampPoint,
                    // Shadow Map (Do not use linear, these are perspective projections)
                    [2] = CommonMaterialData.SamplerClampLinear, // Cookie Map
                    [3] = CommonMaterialData.SamplerWrapPoint    // Random Direction Map
                },
                CullDefined    = true,
                CullMode       = GFXCullMode.GFXCullCW,
                StencilDefined = true,
                StencilEnable  = true,
                StencilFailOp  = GFXStencilOp.GFXStencilOpKeep,
                StencilZFailOp = GFXStencilOp.GFXStencilOpKeep,
                StencilPassOp  = GFXStencilOp.GFXStencilOpKeep,
                StencilFunc    = GFXCmpFunc.GFXCmpLess,
                StencilRef     = 0
            };

            AL_ConvexLightState.setFieldValue("mSamplerNames[0]", "prePassBuffer");
            AL_ConvexLightState.setFieldValue("mSamplerNames[1]", "shadowMap");
            AL_ConvexLightState.registerSingleton();


            // Point Light Material
            ShaderData AL_PointLightShader = new ShaderData("AL_PointLightShader")
            {
                DXVertexShaderFile  = Globals.GetString("Core::CommonShaderPath") + "/lighting/advanced/farFrustumQuadV.hlsl",
                DXPixelShaderFile   = Globals.GetString("Core::CommonShaderPath") + "/lighting/advanced/pointLightP.hlsl",
                OGLVertexShaderFile =
                    Globals.GetString("Core::CommonShaderPath") + "/lighting/advanced/gl/farFrustumQuadV.glsl",
                OGLPixelShaderFile = Globals.GetString("Core::CommonShaderPath") + "/lighting/advanced/gl/pointLightP.glsl",
                SamplerNames       =
                {
                    [0] = "$prePassBuffer",
                    [1] = "$shadowMap",
                    [2] = "$dynamicShadowMap",
                    [3] = "cookieMap",
                    [4] = "$gTapRotationTex",
                    [5] = "$lightBuffer",
                    [6] = "$colorBuffer",
                    [7] = "$matInfoBuffer"
                },
                PixVersion = 3.0f
            };

            AL_PointLightShader.registerSingleton();

            CustomMaterial AL_PointLightMaterial = new CustomMaterial("AL_PointLightMaterial")
            {
                Shader     = "AL_PointLightShader",
                StateBlock = AL_ConvexLightState,
                Target     = "lightinfo"

                             //todo pixVersion 3.0f
            };

            AL_PointLightMaterial.setFieldValue("sampler[prepassBuffer]", "#prepass");
            AL_PointLightMaterial.setFieldValue("sampler[shadowMap]", "$dynamiclight");
            AL_PointLightMaterial.setFieldValue("sampler[dynamicShadowMap]", "$dynamicShadowMap");
            AL_PointLightMaterial.setFieldValue("sampler[cookieMap]", "$dynamiclightmask");
            AL_PointLightMaterial.setFieldValue("sampler[lightBuffer]", "#lightinfo");
            AL_PointLightMaterial.setFieldValue("sampler[colorBuffer]", "#color");
            AL_PointLightMaterial.setFieldValue("sampler[matInfoBuffer]", "#matinfo");
            AL_PointLightMaterial.registerSingleton();


            // Spot Light Material
            ShaderData AL_SpotLightShader = new ShaderData("AL_SpotLightShader")
            {
                DXVertexShaderFile  = Globals.GetString("Core::CommonShaderPath") + "/lighting/advanced/farFrustumQuadV.hlsl",
                DXPixelShaderFile   = Globals.GetString("Core::CommonShaderPath") + "/lighting/advanced/spotLightP.hlsl",
                OGLVertexShaderFile =
                    Globals.GetString("Core::CommonShaderPath") + "/lighting/advanced/gl/farFrustumQuadV.glsl",
                OGLPixelShaderFile = Globals.GetString("Core::CommonShaderPath") + "/lighting/advanced/gl/spotLightP.glsl",
                SamplerNames       =
                {
                    [0] = "$prePassBuffer",
                    [1] = "$shadowMap",
                    [2] = "$dynamicShadowMap",
                    [3] = "cookieMap",
                    [4] = "$gTapRotationTex",
                    [5] = "$lightBuffer",
                    [6] = "$colorBuffer",
                    [7] = "$matInfoBuffer"
                },
                PixVersion = 3.0f
            };

            AL_SpotLightShader.registerSingleton();

            CustomMaterial AL_SpotLightMaterial = new CustomMaterial("AL_SpotLightMaterial")
            {
                Shader     = "AL_SpotLightShader",
                StateBlock = AL_ConvexLightState,
                Target     = "lightinfo"

                             //todo pixVersion 3.0f
            };

            AL_SpotLightMaterial.setFieldValue("sampler[prepassBuffer]", "#prepass");
            AL_SpotLightMaterial.setFieldValue("sampler[shadowMap]", "$dynamiclight");
            AL_SpotLightMaterial.setFieldValue("sampler[dynamicShadowMap]", "$dynamicShadowMap");
            AL_SpotLightMaterial.setFieldValue("sampler[cookieMap]", "$dynamiclightmask");
            AL_SpotLightMaterial.setFieldValue("sampler[lightBuffer]", "#lightinfo");
            AL_SpotLightMaterial.setFieldValue("sampler[colorBuffer]", "#color");
            AL_SpotLightMaterial.setFieldValue("sampler[matInfoBuffer]", "#matinfo");
            AL_SpotLightMaterial.registerSingleton();

            // This material is used for generating prepass
            // materials for objects that do not have materials.
            Material AL_DefaultPrePassMaterial = new Material("AL_DefaultPrePassMaterial")
            {
                // We need something in the first pass else it
                // won't create a proper material instance.
                //
                // We use color here because some objects may not
                // have texture coords in their vertex format...
                // for example like terrain.
                //
                DiffuseColor = { [0] = ColorF.WHITE }
            };

            AL_DefaultPrePassMaterial.registerSingleton();

            // This material is used for generating shadow
            // materials for objects that do not have materials.
            Material AL_DefaultShadowMaterial = new Material("AL_DefaultShadowMaterial")
            {
                // We need something in the first pass else it
                // won't create a proper material instance.
                //
                // We use color here because some objects may not
                // have texture coords in their vertex format...
                // for example like terrain.
                //
                DiffuseColor = { [0] = ColorF.WHITE },

                // This is here mostly for terrain which uses
                // this material to create its shadow material.
                //
                // At sunset/sunrise the sun is looking thru
                // backsides of the terrain which often are not
                // closed.  By changing the material to be double
                // sided we avoid holes in the shadowed geometry.
                //
                DoubleSided = true
            };

            AL_DefaultShadowMaterial.registerSingleton();

            // Particle System Point Light Material
            ShaderData AL_ParticlePointLightShader = new ShaderData("AL_ParticlePointLightShader")
            {
                DXVertexShaderFile =
                    Globals.GetString("Core::CommonShaderPath") + "/lighting/advanced/particlePointLightV.hlsl",
                DXPixelShaderFile =
                    Globals.GetString("Core::CommonShaderPath") + "/lighting/advanced/particlePointLightP.hlsl",
                OGLVertexShaderFile =
                    Globals.GetString("Core::CommonShaderPath") + "/lighting/advanced/gl/convexGeometryV.glsl",
                OGLPixelShaderFile = Globals.GetString("Core::CommonShaderPath") + "/lighting/advanced/gl/pointLightP.glsl",
                SamplerNames       = { [0] = "$prePassBuffer" }

                //todo pixVersion = 3.0,
            };

            AL_ParticlePointLightShader.registerSingleton();

            CustomMaterial AL_ParticlePointLightMaterial = new CustomMaterial("AL_ParticlePointLightMaterial")
            {
                Shader     = "AL_ParticlePointLightShader",
                StateBlock = AL_ConvexLightState,
                Target     = "lightinfo"

                             //todo PixVersion = 3.0
            };

            AL_ParticlePointLightMaterial.setFieldValue("Sampler[prePassBuffer]", "#prepass");
            AL_ParticlePointLightMaterial.registerSingleton();
        }
コード例 #16
0
        public static void Init()
        {
            //-----------------------------------------------------------------------------
            // Water
            //-----------------------------------------------------------------------------

            ShaderData WaterShader = new ShaderData("WaterShader")
            {
                DXVertexShaderFile  = Globals.GetString("Core::CommonShaderPath") + "/water/waterV.hlsl",
                DXPixelShaderFile   = Globals.GetString("Core::CommonShaderPath") + "/water/waterP.hlsl",
                OGLVertexShaderFile = Globals.GetString("Core::CommonShaderPath") + "/water/gl/waterV.glsl",
                OGLPixelShaderFile  = Globals.GetString("Core::CommonShaderPath") + "/water/gl/waterP.glsl",
                SamplerNames        =
                {
                    [0] = "$bumpMap",     // noise
                    [1] = "$prepassTex",  // #prepass
                    [2] = "$reflectMap",  // $reflectbuff
                    [3] = "$refractBuff", // $backbuff
                    [4] = "$skyMap",      // $cubemap
                    [5] = "$foamMap",     // foam
                    [6] = "$depthGradMap" // depthMap ( color gradient )
                },

                PixVersion = 3.0f
            };

            WaterShader.registerSingleton();

            GFXSamplerStateData WaterSampler = new GFXSamplerStateData("WaterSampler")
            {
                TextureColorOp = GFXTextureOp.GFXTOPModulate,
                AddressModeU   = GFXTextureAddressMode.GFXAddressWrap,
                AddressModeV   = GFXTextureAddressMode.GFXAddressWrap,
                AddressModeW   = GFXTextureAddressMode.GFXAddressWrap,
                MagFilter      = GFXTextureFilterType.GFXTextureFilterLinear,
                MinFilter      = GFXTextureFilterType.GFXTextureFilterAnisotropic,
                MipFilter      = GFXTextureFilterType.GFXTextureFilterLinear,
                MaxAnisotropy  = 4
            };

            WaterSampler.registerSingleton();

            GFXStateBlockData WaterStateBlock = new GFXStateBlockData("WaterStateBlock")
            {
                SamplersDefined = true,
                SamplerStates   =
                {
                    [0] = WaterSampler,                          // noise
                    [1] = CommonMaterialData.SamplerClampPoint,  // #prepass
                    [2] = CommonMaterialData.SamplerClampLinear, // $reflectbuff
                    [3] = CommonMaterialData.SamplerClampPoint,  // $backbuff
                    [4] = CommonMaterialData.SamplerWrapLinear,  // $cubemap
                    [5] = CommonMaterialData.SamplerWrapLinear,  // foam
                    [6] = CommonMaterialData.SamplerClampLinear  // depthMap ( color gradient )
                },
                CullDefined = true,
                CullMode    = GFXCullMode.GFXCullCCW
            };

            WaterStateBlock.registerSingleton();

            GFXStateBlockData UnderWaterStateBlock = new GFXStateBlockData("UnderWaterStateBlock", WaterStateBlock)
            {
                CullMode = GFXCullMode.GFXCullCCW
            };

            UnderWaterStateBlock.registerSingleton();

            CustomMaterial WaterMat = new CustomMaterial("WaterMat")
            {
                Shader         = "WaterShader",
                StateBlock     = WaterStateBlock,
                Version        = 3.0f,
                UseAnisotropic = { [0] = true }
            };

            WaterMat.setFieldValue("sampler[prepassTex]", "#prepass");
            WaterMat.setFieldValue("sampler[reflectMap]", "$reflectbuff");
            WaterMat.setFieldValue("sampler[refractBuff]", "$backbuff");
            // These samplers are set in code not here.
            // This is to allow different WaterObject instances
            // to use this same material but override these textures
            // per instance.
            //sampler["bumpMap"] = "";
            //sampler["skyMap"] = "";
            //sampler["foamMap"] = "";
            //sampler["depthGradMap"] = "";
            WaterMat.registerSingleton();

            //-----------------------------------------------------------------------------
            // Underwater
            //-----------------------------------------------------------------------------

            new ShaderData("UnderWaterShader", WaterShader)
            {
                Defines = "UNDERWATER"
            }.registerSingleton();

            CustomMaterial UnderwaterMat = new CustomMaterial("UnderwaterMat")
            {
                // These samplers are set in code not here.
                // This is to allow different WaterObject instances
                // to use this same material but override these textures
                // per instance.
                //sampler["bumpMap"] = "art/images/water/noise02";
                //sampler["foamMap"] = "art/images/water/foam";

                Shader        = "UnderWaterShader",
                StateBlock    = UnderWaterStateBlock,
                Specular      = { [0] = new ColorF(0.75f, 0.75f, 0.75f, 1.0f) },
                SpecularPower = { [0] = 48.0f },
                Version       = 3.0f
            };

            UnderwaterMat.setFieldValue("sampler[prepassTex]", "#prepass");
            UnderwaterMat.setFieldValue("sampler[refractBuff]", "$backbuff");
            UnderwaterMat.registerSingleton();

            //-----------------------------------------------------------------------------
            // Basic Water
            //-----------------------------------------------------------------------------

            ShaderData WaterBasicShader = new ShaderData("WaterBasicShader")
            {
                DXVertexShaderFile  = Globals.GetString("Core::CommonShaderPath") + "/water/waterBasicV.hlsl",
                DXPixelShaderFile   = Globals.GetString("Core::CommonShaderPath") + "/water/waterBasicP.hlsl",
                OGLVertexShaderFile = Globals.GetString("Core::CommonShaderPath") + "/water/gl/waterBasicV.glsl",
                OGLPixelShaderFile  = Globals.GetString("Core::CommonShaderPath") + "/water/gl/waterBasicP.glsl",
                SamplerNames        =
                {
                    [0] = "$bumpMap",
                    [2] = "$reflectMap",
                    [3] = "$refractBuff",
                    [4] = "$skyMap",
                    [5] = "$depthGradMap"
                },
                PixVersion = 2.0f
            };

            WaterBasicShader.registerSingleton();

            GFXStateBlockData WaterBasicStateBlock = new GFXStateBlockData("WaterBasicStateBlock")
            {
                SamplersDefined = true,
                SamplerStates   =
                {
                    [0] = WaterSampler,                          // noise
                    [2] = CommonMaterialData.SamplerClampLinear, // $reflectbuff
                    [3] = CommonMaterialData.SamplerClampPoint,  // $backbuff
                    [4] = CommonMaterialData.SamplerWrapLinear   // $cubemap
                },
                CullDefined = true,
                CullMode    = GFXCullMode.GFXCullCCW
            };

            WaterBasicStateBlock.registerSingleton();

            GFXStateBlockData UnderWaterBasicStateBlock = new GFXStateBlockData("UnderWaterBasicStateBlock",
                                                                                WaterBasicStateBlock)
            {
                CullMode = GFXCullMode.GFXCullCCW
            };

            UnderWaterBasicStateBlock.registerSingleton();

            CustomMaterial WaterBasicMat = new CustomMaterial("WaterBasicMat")
            {
                // These samplers are set in code not here.
                // This is to allow different WaterObject instances
                // to use this same material but override these textures
                // per instance.
                //sampler["bumpMap"] = "art/images/water/noise02";
                //sampler["skyMap"] = "$cubemap";

                //sampler["prepassTex"] = "#prepass";

                Cubemap    = "NewLevelSkyCubemap",
                Shader     = "WaterBasicShader",
                StateBlock = WaterBasicStateBlock,
                Version    = 2.0f
            };

            WaterBasicMat.setFieldValue("sampler[reflectMap]", "$reflectbuff");
            WaterBasicMat.setFieldValue("sampler[refractBuff]", "$backbuff");
            WaterBasicMat.registerSingleton();

            //-----------------------------------------------------------------------------
            // Basic UnderWater
            //-----------------------------------------------------------------------------

            new ShaderData("UnderWaterBasicShader", WaterBasicShader)
            {
                Defines = "UNDERWATER"
            }.registerSingleton();

            CustomMaterial UnderwaterBasicMat = new CustomMaterial("UnderwaterBasicMat")
            {
                // These samplers are set in code not here.
                // This is to allow different WaterObject instances
                // to use this same material but override these textures
                // per instance.
                //sampler["bumpMap"] = "art/images/water/noise02";
                //samplers["skyMap"] = "$cubemap";

                //sampler["prepassTex"] = "#prepass";

                Shader     = "UnderWaterBasicShader",
                StateBlock = UnderWaterBasicStateBlock,
                Version    = 2.0f
            };

            UnderwaterBasicMat.setFieldValue("sampler[refractBuff]", "$backbuff");
            UnderwaterBasicMat.registerSingleton();
        }