protected override void PlaceGhostInterpolate(MotionBlurGhost rGhost, TransformSave rTransformSaveBegin, TransformSave rTransformSaveEnd, float fCurrentGhostCurrentTimeRangePositionInPercent) { base.PlaceGhostInterpolate(rGhost, rTransformSaveBegin, rTransformSaveEnd, fCurrentGhostCurrentTimeRangePositionInPercent); // Make sure is visible rGhost.Show(); }
/// \brief Place Ghost protected virtual float PlaceGhost(TransformSave rTransformSaveBegin, TransformSave rTransformSaveEnd, ref int a_iCurrentGhostIndex) { // Compute the time between two ghost float fTimeBetweenTwoGhosts = m_rMotionBlur.persistenceDuration / m_rMotionBlur.quality; // Get the range time extremity float fCurrentRangeTimeBegin = rTransformSaveBegin.saveTime; float fCurrentRangeTimeEnd = rTransformSaveEnd.saveTime; // Compute the current time range duration float fCurrentTimeRangeDuration = fCurrentRangeTimeBegin - fCurrentRangeTimeEnd; // Compute the current ghost backward time float fCurrentGhostBackwardTime = (a_iCurrentGhostIndex) * fTimeBetweenTwoGhosts; // Compute the current Ghost time float fCurrentTime = Time.time; float fCurrentGhostTime = fCurrentTime - fCurrentGhostBackwardTime; // Compute the remaining time since first ghost before the current time range end float fRemainingTimeSinceFirstGhostBeforeEndOfCurrentTimeRange = fCurrentGhostTime - fCurrentRangeTimeEnd; // Compute the number of ghost to place int iNumberOfGhostToPlaceInTheCurrentTimeRange = 1 + Mathf.FloorToInt(fRemainingTimeSinceFirstGhostBeforeEndOfCurrentTimeRange / fTimeBetweenTwoGhosts); iNumberOfGhostToPlaceInTheCurrentTimeRange = Mathf.Clamp(iNumberOfGhostToPlaceInTheCurrentTimeRange, 0, m_oGhosts.Count - a_iCurrentGhostIndex); // Place the number of ghost needed for (int k = 0; k < iNumberOfGhostToPlaceInTheCurrentTimeRange; k++) { // Update the current ghost backward time fCurrentGhostBackwardTime = (a_iCurrentGhostIndex) * fTimeBetweenTwoGhosts; // Update the current Ghost time fCurrentGhostTime = fCurrentTime - fCurrentGhostBackwardTime; // Compute at which percent of the current time range is placed the current ghost float fCurrentGhostCurrentTimeRangePositionInPercent = (fCurrentRangeTimeBegin - fCurrentGhostTime) / fCurrentTimeRangeDuration; // Grab the current ghost MotionBlurGhost rGhost = m_oGhosts[a_iCurrentGhostIndex]; // Place the ghost fCurrentGhostCurrentTimeRangePositionInPercent = Mathf.Max(fCurrentGhostCurrentTimeRangePositionInPercent, 0.0f); PlaceGhostInterpolate(rGhost, rTransformSaveBegin, rTransformSaveEnd, fCurrentGhostCurrentTimeRangePositionInPercent); // Offset the ghost rGhost.transform.position += m_rMotionBlur.offset; // Fade out the ghost => the older it is the more transparent ApplyGhostFade(rGhost, fCurrentGhostBackwardTime / m_rMotionBlur.persistenceDuration); // Pass to the next ghost a_iCurrentGhostIndex++; } // Increment elapsed time since last ghost return(fCurrentGhostTime - fCurrentRangeTimeEnd); }
protected virtual void PlaceGhostInterpolate(MotionBlurGhost rGhost, TransformSave rTransformSaveBegin, TransformSave rTransformSaveEnd, float fCurrentGhostCurrentTimeRangePositionInPercent) { TransformSave.LoadInterpolatedTransform(rGhost.transform, rTransformSaveBegin, rTransformSaveEnd, fCurrentGhostCurrentTimeRangePositionInPercent); if (!m_rMotionBlur.progressiveScale) { rGhost.SetTransformToGhost(m_rMotionBlur.transform); } }
/// \brief If the material has changed update the ghost shared material private void TakeCareOfMaterialUpdate(MotionBlurGhost a_rFirstGhost) { //if (AreMaterialsEqual(m_rMotionBlur.renderer.materials, a_rFirstGhost.renderer.sharedMaterials) == false) if (m_rMotionBlur.renderer.sharedMaterial != a_rFirstGhost.renderer.sharedMaterial) { foreach (MotionBlurGhost3D rGhost in m_oGhosts) { rGhost.renderer.sharedMaterials = m_rMotionBlur.renderer.sharedMaterials;//CopyMaterials(m_rMotionBlur.renderer.materials); } } }
/// \brief If the material has changed update the ghost shared material private void TakeCareOfMaterialUpdate(MotionBlurGhost a_rFirstGhost) { //if (AreMaterialsEqual(m_rMotionBlur.renderer.materials, a_rFirstGhost.renderer.sharedMaterials) == false) if (m_rMotionBlur.GetComponent<Renderer>().sharedMaterial != a_rFirstGhost.GetComponent<Renderer>().sharedMaterial) { foreach(MotionBlurGhost3D rGhost in m_oGhosts) { rGhost.GetComponent<Renderer>().sharedMaterials = m_rMotionBlur.GetComponent<Renderer>().sharedMaterials;//CopyMaterials(m_rMotionBlur.renderer.materials); } } }
protected override void PlaceGhostInterpolate(MotionBlurGhost rGhost, TransformSave rTransformSaveBegin, TransformSave rTransformSaveEnd, float fCurrentGhostCurrentTimeRangePositionInPercent) { base.PlaceGhostInterpolate(rGhost, rTransformSaveBegin, rTransformSaveEnd, fCurrentGhostCurrentTimeRangePositionInPercent); // Render and transform smooth update or not if (m_rMotionBlur.progressiveSpriteColor) { TransformSave2D.LoadInterpolatedTransform(((MotionBlurGhost2D)rGhost).m_rSpriteRendererFilter, (TransformSave2D)rTransformSaveBegin, (TransformSave2D)rTransformSaveEnd, fCurrentGhostCurrentTimeRangePositionInPercent); } else { ((MotionBlurGhost2D)rGhost).SetSpriteRendererToGhost(m_rSpriteRenderer); } }
/// \brief Update world motion blur private void HideUnusedGhost(ref int a_iCurrentGhostIndex) { // Loop through the unused Ghost and Ensure they are hidden int iGhostCount = m_oGhosts.Count; for (; a_iCurrentGhostIndex < iGhostCount; a_iCurrentGhostIndex++) { // Grab the next unused ghost MotionBlurGhost rGhost = m_oGhosts[a_iCurrentGhostIndex]; // Make sure is invisible rGhost.Hide(); } }
/// \brief Update Parameters protected override void TakeCareOfParametersUpdate() { base.TakeCareOfParametersUpdate(); if (m_oGhosts.Count > 0) { // Grab the first ghost MotionBlurGhost rFirstGhost = m_oGhosts[0]; // If the material has changed update the ghost shared material TakeCareOfMaterialUpdate(rFirstGhost); // If the mesh to ghost has changed update the ghosts meshes TakeCareOfMeshUpdate(); // Update mesh uv if needed if (m_bUpdateMeshUVRequested) { UpdateMeshUV(); m_bUpdateMeshUVRequested = false; } } }
protected virtual void PlaceGhostInterpolate(MotionBlurGhost rGhost, TransformSave rTransformSaveBegin, TransformSave rTransformSaveEnd, float fCurrentGhostCurrentTimeRangePositionInPercent) { TransformSave.LoadInterpolatedTransform(rGhost.transform, rTransformSaveBegin, rTransformSaveEnd, fCurrentGhostCurrentTimeRangePositionInPercent); if (!m_rMotionBlur.progressiveScale) { rGhost.SetTransformToGhost(m_rMotionBlur.transform); } }
/// \brief Update ghosts protected void ApplyGhostFade(MotionBlurGhost a_rGhost, float a_fPercentFade) { a_rGhost.SetOpacity(MotionBlurInterpolate.Ease(GetFadeEaseType())(0.0f, 1.0f, 1.0f - a_fPercentFade, 1.0f) * m_rMotionBlur.opacity); }
/// \brief Update ghosts protected void ApplyGhostFade(MotionBlurGhost a_rGhost, float a_fPercentFade) { a_rGhost.SetOpacity(MotionBlurInterpolate.Ease(GetFadeEaseType())(0.0f, 1.0f, 1.0f - a_fPercentFade, 1.0f) * m_rMotionBlur.opacity); }
protected override void PlaceGhostInterpolate(MotionBlurGhost rGhost, TransformSave rTransformSaveBegin, TransformSave rTransformSaveEnd, float fCurrentGhostCurrentTimeRangePositionInPercent) { base.PlaceGhostInterpolate(rGhost, rTransformSaveBegin, rTransformSaveEnd, fCurrentGhostCurrentTimeRangePositionInPercent); // Make sure is visible rGhost.Show(); }
protected override void PlaceGhostInterpolate(MotionBlurGhost rGhost, TransformSave rTransformSaveBegin, TransformSave rTransformSaveEnd, float fCurrentGhostCurrentTimeRangePositionInPercent) { base.PlaceGhostInterpolate( rGhost, rTransformSaveBegin, rTransformSaveEnd, fCurrentGhostCurrentTimeRangePositionInPercent); // Render and transform smooth update or not if (m_rMotionBlur.progressiveSpriteColor) { TransformSave2D.LoadInterpolatedTransform( ((MotionBlurGhost2D)rGhost).m_rSpriteRendererFilter, (TransformSave2D)rTransformSaveBegin, (TransformSave2D)rTransformSaveEnd, fCurrentGhostCurrentTimeRangePositionInPercent); } else { ((MotionBlurGhost2D)rGhost).SetSpriteRendererToGhost(m_rSpriteRenderer); } }