Skip to content

Instantly share code, notes, and snippets.

View mkvenkit's full-sized avatar

Mahesh Venkitachalam mkvenkit

View GitHub Profile
@mkvenkit
mkvenkit / VL53L1X.cpp
Created November 15, 2021 16:25
This code sends VL53L1X 12 x 12 or 8 x 8 ROI distance data over serial.
/*
This code sends VL53L1X 12 x 12 or 8 x 8 ROI distance data over serial.
Python code for plottomg:
import serial
import struct
import numpy as np
@mkvenkit
mkvenkit / nocg_torus_bm.frag
Created June 27, 2021 02:41
Fragment shader for bump mapping
#version 450 core
uniform bool enableRimLight;
uniform sampler2D sampler;
in VS_OUT {
in vec3 L;
in vec3 V;
in vec2 tc;
} fs_in;
@mkvenkit
mkvenkit / nocg_torus_bm.vert
Created June 27, 2021 02:39
Vertex shader for bump mapping
#version 450 core
layout(location = 0) in vec3 aVert;
layout(location = 1) in vec3 aNorm;
layout(location = 2) in vec2 aTexCoord;
layout(location = 3) in vec3 aTangent;
uniform mat4 vMat;
uniform mat4 pMat;
uniform mat4 mMat;
@mkvenkit
mkvenkit / make_bmap.py
Created June 26, 2021 15:59
Make a bump map
import numpy as np
from PIL import Image
from math import sqrt
def main():
NX, NY = 256, 256
nmap = np.zeros([NX, NY, 3], np.float32)
@mkvenkit
mkvenkit / nocg_torus_pt1.frag
Created June 26, 2021 15:21
Procedural texture shader
// stripes
float val = clamp(round(sin( 20 * fs_in.tc.x * 3.14156)), 0, 1);
vec3 col1 = vec3(255, 237, 81) / 255.0;
vec3 col2 = vec3(133, 202, 93) / 255.0;
vec3 col = mix(col1, col2, val);
@mkvenkit
mkvenkit / nocg_rim.vert
Created June 26, 2021 12:10
Rim lighting shader
float rim = (1.0 - dot(N, V));
rim = smoothstep(0.0, 1.0, rim);
float rim_exp = 3.5;
rim = pow(rim, rim_exp);
vec3 rim_col = vec3(0.1, 0.1, 0.1);
crim = rim * rim_col;
@mkvenkit
mkvenkit / nocg_torus_p.frag
Created June 26, 2021 07:08
Fragment shader for Phong shading
#version 450 core
uniform bool enableRimLight;
in VS_OUT {
in vec3 N;
in vec3 L;
in vec3 V;
} fs_in;
@mkvenkit
mkvenkit / nocg_torus_p.vert
Last active June 27, 2021 13:16
Vertex shader for Phong shading
#version 450 core
layout(location = 0) in vec3 aVert;
layout(location = 1) in vec3 aNorm;
uniform mat4 vMat;
uniform mat4 pMat;
uniform mat4 mMat;
out VS_OUT {
@mkvenkit
mkvenkit / nocg_torus_t.frag
Last active June 27, 2021 13:18
Fragment shader for torus - Texture Mapping
#version 450 core
uniform bool enableRimLight;
uniform sampler2D sampler;
in VS_OUT {
in vec3 N;
in vec3 L;
in vec3 V;
in vec2 tc;
@mkvenkit
mkvenkit / simple_audio_pi_gist2.py
Last active January 17, 2021 02:50
simple_audio_pi NN
model.compile(
optimizer=tf.keras.optimizers.Adam(),
loss=tf.keras.losses.SparseCategoricalCrossentropy(from_logits=True),
metrics=['accuracy'],
)
EPOCHS = 10
history = model.fit(
train_ds,
validation_data=val_ds,