protected override void OnResultCompile() { base.OnResultCompile(); if (!IsSupported) { return; } if (Result != null) { return; } var result = new CompiledDataSimple(); //!!!!temp? надо ли знать о создателе? пока сделано, чтобы параметры материала получить result.owner = this; //!!!! EngineThreading.ExecuteFromMainThreadWait(delegate() { //generate compile arguments var vertexDefines = new List <(string, string)>(); var fragmentDefines = new List <(string, string)>(); { //var generalDefines = new List<Tuple<string, string>>(); //generalDefines.Add( Tuple.Create( "LIGHTTYPE_" + lightType.ToString().ToUpper(), "" ) ); //vertexDefines.AddRange( generalDefines ); //fragmentDefines.AddRange( generalDefines ); } { string shaderFileName = Shader; if (string.IsNullOrEmpty(shaderFileName)) { return; } string error2; //vertex program var vertexProgram = GpuProgramManager.GetProgram("RenderingEffect_Simple_Vertex_", GpuProgramType.Vertex, @"Base\Shaders\EffectsCommon_vs.sc", /*"main_vp", */ vertexDefines, out error2); if (!string.IsNullOrEmpty(error2)) { result.error = GpuProgramManager.GetGpuProgramCompilationErrorText(this, error2); Log.Warning(result.error); result.Dispose(); return; } //fragment program var fragmentProgram = GpuProgramManager.GetProgram("RenderingEffect_Simple_Fragment_", GpuProgramType.Fragment, shaderFileName, /*"main_fp", */ fragmentDefines, out error2); if (!string.IsNullOrEmpty(error2)) { result.error = GpuProgramManager.GetGpuProgramCompilationErrorText(this, error2); Log.Warning(result.error); result.Dispose(); return; } result.vertexProgram = vertexProgram; result.fragmentProgram = fragmentProgram; //standard material architecture: //var pass = GpuMaterialPass.CreatePass( vertexProgram, fragmentProgram ); //result.AllPasses.Add( pass ); //pass.SourceBlendFactor = SceneBlendFactor.One; //pass.DestBlendFactor = SceneBlendFactor.Zero; } }); Result = result; }
protected override void OnResultCompile() { base.OnResultCompile(); if (!IsSupported) { return; } if (Result != null) { return; } var result = new CompiledDataCodeGenerated(); //!!!!temp? надо ли знать о создателе? пока сделано, чтобы параметры материала получить result.owner = this; //!!!! EngineThreading.ExecuteFromMainThreadWait(delegate() { //shader generation if (shaderGenerationCompile) { if (!GenerateCode(result)) { return; } } //generate compile arguments var vertexDefines = new List <(string, string)>(); var fragmentDefines = new List <(string, string)>(); { //var generalDefines = new List<(string, string)>(); //generalDefines.Add( ( "LIGHTTYPE_" + lightType.ToString().ToUpper(), "" ) ); //vertexDefines.AddRange( generalDefines ); //fragmentDefines.AddRange( generalDefines ); if (shaderGenerationEnable) { ////vertex //var vertexCode = result.vertexGeneratedCode; //if( vertexCode != null ) //{ // if( !string.IsNullOrEmpty( vertexCode.parametersBody ) ) // vertexDefines.Add( ( "VERTEX_CODE_PARAMETERS", vertexCode.parametersBody ) ); // if( !string.IsNullOrEmpty( vertexCode.samplersBody ) ) // vertexDefines.Add( ( "VERTEX_CODE_SAMPLERS", vertexCode.samplersBody ) ); // if( !string.IsNullOrEmpty( vertexCode.codeBody ) ) // vertexDefines.Add( ( "VERTEX_CODE_BODY", vertexCode.codeBody ) ); //} //fragment var fragmentCode = result.fragmentGeneratedCode; if (fragmentCode != null) { if (!string.IsNullOrEmpty(fragmentCode.parametersBody)) { fragmentDefines.Add(("FRAGMENT_CODE_PARAMETERS", fragmentCode.parametersBody)); } if (!string.IsNullOrEmpty(fragmentCode.samplersBody)) { fragmentDefines.Add(("FRAGMENT_CODE_SAMPLERS", fragmentCode.samplersBody)); } if (!string.IsNullOrEmpty(fragmentCode.shaderScripts)) { fragmentDefines.Add(("FRAGMENT_CODE_SHADER_SCRIPTS", fragmentCode.shaderScripts)); } if (!string.IsNullOrEmpty(fragmentCode.codeBody)) { fragmentDefines.Add(("FRAGMENT_CODE_BODY", fragmentCode.codeBody)); } } } } { string shaderFileName = Shader; if (string.IsNullOrEmpty(shaderFileName)) { return; } string error2; //vertex program var vertexProgram = GpuProgramManager.GetProgram("RenderingEffect_CodeGenerated_Vertex_", GpuProgramType.Vertex, @"Base\Shaders\EffectsCommon_vs.sc", vertexDefines, out error2); if (!string.IsNullOrEmpty(error2)) { result.error = GpuProgramManager.GetGpuProgramCompilationErrorText(this, error2); Log.Warning(result.error); result.Dispose(); return; } //fragment program var fragmentProgram = GpuProgramManager.GetProgram("RenderingEffect_CodeGenerated_Fragment_", GpuProgramType.Fragment, shaderFileName, fragmentDefines, out error2); if (!string.IsNullOrEmpty(error2)) { result.error = GpuProgramManager.GetGpuProgramCompilationErrorText(this, error2); Log.Warning(result.error); result.Dispose(); return; } result.vertexProgram = vertexProgram; result.fragmentProgram = fragmentProgram; //standard material architecture: //var pass = GpuMaterialPass.CreatePass( vertexProgram, fragmentProgram ); //result.AllPasses.Add( pass ); //pass.SourceBlendFactor = SceneBlendFactor.One; //pass.DestBlendFactor = SceneBlendFactor.Zero; } }); Result = result; }