Skip to content

Instantly share code, notes, and snippets.

// Some small parts of the code are specific to my setup, as I'm sometimes getting game objects by name (for the wheel parts),
// but most of it could be easily adapted to your project.
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using UnityEditor.SceneManagement;
Shader "Unlit/GeoGrass" {
Properties {
_Color ("Colour", Color) = (1,1,1,1)
_Color2 ("Colour2", Color) = (1,1,1,1)
_Width ("Width", Float) = 1
_RandomWidth ("Random Width", Float) = 1
_Height ("Height", Float) = 1
_RandomHeight ("Random Height", Float) = 1
}
SubShader {
///////////////////////////////////////////////////
//////////////// grass_struct.hlsl ////////////////
///////////////////////////////////////////////////
struct Attributes {
float4 positionOS : POSITION;
float3 normal : NORMAL;
float4 tangent : TANGENT;
float2 texcoord : TEXCOORD0;
// Tessellation programs based on this article by Catlike Coding:
// https://catlikecoding.com/unity/tutorials/advanced-rendering/tessellation/
struct vertexInput
{
float4 vertex : POSITION;
float3 normal : NORMAL;
float4 tangent : TANGENT;
};
// target is the player
// transform is the spider
Vector3 orientation = GetTerrainNormal();
Vector3 directionToTarget = (target.position - transform.position).Y(0);
float d = Vector3.Dot(directionToTarget, orientation);
directionToTarget -= d * orientation;
if (directionToTarget.sqrMagnitude > 0.00001f) {
directionToTarget.Normalize();
Quaternion rotationNeeded = Quaternion.LookRotation(directionToTarget, orientation);
Hello Sheets Developer,
We're writing to let you know that Google Sheets v3 API will be shut down on March 3, 2020.
What do I need to know?
The Sheets v4 API, launched in 2016, opened new doors to custom development with programmatic access to critical features like conditional formatting, charts and pivot tables. Since then, we’ve continually improved version 4 by supporting new Sheets features and introducing developer metadata.
As part of the migration to the Sheets v4 API, we will shut down the Sheets v3 API on March 3, 2020.
What do I need to do?
# ca marche
[1, 2, 1, 2, 3, 3].reduce({}) do |memo, i|
memo[i] ||= []
memo[i] << i
memo
end
# ca marche pas
[1, 2, 1, 2, 3, 3].reduce(Hash.new([])) do |memo, i|
memo[i] << i
@niuage
niuage / lala.rb
Last active February 25, 2019 19:02
pipe = "kikou.png"
(1..100).step(0.5) do |time|
begin
retries ||= 0
Timeout::timeout(5) do
fork do
`#{command(time, score_crop_options, pipe)}` # runs ffmpeg, writes frame into `pipe`
exit
end
@niuage
niuage / kik.rb
Created January 21, 2019 22:18
some more dirty experimentation
require 'rmagick'
require 'open3'
def pixel_at(images, x, y)
values = images.map do |image|
color = image.pixel_color(x, y).red
color < 257 * 150 ? 0 : 1
end
res = values.reduce &:|
@niuage
niuage / sobel_operator.rb
Last active January 20, 2019 22:27
Quick and dirty test - implementation of the sobel operator algo
class Img
def initialize(img)
@img = img
@pixels = img.get_pixels(0, 0, img.columns, img.rows)
end
def at(x, y)
pos = x + y * @img.columns
@pixels[pos].red
end