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
CGPROGRAM | |
// Pass a clean copy of the VP matrix. | |
// Shader.SetGlobalMatrix("_MyMatrixVP", Camera.current.projectionMatrix*Camera.current.worldToCameraMatrix); | |
// Unity applies poorly documented magic to UNITY_MATRIX_VP that you don't want. | |
float4x4 _MyMatrixVP; | |
struct VertexOutput { | |
// Pass the screen space coordinate as a new varying. | |
// Don't re-use SV_POSITION in your frag shader, it only works on non-DirectX platforms IIRC. | |
float4 screenSpace : TEXCOORD1; |
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
using UnityEngine; | |
[ExecuteInEditMode] | |
public class ProjectedBounds : MonoBehaviour { | |
private Transform _transform; | |
private Renderer _renderer; | |
private Mesh _mesh; | |
private MaterialPropertyBlock _block; | |
private void Start(){ |
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
#include <stdint.h> | |
#include <stdlib.h> | |
#include <stdio.h> | |
#include <string.h> | |
#include <math.h> | |
static const size_t COUNT = 64*(1<<20); | |
typedef float FLOAT_T; |
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
#include <stdint.h> | |
#include <stdio.h> | |
#include "disassembler.h" | |
// 6502 instruction tables. | |
enum OPCODE { | |
OP_LDA, OP_LDX, OP_LDY, OP_STA, OP_STX, OP_STY, OP_ADC, OP_SBC, | |
OP_INC, OP_INX, OP_INY, OP_DEC, OP_DEX, OP_DEY, OP_ASL, OP_LSR, | |
OP_ROL, OP_ROR, OP_AND, OP_ORA, OP_EOR, OP_CMP, OP_CPX, OP_CPY, |
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
// 'coord.y' is the clip space y-coordinate of the pixel on the water. | |
// 'ray0.y/ray0.w' is the clip space y-coordinate of the reflected pixel. | |
// The basic idea is near the horizion where the reflected point is close to the water, | |
// you should have a strong reflection. The further it gets from the horizon the more it should be blurred vertically. | |
// The result is pretty good. :D | |
float aniso = _SSRAniso*abs(coord.y - ray0.y/ray0.w); | |
float2 ddy_uv = max(ddy(uv), float2(0, aniso)); | |
... | |
float4 color = tex2Dgrad(_CameraColorTexture, uv, ddx(uv), ddy_uv); |
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
section "lz4-data", hram | |
token: db ; Most recently read token. | |
backref: dw | |
; NOTES: | |
; dst/src is always stored in de/hl | |
section "lz4-code", rom0 |
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
static void px_ppu_sync_off(){ | |
px_mask &= ~PX_MASK_RENDER_ENABLE; | |
px_wait_nmi(); | |
// Without these I get a few garbage lines at the top of the screen | |
waitvsync(); | |
waitvsync(); | |
} | |
static void px_ppu_sync_on(){ |
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
#ifndef NACO_H | |
#define NACO_H | |
#include <stdint.h> | |
#include <stdlib.h> | |
typedef uintptr_t (*naco_func)(uintptr_t); | |
void naco_init(naco_func func, void *naco_buffer, size_t buffer_size); | |
uintptr_t naco_yield(uintptr_t value); |
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
#ifndef CORO_H | |
#define CORO_H | |
#include <stdint.h> | |
typedef uintptr_t (*coro_func)(uintptr_t); | |
void coro_start(coro_func func); | |
uintptr_t coro_yield(uintptr_t); | |
uintptr_t coro_resume(uintptr_t); |
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
.include "zeropage.inc" | |
.macpack generic | |
.import pusha, popa | |
.import pushax | |
.import addysp, subysp | |
.import _exit | |
.data |