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