This file contains hidden or 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
@group(0) @binding(0) var gBufferNormal: texture_2d<f32>; | |
@group(0) @binding(1) var gBufferAlbedo: texture_2d<f32>; | |
@group(0) @binding(2) var gBufferDepth: texture_depth_2d; | |
struct LightData { | |
position : vec4<f32>, | |
color : vec3<f32>, | |
radius : f32, | |
} |
This file contains hidden or 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 System; | |
using System.Runtime.InteropServices; | |
using System.Runtime.CompilerServices; | |
using Range = System.Range; | |
public unsafe struct Arena { | |
UnmanagedArray<Optional<Block>> _blocks; | |
int _currentBlockIndex; |
This file contains hidden or 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
package main | |
import "core:fmt" | |
DangerStruct :: struct { | |
guid: u128, | |
value: u64, | |
} | |
SafeStruct1 :: struct { |
This file contains hidden or 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 System; | |
using System.Collections; | |
using System.Collections.Generic; | |
using System.Runtime.InteropServices; | |
using UnityEngine; | |
using Object = UnityEngine.Object; | |
// This is a System.Guid, except it can be serialized by Unity, | |
// so it can be used to permanently store the ID of an entity. |
This file contains hidden or 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
package main | |
import "core:fmt" | |
import "vendor:directx/d3d11" | |
import "vendor:directx/d3d_compiler" | |
import "vendor:directx/dxgi" | |
import SDL "vendor:sdl2" | |
import "core:unicode/utf16" | |
WINDOW_WIDTH : i32 = 1280 |
This file contains hidden or 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
use std::borrow::Cow; | |
use winit::{ | |
event::*, | |
event_loop::{ControlFlow, EventLoop}, | |
window::Window, | |
}; | |
struct AppState { | |
surface: wgpu::Surface, | |
device: wgpu::Device, |
This file contains hidden or 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; | |
using Unity.Mathematics; | |
using static Unity.Mathematics.math; | |
[ExecuteInEditMode] | |
public class Bezier : MonoBehaviour { | |
public Vector3 a; | |
public Vector3 b; | |
public Vector3 c; |
This file contains hidden or 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 Unity.Mathematics; | |
using UnityEngine; | |
using System.Diagnostics; | |
public class MathematicsTests : MonoBehaviour { | |
const int NUM_TESTS = 1_000_000; | |
void Test() { | |
Matrix4x4 identityMatrix4x4 = Matrix4x4.identity; |
This file contains hidden or 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
// Sometimes, RenderTexture.GetTemporary() and RenderTexture.ReleaseTemporary() leak textures. | |
// For those times, there is RenderTexturePool. | |
using System.Collections.Generic; | |
using Unity.Collections; | |
using UnityEngine; | |
public class RenderTexturePool { | |
readonly Dictionary<RenderTextureDescriptor, List<RenderTextureCounter>> _pool; | |
readonly int _initialListCapacity; |
This file contains hidden or 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
public static class NativeListExtensions { | |
public static unsafe void UnsafeAddRange<T>(this NativeList<T> nativeList, void* ptr, int length) where T: struct { | |
int idx = nativeList.Length; | |
int newCount = idx + length; | |
if (nativeList.Capacity < newCount) { | |
nativeList.Resize(nativeList.Capacity + length, NativeArrayOptions.UninitializedMemory); | |
} | |
nativeList.Length = newCount; | |
int stride = UnsafeUtility.SizeOf<T>(); |
NewerOlder