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
// This gist can be found at https://gist.github.com/bestknighter/660e6a53cf6a6643618d8531f962be2c | |
// I modified Aras Pranckevičius's awesome shader code to be able to handle Infinite and Not A Number numbers | |
// Tested on Unity 2023.1.0a15 with ShaderGraph 15.0.1. | |
// Quick try at doing a "print value" node for Unity ShaderGraph. | |
// | |
// Use with CustomFunction node, with two inputs: | |
// - Vector1 Value, the value to display, | |
// - Vector2 UV, the UVs of area to display at. |
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
// Copyright 2021 Andreas Atteneder | |
// | |
// Licensed under the Apache License, Version 2.0 (the "License"); | |
// you may not use this file except in compliance with the License. | |
// You may obtain a copy of the License at | |
// | |
// http://www.apache.org/licenses/LICENSE-2.0 | |
// | |
// Unless required by applicable law or agreed to in writing, software | |
// distributed under the License is distributed on an "AS IS" BASIS, |
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
// Quick try at doing a "print value" node for Unity ShaderGraph. | |
// Tested on Unity 2019.2.17 with ShaderGraph 6.9.2. | |
// | |
// Use with CustomFunction node, with two inputs: | |
// - Vector1 Value, the value to display, | |
// - Vector2 UV, the UVs of area to display at. | |
// And one output: | |
// - Vector4 Color, the color. | |
// Function name is DoDebug. |
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
/////////////////////////////////////////////////////////////////////////////////////// | |
// Native queue collection with fixed length. FILO. | |
// NativeStack<T> supports writing in IJobParallelFor, just use ParallelWriter and AsParallelWriter(). | |
// Not tested to much, works for me with integers and unity 2019.3 | |
// | |
// Assembled with help of: | |
// - NativeCounter example (https://docs.unity3d.com/Packages/[email protected]/manual/custom_job_types.html) | |
// - How to Make Custom Native Collections (https://jacksondunstan.com/articles/4734) | |
// - source code of NativeQueue and NativeList |
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
// Code ported from https://0fps.net/2012/06/30/meshing-in-a-minecraft-game/ | |
// Note this implementation does not support different block types or block normals | |
// The original author describes how to do this here: https://0fps.net/2012/07/07/meshing-minecraft-part-2/ | |
const int CHUNK_SIZE = 32; | |
// These variables store the location of the chunk in the world, e.g. (0,0,0), (32,0,0), (64,0,0) |
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 System; | |
using System.Collections.Concurrent; | |
using System.Collections.Generic; | |
using System.Runtime.CompilerServices; | |
using System.Threading; | |
using System.Threading.Tasks; | |
using Unity.Jobs; | |
public static class JobHelper | |
{ |
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
// adapted from intersectCube in https://github.com/evanw/webgl-path-tracing/blob/master/webgl-path-tracing.js | |
// compute the near and far intersections of the cube (stored in the x and y components) using the slab method | |
// no intersection means vec.x > vec.y (really tNear > tFar) | |
vec2 intersectAABB(vec3 rayOrigin, vec3 rayDir, vec3 boxMin, vec3 boxMax) { | |
vec3 tMin = (boxMin - rayOrigin) / rayDir; | |
vec3 tMax = (boxMax - rayOrigin) / rayDir; | |
vec3 t1 = min(tMin, tMax); | |
vec3 t2 = max(tMin, tMax); | |
float tNear = max(max(t1.x, t1.y), t1.z); |