Ejemplo n.º 1
0
        static int CreateProjectInitializeScript(ProjectInitialization opts)
        {
            int returnCode = 0;
            var logger     = GetLogger();

            logger.Information($"Project  : {opts.ProjectName}");
            logger.Information($"Directory: {opts.DirectoryName}");

            do
            {
                try
                {
                    ProjectInitializationProcess process = new ProjectInitializationProcess(logger, opts);
                    returnCode = process.Execute();
                    if (returnCode != 0)
                    {
                        break;
                    }
                }
                catch (Exception exception)
                {
                    logger.Error(exception, "CreateProjectInitializeScript, unhandled exception caught.");
                    returnCode = -1;
                    break;
                }
            } while(false);

            return(returnCode);
        }
Ejemplo n.º 2
0
    void Initialize()
    {
        var light = GameObject.Find("Directional Light");

        if (light == null)
        {
            return;
        }

        m_LightingInfoDefinition = DatasetCapture.RegisterMetricDefinition("lighting info", "Per-frame light color and orientation", id: k_LightingInfoGuid);
        m_Light = light.GetComponent <Light>();
        // To simulate phong shading we turn off shadows
        m_Light.shadows = LightShadows.None;
        m_IsInitialized = true;


        // Try to find game object here because scene may not be initialized on Create()
        if (m_InitParams == null)
        {
            m_InitParams = GameObject.Find("Management")?.GetComponentInChildren <ProjectInitialization>();
            if (m_InitParams == null)
            {
                Debug.LogWarning("Unable to find Management object. Will not randomize lighting.");
                return;
            }
        }
    }
Ejemplo n.º 3
0
        public ProjectInitializationProcess(ILogger logger, ProjectInitialization options)
        {
            _logger  = logger;
            _options = options;

            if (!_options.DirectoryName.EndsWith("/"))
            {
                _options.DirectoryName = _options.DirectoryName + "/";
            }
        }
    public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData)
    {
        #if UNITY_EDITOR
        if (!RenderInEditor && !EditorApplication.isPlaying)
        {
            return;
        }
        #endif

        // Initialize here because scene is not guaranteed to be initialized when Create is called
        if (m_InitParams == null)
        {
            m_InitParams = GameObject.Find("Management")?.GetComponentInChildren <ProjectInitialization>();
            if (m_InitParams == null)
            {
                Debug.LogWarning("Unable to find Management object. Will not render this pass. " +
                                 "(You can disable this feature in Assets/RenderFeatures/ForwardRenderer/RandomizedPostProcessing");
                return;
            }

            m_ShadersWereFound = true;
            var blurShader = Shader.Find(k_BlurShader);
            if (blurShader != null)
            {
                m_BlurMaterial = new Material(blurShader);
            }
            else
            {
                m_ShadersWereFound = false;
            }

            var noiseShader = Shader.Find(k_NoiseShader);
            if (noiseShader != null)
            {
                m_NoiseMaterial = new Material(noiseShader);
            }
            else
            {
                m_ShadersWereFound = false;
            }

            if (!m_ShadersWereFound)
            {
                Debug.LogError(
                    $"{nameof(RandomizedPostProcessingFeature)} couldn't find its shaders and will not render.");
            }
        }

        if (!m_ShadersWereFound)
        {
            return;
        }

        var p          = m_InitParams.AppParameters;
        var kernelSize = RenderMaxStrength ? p.BlurKernelSizeMax : m_Rand.NextFloat(0f, p.BlurKernelSizeMax);
        var stdDev     = (RenderMaxStrength ? p.BlurStandardDeviationMax :
                          m_Rand.NextFloat(0f, p.BlurStandardDeviationMax)) * kernelSize;
        var noiseStrength = RenderMaxStrength ? p.NoiseStrengthMax : m_Rand.NextFloat(0f, p.NoiseStrengthMax);

        if (Application.isPlaying)
        {
            var metric = new PostProcessingValues
            {
                blur_kernel_size_uv = kernelSize,
                blur_std_dev_uv     = stdDev,
                noise_strength      = noiseStrength
            };
            SimulationManager.ReportMetric(m_PostProcessValuesMetric, new[] { metric });
        }

        m_RenderPass.Update(m_BlurMaterial, m_NoiseMaterial, RenderEvent,
                            renderer.cameraColorTarget, kernelSize, stdDev, noiseStrength);
        renderer.EnqueuePass(m_RenderPass);
    }
    public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData)
    {
        #if UNITY_EDITOR
        if (!RenderInEditor && !EditorApplication.isPlaying)
        {
            return;
        }
        #endif

        // When SynthDet is being ran in visualization mode, a second camera is created to display the scene. The first
        // camera (which contains the perception camera) renders the scene to a render texture, and a second camera
        // displays the render texture along with all visualization components. We do not one the custom passes applied
        // to the visualized contents, only the contents that are used by the perception camera. In a scene without
        // visualization only one camera (the perception camera) is available and so that case will bypass this check
        if (renderingData.cameraData.camera.GetComponent <PerceptionCamera>() == null)
        {
            return;
        }

        // Initialize here because scene is not guaranteed to be initialized when Create is called
        if (m_InitParams == null)
        {
            m_InitParams = GameObject.Find("Management")?.GetComponentInChildren <ProjectInitialization>();
            if (m_InitParams == null)
            {
                Debug.LogWarning("Unable to find Management object. Will not render this pass. " +
                                 "(You can disable this feature in Assets/RenderFeatures/ForwardRenderer/RandomizedPostProcessing");
                return;
            }

            m_ShadersWereFound = true;
            var blurShader = Shader.Find(k_BlurShader);
            if (blurShader != null)
            {
                m_BlurMaterial = new Material(blurShader);
            }
            else
            {
                m_ShadersWereFound = false;
            }

            var noiseShader = Shader.Find(k_NoiseShader);
            if (noiseShader != null)
            {
                m_NoiseMaterial = new Material(noiseShader);
            }
            else
            {
                m_ShadersWereFound = false;
            }

            if (!m_ShadersWereFound)
            {
                Debug.LogError(
                    $"{nameof(RandomizedPostProcessingFeature)} couldn't find its shaders and will not render.");
            }
        }

        if (!m_ShadersWereFound)
        {
            return;
        }

        var p          = m_InitParams.AppParameters;
        var kernelSize = RenderMaxStrength ? p.BlurKernelSizeMax : m_Rand.NextFloat(0f, p.BlurKernelSizeMax);
        var stdDev     = (RenderMaxStrength ? p.BlurStandardDeviationMax :
                          m_Rand.NextFloat(0f, p.BlurStandardDeviationMax)) * kernelSize;
        var noiseStrength = RenderMaxStrength ? p.NoiseStrengthMax : m_Rand.NextFloat(0f, p.NoiseStrengthMax);

        if (Application.isPlaying)
        {
            var metric = new PostProcessingValues
            {
                blur_kernel_size_uv = kernelSize,
                blur_std_dev_uv     = stdDev,
                noise_strength      = noiseStrength
            };
            DatasetCapture.ReportMetric(m_PostProcessValuesMetric, new[] { metric });
        }

        m_RenderPass.Update(m_BlurMaterial, m_NoiseMaterial, RenderEvent,
                            renderer.cameraColorTarget, kernelSize, stdDev, noiseStrength);
        renderer.EnqueuePass(m_RenderPass);
    }