public LightweightRenderPipeline(LightweightRenderPipelineAsset asset)
        {
            SetSupportedRenderingFeatures();

            PerFrameBuffer._GlossyEnvironmentColor = Shader.PropertyToID("_GlossyEnvironmentColor");
            PerFrameBuffer._SubtractiveShadowColor = Shader.PropertyToID("_SubtractiveShadowColor");

            PerFrameBuffer._Time           = Shader.PropertyToID("_Time");
            PerFrameBuffer._SinTime        = Shader.PropertyToID("_SinTime");
            PerFrameBuffer._CosTime        = Shader.PropertyToID("_CosTime");
            PerFrameBuffer.unity_DeltaTime = Shader.PropertyToID("unity_DeltaTime");
            PerFrameBuffer._TimeParameters = Shader.PropertyToID("_TimeParameters");

            PerCameraBuffer._InvCameraViewProj   = Shader.PropertyToID("_InvCameraViewProj");
            PerCameraBuffer._ScreenParams        = Shader.PropertyToID("_ScreenParams");
            PerCameraBuffer._ScaledScreenParams  = Shader.PropertyToID("_ScaledScreenParams");
            PerCameraBuffer._WorldSpaceCameraPos = Shader.PropertyToID("_WorldSpaceCameraPos");

            // Let engine know we have MSAA on for cases where we support MSAA backbuffer
            if (QualitySettings.antiAliasing != asset.msaaSampleCount)
            {
                QualitySettings.antiAliasing = asset.msaaSampleCount;
            }

            Shader.globalRenderPipeline = "LightweightPipeline";

            Lightmapping.SetDelegate(lightsDelegate);

            CameraCaptureBridge.enabled = true;

            RenderingUtils.ClearSystemInfoCache();
        }
Ejemplo n.º 2
0
        public LightweightRenderPipeline(LightweightRenderPipelineAsset asset)
        {
            settings = PipelineSettings.Create(asset);
            renderer = new ScriptableRenderer(asset);

            SetSupportedRenderingFeatures();

            GraphicsSettings.useScriptableRenderPipelineBatching = asset.useSRPBatcher;

            PerFrameBuffer._GlossyEnvironmentColor = Shader.PropertyToID("_GlossyEnvironmentColor");
            PerFrameBuffer._SubtractiveShadowColor = Shader.PropertyToID("_SubtractiveShadowColor");

            PerCameraBuffer._InvCameraViewProj  = Shader.PropertyToID("_InvCameraViewProj");
            PerCameraBuffer._ScaledScreenParams = Shader.PropertyToID("_ScaledScreenParams");

            // Let engine know we have MSAA on for cases where we support MSAA backbuffer
            if (QualitySettings.antiAliasing != settings.msaaSampleCount)
            {
                QualitySettings.antiAliasing = settings.msaaSampleCount;
            }

            Shader.globalRenderPipeline = "LightweightPipeline";

            Lightmapping.SetDelegate(lightsDelegate);

            CameraCaptureBridge.enabled = true;
        }
    public MyPipeline(bool dynamicBatching, bool instancing, MyPostProcessingStack _defaultStack,
                      Texture2D _ditherTexture, float _ditherAnimationSpeed, int _shadowMapSize, float _shadowDistance
                      , float _shadowFadeRange, int _shadowCascades, Vector3 _shadowCascadeSplit, float _renderScale
                      , int _msaaSamples, bool _allowHDR, bool _syncGameCamera)
    {
        //Unity 认为光的强度是在伽马空间中定义的,即使我们是在线性空间中工作。
        GraphicsSettings.lightsUseLinearIntensity = true;

        //如果Z相反 阴影的z最远是1
        if (SystemInfo.usesReversedZBuffer)
        {
            worldToShadowCascadeMatrices[4].m33 = 1f;
        }

        if (dynamicBatching)
        {
            drawFlags = DrawRendererFlags.EnableDynamicBatching;
        }

        ditherTexture = _ditherTexture;
        if (_ditherAnimationSpeed > 0f)
        {
            ConfigureDitherAnimation(_ditherAnimationSpeed);
        }

        if (instancing)
        {
            drawFlags |= DrawRendererFlags.EnableInstancing;
        }

        defaultStack = _defaultStack;

        shadowMapSize      = _shadowMapSize;
        shadowDistance     = _shadowDistance;
        globalShadowData.y = 1f / _shadowFadeRange;
        shadowCascades     = _shadowCascades;
        shadowCascadeSplit = _shadowCascadeSplit;
        renderScale        = _renderScale;
        //设置msaa 如果硬件不支持 则为自动回退为1
        QualitySettings.antiAliasing = _msaaSamples;
        msaaSamples = Mathf.Max(QualitySettings.antiAliasing, 1);
        allowHDR    = _allowHDR;

#if UNITY_EDITOR
        if (SceneView.onSceneGUIDelegate != null)
        {
            SceneView.onSceneGUIDelegate -= OnSceneView;
        }

        if (_syncGameCamera)
        {
            SceneView.onSceneGUIDelegate += OnSceneView;
        }
#endif

#if UNITY_EDITOR
        Lightmapping.SetDelegate(lightmappingLightDelegate);
#endif
    }
 public override void Dispose()
 {
     base.Dispose();
     if (SceneView.onSceneGUIDelegate != null)
     {
         SceneView.onSceneGUIDelegate -= OnSceneView;
     }
     Lightmapping.ResetDelegate();
 }
        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);
            Shader.globalRenderPipeline       = "";
            SupportedRenderingFeatures.active = new SupportedRenderingFeatures();

#if UNITY_EDITOR
            SceneViewDrawMode.ResetDrawMode();
#endif

            Lightmapping.ResetDelegate();
            CameraCaptureBridge.enabled = false;
        }
Ejemplo n.º 6
0
        public override void Dispose()
        {
            base.Dispose();
            Shader.globalRenderPipeline       = "";
            SupportedRenderingFeatures.active = new SupportedRenderingFeatures();

#if UNITY_EDITOR
            SceneViewDrawMode.ResetDrawMode();
#endif

            renderer.Dispose();

            Lightmapping.ResetDelegate();
        }
Ejemplo n.º 7
0
        public LightweightRenderPipeline(LightweightRenderPipelineAsset asset)
        {
            SetSupportedRenderingFeatures();

            PerFrameBuffer._GlossyEnvironmentColor = Shader.PropertyToID("_GlossyEnvironmentColor");
            PerFrameBuffer._SubtractiveShadowColor = Shader.PropertyToID("_SubtractiveShadowColor");

            PerCameraBuffer._InvCameraViewProj  = Shader.PropertyToID("_InvCameraViewProj");
            PerCameraBuffer._ScaledScreenParams = Shader.PropertyToID("_ScaledScreenParams");

            // Let engine know we have MSAA on for cases where we support MSAA backbuffer
            if (QualitySettings.antiAliasing != asset.msaaSampleCount)
            {
                QualitySettings.antiAliasing = asset.msaaSampleCount;
            }

            Shader.globalRenderPipeline = "LightweightPipeline";

            Lightmapping.SetDelegate(lightsDelegate);

            CameraCaptureBridge.enabled = true;
            VxShadowMapsManager.Instance.Build(); //seongdae;vxsm
        }
Ejemplo n.º 8
0
 void DisposeLighting()
 {
     // Clear callback for converting light sources from HPSXRP representation to lightmapper representation.
     Lightmapping.ResetDelegate();
 }
Ejemplo n.º 9
0
 void AllocateLighting()
 {
     // Set callback for converting light sources from HPSXRP representation to lightmapper representation.
     Lightmapping.SetDelegate(lightsDelegate);
 }
Ejemplo n.º 10
0
 private static void RequestLights_Internal()
 {
     Lightmapping.RequestLights();
 }