Skip to content

Instantly share code, notes, and snippets.

@Popov72
Popov72 / webgpuShadow.html
Created July 5, 2021 10:52
Error using shadowSampler in WebGPU
<html>
<body>
<script>
const canvas = document.createElement('canvas');
canvas.width = 600;
canvas.height = 600;
document.body.appendChild(canvas);
@Popov72
Popov72 / webgpu_shadow.ts
Created November 2, 2020 21:39
Simple WebGPU sample using shadow sampler
import glslangModule from '../glslang';
export const title = 'Hello Triangle';
export const description = 'Shows rendering a basic triangle.';
export async function init(canvas: HTMLCanvasElement) {
const vertexShaderGLSL = `#version 450
const vec2 pos[3] = vec2[3](vec2(0.0f, 0.5f), vec2(-0.5f, -0.5f), vec2(0.5f, -0.5f));
void main() {
@Popov72
Popov72 / using_pix_with_canary.md
Last active February 14, 2024 04:36
Using PIX with Chrome

In PIX, Select Target Process => Launch Win32 and set the following 2 entries according to where Canary / Chrome is installed:

  • Path to executable: "C:\Users\alexis\AppData\Local\Google\Chrome SxS\Application\chrome.exe"
  • Working directory: "C:\Users\alexis\AppData\Local\Google\Chrome SxS\Application"
  • Command line arguments: --disable-gpu-sandbox --disable-direct-composition
    • You can add those arguments if you want to be able to see the disassembled shader code: --enable-dawn-features=emit_hlsl_debug_symbols,disable_symbol_renaming
  • Launch Suspended unchecked, Launch for GPU capture and Force D3D11On12 checked

Then click on "Launch".

Important: you should close all your Canary / Chrome windows/processes before clicking on the "Launch" button!

@Popov72
Popov72 / playground.js
Created October 24, 2019 12:00
Babylon playground for simple custom ShaderMaterial
var createScene = function() {
var scene = new BABYLON.Scene(engine);
var camera = new BABYLON.ArcRotateCamera("Camera", - Math.PI / 2, Math.PI / 4, 10, BABYLON.Vector3.Zero(), scene);
camera.attachControl(canvas, true);
BABYLON.Effect.ShadersStore["customVertexShader"]= `
precision highp float;
// Attributes
@Popov72
Popov72 / gist:7e856b2589f659b2e9ff7ca0a7a6f815
Created October 23, 2019 22:32
Linearize / Delinearize z depth values in fragment shaders
uniform float zNear = 0.1;
uniform float zFar = 500.0;
// depthSample from depthTexture.r, for instance
float linearDepth(float depthSample)
{
depthSample = 2.0 * depthSample - 1.0;
float zLinear = 2.0 * zNear * zFar / (zFar + zNear - depthSample * (zFar - zNear));
return zLinear;
}