Skip to content

Instantly share code, notes, and snippets.

View tombasche's full-sized avatar

Thomas Basche tombasche

  • Helsinki, Finland
View GitHub Profile
@tombasche
tombasche / Gerstner.hlsl
Created October 23, 2025 07:18
Gerstner wave shader include
float3 GerstnerWave(float3 position, float steepness, float wavelength, float speed, float direction, inout float3 tangent, inout float3 binormal)
{
direction = direction * 2 - 1;
float2 d = normalize(float2(cos(3.14 * direction), sin(3.14 * direction)));
float k = 2 * 3.14 / wavelength;
float f = k * (dot(d, position.xz) - speed * _Time.y);
float a = steepness / k;
tangent += float3(
-d.x * d.x * (steepness * sin(f)),
@tombasche
tombasche / BuoyantObject.cs
Created October 21, 2025 19:13
Water buoyancy in Unity
/*
Attach this to an object you want to "float" on a surface.
For this component to work you need to supply an array of Transforms indicating the points
on the object that will have the buoyancy applied to it. For instance, a cube may have points on each corner touching the surface.
*/
using UnityEngine;
@tombasche
tombasche / MazeGenerator.cs
Created November 9, 2024 09:42
Generating a "perfect" maze using recursive backtracking
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
public class MazeGenerator : MonoBehaviour
{
[SerializeField]
int seed;
@tombasche
tombasche / blender_batch_export.py
Created October 30, 2024 11:18
Batch export selected objects from Blender to FBX
import bpy
import os
from copy import copy
# export to blend file location
basedir = os.path.dirname(bpy.data.filepath)
if not basedir:
raise Exception("Blend file is not saved")
@tombasche
tombasche / CameraController.cs
Created December 9, 2023 08:25
cinemachine top down camera
using UnityEngine;
using Cinemachine;
public class CameraController : MonoBehaviour
{
[SerializeField] private CinemachineVirtualCamera cinemachineVirtualCamera;
private const float MIN_FOLLOW_Y_OFFSET = 2f;
private const float MAX_FOLLOW_Y_OFFSET = 12f;
@tombasche
tombasche / EmailClientConfiguration.kt
Last active August 18, 2021 16:20
SES Email client config + Sprint + Kotlin
package com.myapplication.email
import org.springframework.beans.factory.annotation.Value
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import software.amazon.awssdk.regions.Region
import software.amazon.awssdk.services.ses.SesClient
@Configuration
class EmailClientConfiguration {
@tombasche
tombasche / EmailClient.kt
Created August 18, 2021 16:11
Basic email client using AWS SES + Spring + Kotlin
package com.myapplication.email
import arrow.core.Either
import org.springframework.stereotype.Component
import software.amazon.awssdk.services.ses.SesClient
import software.amazon.awssdk.services.ses.model.Body
import software.amazon.awssdk.services.ses.model.Content
import software.amazon.awssdk.services.ses.model.Destination
import software.amazon.awssdk.services.ses.model.Message
import software.amazon.awssdk.services.ses.model.SendEmailRequest
@tombasche
tombasche / EmailTests.kt
Last active August 18, 2021 16:24
Sample test using localstack + testcontainers in Spring
package com.myapplication.email
import arrow.core.Either
import org.junit.jupiter.api.Assertions.fail
import org.junit.jupiter.api.Test
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.test.context.ActiveProfiles
import org.testcontainers.containers.localstack.LocalStackContainer
import org.testcontainers.utility.DockerImageName
import software.amazon.awssdk.auth.credentials.AwsBasicCredentials
@tombasche
tombasche / SecurityConfig.kt
Last active August 11, 2021 15:36
Spring boot security config to allow preflight requests
import org.springframework.web.cors.CorsUtils
import org.springframework.context.annotation.Configuration
import org.springframework.security.config.annotation.web.builders.HttpSecurity
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter
@Configuration
class SecurityConfig : WebSecurityConfigurerAdapter() {
override fun configure(http: HttpSecurity) {
http
.authorizeRequests()
@tombasche
tombasche / WebServerConfiguration.kt
Created August 11, 2021 15:14
Spring boot (kotlin) Web Server Config for CORS
package com.myapplication
import org.springframework.beans.factory.annotation.Value
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.web.servlet.config.annotation.CorsRegistry
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer
@Configuration
class WebServerConfiguration {