Author SHA1 Message Date
Redstone1024 ddc971d497 Set color space to linear. 2021-01-30 11:46:41 +08:00
Redstone1024 622e37e486 Done! 2021-01-29 19:12:56 +08:00
8 changed files with 119 additions and 41 deletions
+1 -1
View File
@@ -20,7 +20,7 @@
void ConfigureSurface(Input input, inout SurfaceOutputStandard surface) void ConfigureSurface(Input input, inout SurfaceOutputStandard surface)
{ {
surface.Albedo.rg = saturate(input.worldPos.xy * 0.5 + 0.5); surface.Albedo = saturate(input.worldPos * 0.5 + 0.5);
surface.Smoothness = _Smoothness; surface.Smoothness = _Smoothness;
} }
File diff suppressed because one or more lines are too long
+7 -6
View File
@@ -38,7 +38,7 @@ RenderSettings:
m_ReflectionIntensity: 1 m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0} m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 705507994} m_Sun: {fileID: 705507994}
m_IndirectSpecularColor: {r: 0.18028378, g: 0.22571412, b: 0.30692285, a: 1} m_IndirectSpecularColor: {r: 0.44657892, g: 0.4964133, b: 0.57481736, a: 1}
m_UseRadianceAmbientProbe: 0 m_UseRadianceAmbientProbe: 0
--- !u!157 &3 --- !u!157 &3
LightmapSettings: LightmapSettings:
@@ -153,6 +153,7 @@ MonoBehaviour:
pointPrefab: {fileID: 5221897554875366738, guid: d73a635284aa0ca4eb9cc40879b3267d, pointPrefab: {fileID: 5221897554875366738, guid: d73a635284aa0ca4eb9cc40879b3267d,
type: 3} type: 3}
resolution: 50 resolution: 50
function: 0
--- !u!4 &75389716 --- !u!4 &75389716
Transform: Transform:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@@ -252,13 +253,13 @@ Transform:
m_PrefabInstance: {fileID: 0} m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 705507993} m_GameObject: {fileID: 705507993}
m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261} m_LocalRotation: {x: 0.40821788, y: 0.23456976, z: -0.10938167, w: 0.8754261}
m_LocalPosition: {x: 0, y: 3, z: 0} m_LocalPosition: {x: 0, y: 3, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 1 m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} m_LocalEulerAnglesHint: {x: 50, y: 30, z: 0}
--- !u!1 &963194225 --- !u!1 &963194225
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@@ -336,13 +337,13 @@ Transform:
m_PrefabInstance: {fileID: 0} m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 963194225} m_GameObject: {fileID: 963194225}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: -0.32403755, y: -0.3351304, z: 0.123971656, w: -0.87596714}
m_LocalPosition: {x: 0, y: 0, z: -2} m_LocalPosition: {x: -1.7640238, y: 2.0069275, z: -2.0079021}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 0 m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 37.741, y: 43.286003, z: 3.548}
--- !u!114 &963194229 --- !u!114 &963194229
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
+71
View File
@@ -0,0 +1,71 @@
using UnityEngine;
using static UnityEngine.Mathf;
public static class FunctionLibrary
{
public delegate Vector3 Function(float u, float v, float y);
public enum FunctionName { Wave, MultiWave, Ripple, Sphere, Torus }
private static Function[] functions = { Wave, MultiWave, Ripple, Sphere, Torus };
public static Function GetFunction(FunctionName name)
{
return functions[(int)name];
}
public static Vector3 Wave(float u, float v, float t)
{
Vector3 p;
p.x = u;
p.y = Sin(PI * (u + v + t));
p.z = v;
return p;
}
public static Vector3 MultiWave(float u, float v, float t)
{
Vector3 p;
p.x = u;
p.y = Sin(PI * (u + 0.5f * t));
p.y += 0.5f * Sin(2f * PI * (v + t));
p.y += Sin(PI * (u + v + 0.25f * t));
p.y *= 1f / 2.5f;
p.z = v;
return p;
}
public static Vector3 Ripple(float u, float v, float t)
{
var d = Sqrt(u * u + v * v);
Vector3 p;
p.x = u;
p.y = Sin(PI * (4f * d - t));
p.y /= 1f + 10f * d;
p.z = v;
return p;
}
public static Vector3 Sphere(float u, float v, float t)
{
float r = 0.9f + 0.1f * Sin(PI * (6f * u + 4f * v + t));
float s = r * Cos(0.5f * PI * v);
Vector3 p;
p.x = s * Sin(PI * u);
p.y = r * Sin(0.5f * PI * v);
p.z = s * Cos(PI * u);
return p;
}
public static Vector3 Torus(float u, float v, float t)
{
float r1 = 0.7f + 0.1f * Sin(PI * (6f * u + 0.5f * t));
float r2 = 0.15f + 0.05f * Sin(PI * (8f * u + 4f * v + 2f * t));
float s = r1 + r2 * Cos(PI * v);
Vector3 p;
p.x = s * Sin(PI * u);
p.y = r2 * Sin(PI * v);
p.z = s * Cos(PI * u);
return p;
}
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e5d4ebe0e863dfd49b58925b59880bf7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+17 -10
View File
@@ -8,19 +8,19 @@ public class Graph : MonoBehaviour
[SerializeField, Range(10, 100)] [SerializeField, Range(10, 100)]
int resolution = 10; int resolution = 10;
[SerializeField]
FunctionLibrary.FunctionName function = default;
Transform[] points; Transform[] points;
private void Awake() private void Awake()
{ {
var step = 2.0f / resolution; var step = 2f / resolution;
var position = Vector3.zero;
var scale = Vector3.one * step; var scale = Vector3.one * step;
points = new Transform[resolution]; points = new Transform[resolution * resolution];
for (int i = 0; i < points.Length; i++) for (int i = 0; i < points.Length; i++)
{ {
Transform point = Instantiate(pointPrefab); Transform point = Instantiate(pointPrefab);
position.x = (i + 0.5f) * step - 1.0f;
point.localPosition = position;
point.localScale = scale; point.localScale = scale;
point.SetParent(transform, false); point.SetParent(transform, false);
points[i] = point; points[i] = point;
@@ -29,13 +29,20 @@ public class Graph : MonoBehaviour
private void Update() private void Update()
{ {
FunctionLibrary.Function f = FunctionLibrary.GetFunction(function);
var time = Time.time; var time = Time.time;
for (int i = 0; i < points.Length; i++) var step = 2.0f / resolution;
var v = 0.5f * step - 1f;
for (int i = 0, x = 0, z = 0; i < points.Length; i++, x++)
{ {
Transform point = points[i]; if (x == resolution)
Vector3 position = point.localPosition; {
position.y = Mathf.Sin(Mathf.PI * (position.x + time)); x = 0;
point.localPosition = position; z += 1;
v = (z + 0.5f) * step - 1f;
}
float u = (x + 0.5f) * step - 1f;
points[i].localPosition = f(u, v, time);
} }
} }
} }
+3 -3
View File
@@ -28,18 +28,18 @@ MonoBehaviour:
m_RenderScale: 1 m_RenderScale: 1
m_MainLightRenderingMode: 1 m_MainLightRenderingMode: 1
m_MainLightShadowsSupported: 1 m_MainLightShadowsSupported: 1
m_MainLightShadowmapResolution: 2048 m_MainLightShadowmapResolution: 4096
m_AdditionalLightsRenderingMode: 1 m_AdditionalLightsRenderingMode: 1
m_AdditionalLightsPerObjectLimit: 4 m_AdditionalLightsPerObjectLimit: 4
m_AdditionalLightShadowsSupported: 0 m_AdditionalLightShadowsSupported: 0
m_AdditionalLightsShadowmapResolution: 512 m_AdditionalLightsShadowmapResolution: 512
m_ShadowDistance: 50 m_ShadowDistance: 10
m_ShadowCascades: 0 m_ShadowCascades: 0
m_Cascade2Split: 0.25 m_Cascade2Split: 0.25
m_Cascade4Split: {x: 0.067, y: 0.2, z: 0.467} m_Cascade4Split: {x: 0.067, y: 0.2, z: 0.467}
m_ShadowDepthBias: 1 m_ShadowDepthBias: 1
m_ShadowNormalBias: 1 m_ShadowNormalBias: 1
m_SoftShadowsSupported: 0 m_SoftShadowsSupported: 1
m_UseSRPBatcher: 1 m_UseSRPBatcher: 1
m_SupportsDynamicBatching: 0 m_SupportsDynamicBatching: 0
m_MixedLightingSupported: 1 m_MixedLightingSupported: 1
+3 -15
View File
@@ -4,7 +4,7 @@
PlayerSettings: PlayerSettings:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
serializedVersion: 20 serializedVersion: 20
productGUID: d2816c567858caa4d908a68155d97c6b productGUID: 0e84fdf2766f65b408b878c2492b3a6f
AndroidProfiler: 0 AndroidProfiler: 0
AndroidFilterTouchesWhenObscured: 0 AndroidFilterTouchesWhenObscured: 0
AndroidEnableSustainedPerformanceMode: 0 AndroidEnableSustainedPerformanceMode: 0
@@ -13,7 +13,7 @@ PlayerSettings:
useOnDemandResources: 0 useOnDemandResources: 0
accelerometerFrequency: 60 accelerometerFrequency: 60
companyName: DefaultCompany companyName: DefaultCompany
productName: Tutorials-Basics-BuildingAGraph productName: Tutorials-Basics-MathematicalSurfaces
defaultCursor: {fileID: 0} defaultCursor: {fileID: 0}
cursorHotspot: {x: 0, y: 0} cursorHotspot: {x: 0, y: 0}
m_SplashScreenBackgroundColor: {r: 0.13725491, g: 0.12156863, b: 0.1254902, a: 1} m_SplashScreenBackgroundColor: {r: 0.13725491, g: 0.12156863, b: 0.1254902, a: 1}
@@ -582,19 +582,7 @@ PlayerSettings:
webGLLinkerTarget: 1 webGLLinkerTarget: 1
webGLThreadsSupport: 0 webGLThreadsSupport: 0
webGLWasmStreaming: 0 webGLWasmStreaming: 0
scriptingDefineSymbols: scriptingDefineSymbols: {}
1: UNITY_POST_PROCESSING_STACK_V2
4: UNITY_POST_PROCESSING_STACK_V2
7: UNITY_POST_PROCESSING_STACK_V2
13: UNITY_POST_PROCESSING_STACK_V2
14: UNITY_POST_PROCESSING_STACK_V2
19: UNITY_POST_PROCESSING_STACK_V2
21: UNITY_POST_PROCESSING_STACK_V2
25: UNITY_POST_PROCESSING_STACK_V2
27: UNITY_POST_PROCESSING_STACK_V2
28: UNITY_POST_PROCESSING_STACK_V2
29: UNITY_POST_PROCESSING_STACK_V2
30: UNITY_POST_PROCESSING_STACK_V2
platformArchitecture: {} platformArchitecture: {}
scriptingBackend: {} scriptingBackend: {}
il2cppCompilerConfiguration: {} il2cppCompilerConfiguration: {}