Posts

Showing posts with the label Math

3D Math - Always a Single Plane to Cut Three 3D Objects in Half with Borsuk-Ulam Theorem - by Zach Star

June 28, 2021 Borsuk-Ulam Theorem 3D Math Title: A surprising topological proof - Why you can always cut three objects in half with a single plane By: Zach Star Youtube - Information Description: Proving that any set of n n-dimensional objects can be cut in half by n-1 dimensional object (i.e. 3 3D objects can be cut in half by a 2D plane). Overview This was just a fun and interesting mathematical proof I came across. Using the Borsuk-Ulam Theorem at its core, it proves how any set of 3 3D objects can be cut in half (by volume) by some 2D plane. It then expands that to show that this works for any n amount of n-dimensional objects, which are then divided by an object with n-1 dimensions. Borsuk-Ulam Theorem This can be read up on here at the corresponding wikipedia page: Wikipedia - Borsuk-Ulam Theorem This states: "every continuous function from an n-sphere into Euclidean n-space maps some pair of antipodal points to the same point". ...

Unity Shader Graph - Signed Distance Fields - Update with Subgraph Fix

June 24, 2021 Shader Graph Unity Title: Drawing Boxes and Rectangles in URP Shader Graph with 2D SDFs! 2021.1 | Unity Game Dev Tutorial By: Ned Makes Games Youtube - Tutorial Description: Exploration into calculating signed distance fields and using them with Unity's Shader Graph. Title: Rectangle SDFs and Procedural Bricks! Video Production Stream | Unity Game Dev Livestream By: Ned Makes Games 2 Youtube - Tutorial Description: The full stream which most of the previous tutorial is pulled from. Useful for any more in depth questions of previous tutorial. Overview When I visited this tutorial yesterday I ran into an issue with Unity 2021.1.3 that working with subgraphs was extremely bugged and error prone. I had seen online that later versions potentially fixed the issue, so I download the latest version, 2021.1.12, and this did indeed fix the issue for me, making this tutorial much easier to follow along with. This tutorial was m...

Unity Shader Graph - Signed Distance Fields and Subgraph Errors

June 23, 2021 Shader Graph Unity Title: Drawing Boxes and Rectangles in URP Shader Graph with 2D SDFs! 2021.1 | Unity Game Dev Tutorial By: Ned Makes Games Youtube - Tutorial Description: Exploration into calculating signed distance fields and using them with Unity's Shader Graph. Overview This shader tutorial quickly explores calculating signed distance fields and using that for interesting effects. These effects were built in HLSL in the tutorial video originally, but they also show how these can be implemented with Unity's Shader Graph system. I wanted to use the Shader Graph approach, but unfortunately I found that Unity's Shader Graph Subgraphs have some major issues. Signed Distance Fields (SDFs) Signed Distance Fields (SDFs): calculate the distance from any arbitrary point to a specific shape Principles of Calculating To start, they look at an example using a rectangle whose center is at the origin (0, 0). First, they find t...

Lerp Fundamentals in Unity

May 10, 2021 Lerp Unity Title: How to Use Lerp (Unity Tutorial) By: Ketra Games Youtube - Tutorial Description: A brief coverage of exactly how Lerp works in Unity with a couple ways to use it. Overview I was recently researching ways to effectively use Lerp in Unity and came across some strange implementations that made me unsure if I understood how it worked. This video however specifically covered that case and explained that it does work, but it's not a particularly ideal solution. The case covered is specifically called the "Incorrect Usage" in this video. It is when Time.deltaTime alone is entered as the time parameter for Lerp. As I thought, this is just entering some tiny number as a time parameter each time it is called, which is then used to just some value between the intial and final values entered into the Lerp. It is not very controlled, and it leads to a strange situation where it keeps getting called and updated but it doe...

Game Project: Flying Game - Part 2 - 3D UI Guide with Rotational Matrices

May 4, 2021 Flying Game UI & Matrix Rotations Overview I wanted to make a 3D UI element which could direct the player in open flying space towards a point of interest or goal. This needed to point towards the object positionally, as well as account for the rotation or direction the player is facing. This makes sure that no matter where they are and what direction they are facing, it can guide them to turn the proper direction and make informed decisions to move directly towards that goal. After deciding that changing my frame of reference could be a solution for this problem, I found Unity's InverseTransformDirection method which can change a Vector from one space to another. To make sure this was providing a result similar to what I expected mathematically, I also wrote out the math for performing a matrix rotation on the vector and was happy to see it gave the same results. 3D UI Element - Real Time Guide Towards Goal Add a 3D Element to the Unity Canvas ...

Coding Adventure: Ray Marching by Sebastian Lague

Image
April 12, 2021 Ray Marching Unity Title: Coding Adventure: Ray Marching By: Sebastian Lague Youtube - Tutorial Description: Introduction to the concept of ray marching with some open available projects. Overview This video covers some of the basics of ray marching while also visualizing their approach and creating some interesting visual effects and renders with the math of signed distance along with ray marching logic. The major ray marching method they show is sphere tracing, which radiates circles/spheres out from a point until anything is collided with. Then, the point moves along the ray direction until it reaches the radius of that sphere projection and emits another sphere. This process is repeated until it radiates a very small threshold radius sphere, which is when a collision is determined. The resulting project made is available, and I think it would be very useful and interesting to explore. The Youtube video description also holds many lin...

Linear Algebra and Vector Math - Basics and Dot Product - by Looking Glass Universe

April 8, 2021 Linear Algebra Vectors and Dot Product Title: Vector addition and basis vectors | Linear algebra makes sense Youtube - Link #1 Description: Introduction to this series and the basics of linear algebra and vectors. Title: The meaning of the dot product | Linear algebra makes sense Youtube - Link #2 Description: Deep dive into the dot product and what it represents and how to determine it. Overview I wanted to brush up on my vector math fundamentals, particularly with my understanding of the dot product and its geometric implications as it is something that comes up often in my game development path. While I am able to understand it when reading it and coding it for various projects, I wanted to build a more solid foundational understanding so that I could apply it more appropriately on my own. This video series has been very nice for refreshing my learning on these topics, as well as actually providing me a new way of looking at vec...

Architecture AI Pathing Project: Upward Raycast for Better Opening Detection

Image
January 11, 2021 Raycast for A* Nodes Architecture AI Project Original Downward Raycast and Downfalls The raycasting system for detecting the environment to setup the base A* pathing nodes was originally using downward raycasts. These rays traveled until they hit the environment, and then set the position of the node as well as whether it is walkable or not. An extra sphere collision check around the point of contact was also conducted so as to check for obstacles right next to the node as well. This works for rather open environments, but this had a major downside for our particular needs as it failed to detect openings with in walls and primarily doors. Doors are almost always found within a wall, so the raycast system would hit the wall above the door and read as unwalkable. This would leave most doors as unwalkable areas because of the walls above and around them. Upward Raycast System Approach Method The idea of using an upward raycast was that it would help al...

Indiecade Europe 2019 Talk - The Simple Yet Powerful Math We Don't Talk About

July 7, 2020 Indiecade Europe 2019 Talk Math in Game Dev The Simple Yet Powerful Math We Don't Talk About Youtube - Link By: Indiecade Europe Presenter: Freya Holmér Introduction I am always interested to find new ways of using math within game development to produce fun and unique effects as well as for creating cool systems, so this talk sounded right up my alley. They focus on 3 major functions found in a lot of software as well as Unity: Lerp, InverseLerp, and Remap. While I have used Lerp pretty extensively already, I had never used the other two so covering all of them together was eye opening to see how many different ways they can be utilized for different systems. Notes from Talk Lerp Lerp(a, b, t) = value Lerp(a, b, t) where a is like the starting point, b is the end point, and t is a fraction, generally between 0 and 1. Lerp then outputs a blended value between a and b based on t. At t = 0, it outputs a, and at t = 1.0, it outputs b. t does not have to b...

Overview of Hyperbolic and Spherical Space with Non-Euclidean Geometry

July 6, 2020 Non-Euclidean Geometry Hyperbolic and Spherical Space Non-Euclidean Geometry Explained - Hyperbolica Devlog #1 Youtube - Link By: CodeParade Introduction I just find weird and interesting ways to apply math concepts interesting so I wanted to note this video I came across here. It covers the most basic principles of some non-Euclidean geometries and tries to explain them as simply as possible (which will still take several watches for me to truly grasp). The extra mathematical concepts they cover such as how these geometries change the formulas for circumference and area of a circle or the area of a triangle are really cool and it would be a fun challenge to explore how to use these effectively in a game space. Speaking of, they actually mention a roguelike game that tries to use hyperbolic space as the environment for the player which can be found here (it can be downloaded freely at this time as well): Hyper Rogue Site

Hex Based 4X Game Tutorial

September 9, 2019 Unity 4X Game Tutorial Part Based Mostly Civilized: A Hex-Based 4x Game Engine for Unity - Part 1 Youtube - Link By: quill18creates I was looking to add another Unity game genre tutorial that I could follow along with, and happened to come across one for a fairly complex genre I enjoy so this seemed like a nice more advanced tutorial program to go through. I have checked out some of quill18creates content before and it usually serves as some good practice for more advanced topics, while also helping teach you some fundamentals about optimization and general project architecture. This immediately caught my attention with the hex tile map math shown at the beginning of the video. There they show how to use various coordinate systems, such as cube coordinates, in a hex tile system in a very efficient and sensible way. The link to this information can be found here: Hexagonal Grids from Red Blob Games Red Blob Games - Link

Video Game Physics - Constrained Rigid Body Simulation by Nilson Souto

January 5, 2019 Video Game Physics - Constrained Rigid Body Simulation by Nilson Souto Toptal - Video Game Physics Tutorial - Part III: Constrained Rigid Body Simulation By: Nilson Souto Link to Erin Catto's box2d.org This appears to be a good follow up to the game physics GDC talk by Erin Catto I watched earlier. This serves as another listing of physics constraints and how they can apply in games, specifically when dealing with rigid body elements. I also learned the constraint type is "revolute", not "resolute". This article actually references Erin Catto and his Box2D site since it goes into his creation of the sequential impulse method.

Instantiating Objects Randomly Within a Given Polygon

Image
June 11th, 2018 Randomly Selecting Points within a Given Polygon References Used: Stack Overflow - Random Points in a Quadrilateral Wolfram Alpha Information on Points in a Triangle Notes I needed to be able to randomly but evenly distribute a number of objects within a 2D area so these are the sources I started with. The Stack Overflow question ended up being a very good starting point, but there were errors with the calculations that I needed to solve in order to actually use their logic. Fixes from Stack Overflow First calculation to fix was the originally randomly selected position of the object. It turned out that it was very close, but it actually only worked if v0 was the origin. It was simple enough to fix by adding v0 to the x equation. The second equation to fix was the v3 equation. They were subtracting v0 twice which is incorrect (again something unnoticeable if v0 is that origin as you're simply subtracting (0,0) twice). v0 should only be subtracted once to ob...
May 19th, 2018 Math for Game Programmers - Talks from GDC - Notes GDC 2015 - Math for Game Programmers: Fast and Funky 1D Nonlinear Transformations Presenter: Squirrel Eiserloh Youtube link to presentation Notes: Other names used for these concepts in other fields: Easing functions Filter functions Lerping functions Tweening functions Implicit vs. Parametric Equations Implicit: Ex. x^2 + y^2 = R^2 Parametric: Ex. Px = R * cos(2*pi*t); Py = R * sin(2*pi*t) Parametric Equations use a single variable (usually a float) as input Opportunities to Use Parametric Transformations Anywhere you have a single float to change Anywhere that could be expressed as a single float Anytime you use time The two most important number ranges in mathematics and computer science are: 0 to 1: Good for fractions and percentages -1 to 1: Good for deviations from some original value These functions are normalized Input of 0 has output of 0, and input of 1 has output of 1 Th...
May 13th, 2018 Procedural Generation Unite 2016 - The Power of Procedural Meshes Unity Talk by Alexander Birke Youtube Link to Talk Suggested Reading: “Essential Mathematics for Games – A Programmers Guide” by James M. Van Verth & Lars M. Bishop Links to examples to learn about procedural generation of meshes Mesh Presentation Unity Environments Trinagle.net Port to Unity Notes from talk: Why use procedural meshes? Player Made Content (Ex. Spore) Unique Mechanics (Ex. Gish) Procedural Generation (Ex. Sir You're Being Hunted) Unity Procedural Meshes Mesh starts by creating vertices, and then making triangles from those vertices Components Needed: MeshFilter - stores the mesh MeshRenderer - shows the mesh Script - to generate the mesh Normal vectors used to determine surface orientation Colors Used to be determined by assigning values to vertices Can be used to provide more information to vertices still Can be done as bytes or floats Bytes general...