Skip to content

Instantly share code, notes, and snippets.

View antoinefortin's full-sized avatar

Antoine Fortin antoinefortin

  • Montreal, Canada
View GitHub Profile
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MatricesDemo : MonoBehaviour
{
static Vector4 vert0 = new Vector4(0.0f, 0.0f, 0.0f, 1.0f);
static Vector4 vert1 = new Vector4(10.0f, 0.0f, 0.0f, 1.0f);
static Vector4 vert2 = new Vector4(0.0f, 10.0f, 0.0f, 1.0f);
static Vector4 vert0 = new Vector4(0.0f, 0.0f, 0.0f, 1.0f);
static Vector4 vert1 = new Vector4(10.0f, 0.0f, 0.0f, 1.0f);
static Vector4 vert2 = new Vector4(0.0f, 10.0f, 0.0f, 1.0f);
static Vector4[] listVert = new Vector4[4];
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MatricesDemo : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
Gizmos.DrawCube(listVert[i], new Vector3(sizeOfCube, sizeOfCube, sizeOfCube));
@antoinefortin
antoinefortin / TransformationDemo.cs
Created December 10, 2021 17:41
Some demos on how matrices are used to modify some vertex
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SimpleDemo : MonoBehaviour
{
public float sizeOfCube = 1.0f;
public Vector3 scaling = new Vector3();
public Vector3 translate = new Vector3();
void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
vec3 outColDebug = vec3(0.0f);
vec2 uv = (fragCoord-.5 * iResolution.xy)/iResolution.y;
fragColor = vec4(outColDebug,1.0);
}
vec2 rotate(vec2 pos, float angle)
{
float c = cos(angle);
float s = sin(angle);
return mat2(c,s,-s,c) * pos;
}
mat2 Rot(float a) {
kernel UVmap : ImageComputationKernel<ePixelWise>
{
Image<eRead,eAccessRandom, eEdgeClamped> src; //I
Image<eWrite> dst; //O
local:
float width;
float height;
void init() {
width = src.bounds.x2; //function to find right edge
struct RMstruct
{
float RMSphere(float3 pos)
{
return length(pos) - 25;
}
float3 RMNormal(float3 pos)
/* SDF */
float sdSphere( vec3 p, float s )
{
return length(p)-s;
}
float sdBox( vec3 p, vec3 b )
{
vec3 q = abs(p) - b;