Skip to content

Commit

Permalink
Remove noise from solo effect and tweak effect colors.
Browse files Browse the repository at this point in the history
Also fixes unwanted scaling of solo transition objects and removes unneeded GreyscaleNoise texture.
  • Loading branch information
wyrdough committed Dec 31, 2024
1 parent 7022df4 commit f0704c3
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 125 deletions.
6 changes: 3 additions & 3 deletions Assets/Art/Materials/Gameplay/Track/SoloEffectTransition.mat
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Material:
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 2800000, guid: c4c44d2ae22032e4990e0c567fbdf72c, type: 3}
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
Expand Down Expand Up @@ -116,8 +116,8 @@ Material:
- _ZWrite: 1
m_Colors:
- _BaseColor: {r: 1, g: 1, b: 1, a: 1}
- _Color: {r: 0, g: 0.79607844, b: 0.8784314, a: 0.6666667}
- _EmissionColor: {r: 0, g: 2.995996, b: 3.7647054, a: 0.6745098}
- _Color: {r: 0, g: 0.2980392, b: 0.47450978, a: 1}
- _EmissionColor: {r: 0, g: 0.07227186, b: 0.19120172, a: 1}
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
m_BuildTextureStacks: []
--- !u!114 &2562951267628346201
Expand Down
6 changes: 3 additions & 3 deletions Assets/Art/Materials/Gameplay/Track/SoloEffects.mat
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Material:
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 2800000, guid: c4c44d2ae22032e4990e0c567fbdf72c, type: 3}
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
Expand Down Expand Up @@ -117,8 +117,8 @@ Material:
- _ZWrite: 0
m_Colors:
- _BaseColor: {r: 0.19607845, g: 0.19607845, b: 0.19607845, a: 1}
- _Color: {r: 0, g: 0.7960785, b: 0.87843144, a: 0.6666667}
- _EmissionColor: {r: 0, g: 2.995996, b: 3.7647054, a: 0.6745098}
- _Color: {r: 0, g: 0.2980392, b: 0.47450978, a: 1}
- _EmissionColor: {r: 0, g: 0.07227186, b: 0.1878208, a: 1}
- _Solo_Color: {r: 0, g: 1, b: 1, a: 1}
- _Solo_End: {r: 0, g: 0, b: 0, a: 0}
- _Solo_Start: {r: 0, g: 0, b: 0, a: 0}
Expand Down
4 changes: 2 additions & 2 deletions Assets/Art/Textures/Gameplay/Track/SoloTrack.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions Assets/Art/Textures/Gameplay/Track/SoloTransition.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 0 additions & 3 deletions Assets/Art/Textures/GreyscaleNoise.png

This file was deleted.

111 changes: 0 additions & 111 deletions Assets/Art/Textures/GreyscaleNoise.png.meta

This file was deleted.

34 changes: 33 additions & 1 deletion Assets/Script/Gameplay/Visuals/TrackElements/SoloElement.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
Expand All @@ -18,9 +19,40 @@ public class SoloElement : TrackElement<TrackPlayer>

protected override void InitializeElement()
{
var zScale = (float) (SoloRef.EndTime - SoloRef.StartTime) * Player.NoteSpeed / 10;
// More correctly, this would get the unscaled size of the object
// Since we currently use Unity's plane, this works
const float zSize = 10.0f;
float childZBasePosition = zSize / 2;
var zScale = (float) (SoloRef.EndTime - SoloRef.StartTime) * Player.NoteSpeed / zSize;

var cachedTransform = _meshRenderer.transform;

// A bit of hackery is necessary to avoid the rescaling of the
// parent from messing up the scaling of the children
var children = cachedTransform.GetComponentsInChildren<Transform>();
var scaleFactor = zScale / zSize;
foreach (var child in children)
{
if (child == cachedTransform)
{
continue;
}
// Change the child's scale such that their world size remains the same after the parent scales
var originalScale = 0.005f; // this should be child.localScale.z, but that causes issues if the object gets reused
var newScale = originalScale / scaleFactor;
child.localScale = child.localScale.WithZ(newScale);
// Adjust the child's position to reflect the new scale
var signFactor = Math.Sign(child.localPosition.z);
var newZ = (childZBasePosition + newScale * childZBasePosition) * signFactor;
// This fudge shouldn't be necessary, but without it there is sometimes
// a visible gap in the rail between the transition and main section
// I assume this is because of rounding errors with small float values
newZ += 0.001f * -signFactor;

child.localPosition = child.localPosition.WithZ(newZ);
}
// With the adjustments to the children made, we can scale the
// parent and have everything end up in the right place
cachedTransform.localScale = cachedTransform.localScale.WithZ(zScale);
}

Expand Down

0 comments on commit f0704c3

Please sign in to comment.