Skip to content

Instantly share code, notes, and snippets.

View hasenbanck's full-sized avatar

Nils Hasenbanck hasenbanck

  • Hamburg, Germany
View GitHub Profile
@anataliocs
anataliocs / CacheConfig.java
Last active August 4, 2024 04:24
Guava cache with spring boot and clear cache method
import com.google.common.cache.CacheBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.CachingConfigurer;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cache.guava.GuavaCache;
import org.springframework.cache.interceptor.CacheErrorHandler;
import org.springframework.cache.interceptor.CacheResolver;
import org.springframework.cache.interceptor.KeyGenerator;
@crearo
crearo / fragment_shader_NV12_to_RGB.frag
Last active August 1, 2024 01:57
A fragment shader to convert NV12 to RGB.
/** A fragment shader to convert NV12 to RGB.
* Input textures Y - is a block of size w*h.
* texture UV is of size w*h/2.
* Remember, both U and V are individually of size w/2*h/2, but they are interleaved.
* The layout looks like this :
* ----------
* | |
* | Y | size = w*h
* | |
* |________|
@hasenbanck
hasenbanck / intersection.wgsl
Last active October 28, 2024 11:04
very fast cone / sphere intersection test
/// While implementing a tile based light culling shader, I stumbled uppon the bachelor thesis from Jonathan W. Hale:
/// "Dual-Cone View Culling for Virtual Reality Applications" (2018). While lookin at his final version, I
/// realized that his code could be even further simplified, if the cone's tip is the origin of the coordinate system.
/// By creating a "world to cone view space" transformation matrix, that aligns the code to the positive +Z axis and
/// also set's the cone's tip as the origin, this matrix can then be used to transform the world coordinates into the
/// "cone view space". The following code uses a left handed coordinate system.
/// The test itself only uses 10 instructions:
///
/// - 2 scalar multiplications
/// - 2 additions