This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/////////////////////////////////////////////////// | |
//////////////// grass_struct.hlsl //////////////// | |
/////////////////////////////////////////////////// | |
struct Attributes { | |
float4 positionOS : POSITION; | |
float3 normal : NORMAL; | |
float4 tangent : TANGENT; | |
float2 texcoord : TEXCOORD0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 &:| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |