private static void CollectShaderInfoImpl(CGfxEffectDesc desc, int index) { var cloneDesc = desc.CloneEffectDesc(); GfxEnvShaderCode shadingEnv = cloneDesc.EnvShaderPatch; if (index >= shadingEnv.MacroDefines.Count) { return; } for (int i = index; i < shadingEnv.MacroDefines.Count; i++) { var values = shadingEnv.GetMacroValues(shadingEnv.MacroDefines[i].Name); if (values == null) { continue; } for (int j = 0; j < values.Count; j++) { if (shadingEnv.SetMacroDefineValue(i, values[j])) { cloneDesc.UpdateHash64(true); Hash64 hash; hash = cloneDesc.GetHash64(); var file = CGfxEffectDesc.GetShaderInfoFileName(hash); if (CEngine.Instance.FileManager.FileExists(file) == false) { cloneDesc.SaveXML(null, hash); } CollectShaderInfoImpl(cloneDesc, i + 1); } } } }
private Graphics.CGfxEffect GetEffect(CRenderContext RHICtx, Graphics.GfxEnvShaderCode ShaderEnv, Graphics.CGfxMaterialInstance mtl, Graphics.Mesh.CGfxMesh mesh) { var desc = Graphics.CGfxEffectDesc.CreateDesc(mtl.Material, mesh.MdfQueue, ShaderEnv); return(CEngine.Instance.EffectManager.GetEffect(RHICtx, desc)); }
public void InitCodeOnce(GfxEnvShaderCode code) { var defs = new List <CShaderDefinitions.MacroDefine>(); GetMacroDefines(defs); code.Init(ShadingEnvName, defs, this); OnShadingEnvInit(code); }
public GfxEnvShaderCode CloneEnvShaderCode() { var result = new GfxEnvShaderCode(); result.mEnvType = mEnvType; result.mHash64 = mHash64; result.mShaderName = mShaderName; result.mMacroDefines = new List <CShaderDefinitions.MacroDefine>(); result.mMacroDefines.AddRange(mMacroDefines); result.UpdateHash64(); result.GetMacroValues = GetMacroValues; return(result); }
public EnvType GetGfxShadingEnv <EnvType>() where EnvType : CGfxShadingEnv, new() { CGfxShadingEnv tmp; if (ShadingEnvs.TryGetValue(typeof(EnvType), out tmp)) { return(tmp.CloneShadingEnv() as EnvType); //return tmp as EnvType; } EnvType result = new EnvType(); GfxEnvShaderCode code = new GfxEnvShaderCode(); result.InitCodeOnce(code); if (false == result.Init(code)) { return(null); } ShadingEnvs.Add(typeof(EnvType), result); return(result); }
public static CGfxEffectDesc CreateDesc(CGfxMaterial mtl, Mesh.CGfxMdfQueue mdf, GfxEnvShaderCode shadingenv) { CGfxEffectDesc result = new CGfxEffectDesc(); result.MtlShaderPatch = mtl; result.MdfQueueShaderPatch = mdf.CloneMdfQueue(CEngine.Instance.RenderContext, null); result.EnvShaderPatch = shadingenv; //result.EnvShaderPatch = shadingenv.CloneShadingEnv(); result.UpdateHash64(true); return(result); }
public bool Init(GfxEnvShaderCode code) { mEnvCode = code; OnCreated(); return(true); }
protected virtual void OnShadingEnvInit(GfxEnvShaderCode code) { }