1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 09:17:51 +08:00

Merge pull request #9366 from jorolf/logo-shader

This commit is contained in:
Dean Herbert 2020-07-15 20:42:38 +09:00 committed by GitHub
commit 4e9e9205d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 150 additions and 14 deletions

View File

@ -51,7 +51,7 @@
<Reference Include="Java.Interop" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="ppy.osu.Game.Resources" Version="2020.714.0" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2020.715.0" />
<PackageReference Include="ppy.osu.Framework.Android" Version="2020.714.1" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,46 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Textures;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
namespace osu.Game.Tests.Visual.UserInterface
{
[TestFixture]
public class TestSceneHueAnimation : OsuTestScene
{
[BackgroundDependencyLoader]
private void load(LargeTextureStore textures)
{
HueAnimation anim2;
Add(anim2 = new HueAnimation
{
RelativeSizeAxes = Axes.Both,
FillMode = FillMode.Fit,
Texture = textures.Get("Intro/Triangles/logo-highlight"),
Colour = Colour4.White,
});
HueAnimation anim;
Add(anim = new HueAnimation
{
RelativeSizeAxes = Axes.Both,
FillMode = FillMode.Fit,
Texture = textures.Get("Intro/Triangles/logo-background"),
Colour = OsuColour.Gray(0.6f),
});
AddSliderStep("Progress", 0f, 1f, 0f, newValue =>
{
anim2.AnimationProgress = newValue;
anim.AnimationProgress = newValue;
});
}
}
}

View File

@ -0,0 +1,69 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.OpenGL.Vertices;
using osu.Framework.Graphics.Shaders;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
namespace osu.Game.Graphics.Sprites
{
public class HueAnimation : Sprite
{
[BackgroundDependencyLoader]
private void load(ShaderManager shaders, TextureStore textures)
{
TextureShader = shaders.Load(VertexShaderDescriptor.TEXTURE_2, @"HueAnimation");
RoundedTextureShader = shaders.Load(VertexShaderDescriptor.TEXTURE_2, @"HueAnimation"); // Masking isn't supported for now
}
private float animationProgress;
public float AnimationProgress
{
get => animationProgress;
set
{
if (animationProgress == value) return;
animationProgress = value;
Invalidate(Invalidation.DrawInfo);
}
}
public override bool IsPresent => true;
protected override DrawNode CreateDrawNode() => new HueAnimationDrawNode(this);
private class HueAnimationDrawNode : SpriteDrawNode
{
private HueAnimation source => (HueAnimation)Source;
private float progress;
public HueAnimationDrawNode(HueAnimation source)
: base(source)
{
}
public override void ApplyState()
{
base.ApplyState();
progress = source.animationProgress;
}
protected override void Blit(Action<TexturedVertex2D> vertexAction)
{
Shader.GetUniform<float>("progress").UpdateValue(ref progress);
base.Blit(vertexAction);
}
protected override bool CanDrawOpaqueInterior => false;
}
}
}

View File

@ -3,7 +3,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
@ -12,7 +11,6 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Textures;
using osu.Framework.Graphics.Video;
using osu.Framework.Utils;
using osu.Framework.Timing;
using osu.Game.Graphics;
@ -88,7 +86,7 @@ namespace osu.Game.Screens.Menu
private RulesetFlow rulesets;
private Container rulesetsScale;
private Container logoContainerSecondary;
private Drawable lazerLogo;
private LazerLogo lazerLogo;
private GlitchingTriangles triangles;
@ -139,10 +137,10 @@ namespace osu.Game.Screens.Menu
RelativeSizeAxes = Axes.Both,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Child = lazerLogo = new LazerLogo(textures.GetStream("Menu/logo-triangles.mp4"))
Child = lazerLogo = new LazerLogo
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Origin = Anchor.Centre
}
},
};
@ -218,6 +216,9 @@ namespace osu.Game.Screens.Menu
// matching flyte curve y = 0.25x^2 + (max(0, x - 0.7) / 0.3) ^ 5
lazerLogo.FadeIn().ScaleTo(scale_start).Then().Delay(logo_scale_duration * 0.7f).ScaleTo(scale_start - scale_adjust, logo_scale_duration * 0.3f, Easing.InQuint);
lazerLogo.TransformTo(nameof(LazerLogo.Progress), 1f, logo_scale_duration);
logoContainerSecondary.ScaleTo(scale_start).Then().ScaleTo(scale_start - scale_adjust * 0.25f, logo_scale_duration, Easing.InQuad);
}
@ -259,20 +260,40 @@ namespace osu.Game.Screens.Menu
private class LazerLogo : CompositeDrawable
{
private readonly Stream videoStream;
private HueAnimation highlight, background;
public LazerLogo(Stream videoStream)
public float Progress
{
get => background.AnimationProgress;
set
{
background.AnimationProgress = value;
highlight.AnimationProgress = value;
}
}
public LazerLogo()
{
this.videoStream = videoStream;
Size = new Vector2(960);
}
[BackgroundDependencyLoader]
private void load()
private void load(TextureStore textures)
{
InternalChild = new Video(videoStream)
InternalChildren = new Drawable[]
{
RelativeSizeAxes = Axes.Both,
highlight = new HueAnimation
{
RelativeSizeAxes = Axes.Both,
Texture = textures.Get(@"Intro/Triangles/logo-highlight"),
Colour = Color4.White,
},
background = new HueAnimation
{
RelativeSizeAxes = Axes.Both,
Texture = textures.Get(@"Intro/Triangles/logo-background"),
Colour = OsuColour.Gray(0.6f),
},
};
}
}

View File

@ -25,7 +25,7 @@
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.6" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="ppy.osu.Framework" Version="2020.714.1" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2020.714.0" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2020.715.0" />
<PackageReference Include="Sentry" Version="2.1.4" />
<PackageReference Include="SharpCompress" Version="0.25.1" />
<PackageReference Include="NUnit" Version="3.12.0" />

View File

@ -71,7 +71,7 @@
</ItemGroup>
<ItemGroup Label="Package References">
<PackageReference Include="ppy.osu.Framework.iOS" Version="2020.714.1" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2020.714.0" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2020.715.0" />
</ItemGroup>
<!-- Xamarin.iOS does not automatically handle transitive dependencies from NuGet packages. -->
<ItemGroup Label="Transitive Dependencies">