Skip to content

Instantly share code, notes, and snippets.

@da-molchanov
da-molchanov / ue4_aces_tonemapping.hlsl
Last active December 1, 2024 04:18
Simple custom ACES tonemapper that approximates the default UE4 filmic tonemapper in 11 instructions.
// Copyright 2021 Dmitry Molchanov and Julia Molchanova
// This code is licensed under the MIT license
// Output type: CMOT float 3
// Input name: LinearColor
// This multiplier corresponds to "ExposureCompensation=1" and disabled auto exposure
const float ExposureMultiplier = 1.4;
const float3x3 PRE_TONEMAPPING_TRANSFORM =
@mgsx-dev
mgsx-dev / BlendingExportDemo.java
Last active February 25, 2021 00:13
How to draw into a FBO with proper blending function and save it to a PNG file
import com.badlogic.gdx.Game;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Pixmap;
import com.badlogic.gdx.graphics.PixmapIO;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
@samsheffield
samsheffield / UnityCodingCheatSheet.txt
Last active December 31, 2024 20:18
Unity C# Cheat Sheet
// Unity C# Cheat Sheet
// I made these examples for students with prior exerience working with C# and Unity.
// Too much? Try Unity's very good tutorials to get up to speed: https://unity3d.com/learn/tutorials/topics/scripting
@lukz
lukz / PerspectiveGroup.java
Last active June 8, 2016 20:47
Group that allows to change its perspective along X axis (will be very simple to change axis) using orthographic camera and Scene2d. You have to set camera.near = -1000 and camera.far = 1000 on your OrthographicCamera.
package om.mandir.gdx.utils.actors;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.math.Affine2;
import com.badlogic.gdx.math.Matrix4;
import com.badlogic.gdx.scenes.scene2d.Group;
/**
* Allows to render Group in perspective.
*
@eevee
eevee / perlin.py
Last active December 11, 2024 15:24
Perlin noise in Python
"""Perlin noise implementation."""
# Licensed under ISC
from itertools import product
import math
import random
def smoothstep(t):
"""Smooth curve with a zero derivative at 0 and 1, making it useful for
interpolating.
@xoppa
xoppa / PolygonShapeTest.java
Created July 5, 2015 13:05
Shows how to render primitive shapes using Batch, without using ShapeRenderer. Requires at least libGDX 1.6.4 or latest nightly.
package com.badlogic.gdx.tests.g2d;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Mesh;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.VertexAttribute;
import com.badlogic.gdx.graphics.VertexAttributes;
import com.badlogic.gdx.graphics.VertexAttributes.Usage;
@staltz
staltz / introrx.md
Last active December 29, 2024 21:56
The introduction to Reactive Programming you've been missing
@subudeepak
subudeepak / WebSockets.md
Last active December 4, 2024 13:36
The problems and some security implications of websockets - Cross-site WebSockets Scripting (XSWS)

WebSockets - An Introduction

WebSockets is a modern HTML5 standard which makes communication between client and server a lot more simpler than ever. We are all familiar with the technology of sockets. Sockets have been fundamental to network communication for a long time but usually the communication over the browser has been restricted. The general restrictions

  • The server used to have a permanent listener while the client (aka browser) was not designated any fixed listener for a more long term connection. Hence, every communication was restricted to the client demanding and the server responding.
  • This meant that unless the client requested for a particular resource, the server was unable to push such a resource to the client.
  • This was detrimental since the client is then forced to check with the server at regular intervals. This meant a lot of libraries focused on optimizing asynchronous calls and identifying the response of asynchronous calls. Notably t
@gabrielemariotti
gabrielemariotti / build.gradle
Last active November 22, 2024 19:55
Use signing.properties file which controls which keystore to use to sign the APK with gradle.
android {
signingConfigs {
release
}
buildTypes {
release {
signingConfig signingConfigs.release
}