Skip to content

Instantly share code, notes, and snippets.

View 1502shivam-singh's full-sized avatar
🍀
Always learning

Shivam Singh 1502shivam-singh

🍀
Always learning
View GitHub Profile
@1502shivam-singh
1502shivam-singh / MultiLevelQueue.cpp
Created April 2, 2021 22:39
Multi-level queue scheduling (Using FCFS and Round Robin scheduling on individual queues)
#include <iostream>
#include <queue>
#include <vector>
#include <unordered_map>
typedef uint32_t uint;
struct process {
uint32_t pid;
uint32_t atime;
@1502shivam-singh
1502shivam-singh / customAttributes.js
Last active February 17, 2021 23:36
Snippet to add a custom attribute to each vertex of buffergeometry in three.js
// Snippet to look under a buffergeometry and add a custom attribute for each vertex
let geometry = new THREE.PlaneBufferGeometry(5, 5, 5, 5); // for example
let count = geometry.attributes.position.length;
let arrSize = new THREE.BufferAttribute(new Float32Array(count), 1); // Here "1" is the places the attribute would take
for(let i=0;i<arrSize.count; i++){
arrSize.array[i] = Math.random(); // Assigning a random value as attribute here
}
geometry.addAttribute("aSize", arrSize, 1); // Access in shader later
@patriciogonzalezvivo
patriciogonzalezvivo / GLSL-Noise.md
Last active December 7, 2025 11:08
GLSL Noise Algorithms

Please consider using http://lygia.xyz instead of copy/pasting this functions. It expand suport for voronoi, voronoise, fbm, noise, worley, noise, derivatives and much more, through simple file dependencies. Take a look to https://github.com/patriciogonzalezvivo/lygia/tree/main/generative

Generic 1,2,3 Noise

float rand(float n){return fract(sin(n) * 43758.5453123);}

float noise(float p){
	float fl = floor(p);
  float fc = fract(p);