Skip to content

Instantly share code, notes, and snippets.

@iondune
iondune / error.json
Created May 8, 2020 06:08
Gitea error
{"message":"org does not exist [id: 0, name: ]","url":"https://try.gitea.io/api/swagger"}
@iondune
iondune / MinRepo.hlsl
Created May 16, 2019 14:10
Short HLSL shader that causes an internal compiler error
int solve(float x)
{
if (x < 0)
{
return 0;
}
// 1>MinRepo.hlsl(7,2): warning X4000: use of potentially uninitialized variable (solve)
// 1>error X8000 : D3D11 Internal Compiler error : Invalid Bytecode: Negate modifier not allowed for operand #4 of opcode #6 (counts are 1-based).
@iondune
iondune / Copy.cpp
Created June 24, 2018 19:57
Copy texture data from gpu to cpu with Direct3D 11
int const Width = 16;
int const Height = 16;
/////////////////////
// Create Textures //
/////////////////////
ID3D11Texture2D * Texture = nullptr;
ID3D11Texture2D * Staging = nullptr;
@iondune
iondune / visual_studio_cout_debug_output.cpp
Created March 15, 2018 22:18
Write messages from cout to Visual Studio debug output window
// https://stackoverflow.com/a/47312126/1390945
class dbg_stream_for_cout
: public std::stringbuf
{
public:
~dbg_stream_for_cout() { sync(); }
int sync()
{
::OutputDebugStringA(str().c_str());
@iondune
iondune / box2.test1.out
Created June 2, 2017 03:15
[CPE473] printrays output for box2.pov
Pixel: [530, 165] Color: (64, 104, 35)
----
Iteration type: Primary
Ray: {0.0000 0.0000 14.0000} -> {0.4382 -0.1379 -0.8882}
Transformed Ray: {-18.3848 0.0000 8.4853} -> {0.9379 -0.1379 -0.3182}
Hit Object: (ID #4 - Box)
Intersection: {7.6552 -2.4083 -1.5164} at T = 17.4688
Normal: {-0.7071 0.0000 0.7071}
Final Color: {0.2516 0.4061 0.1356}
Ambient: {0.0400 0.0400 0.0400}
@iondune
iondune / valentine2.txt
Created May 31, 2017 19:01
[CPE 473] valentine2.pov sceneinfo with transforms
Camera:
- Location: {0.0000 0.0000 12.0000}
- Up: {0.0000 1.0000 0.0000}
- Right: {1.3333 0.0000 0.0000}
- Look at: {0.0000 0.0000 0.0000}
---
1 light(s)
@iondune
iondune / RayTracer.SchlicksApproximation.Tests.cpp
Created May 24, 2017 06:58
Unit tests for schlick's approximation
TEST_CASE("shlick's approximation")
{
CHECK(CRayTracerMath::SchlicksApproximation(1.02f, vec3f(0, 1, 0), vec3f(0, 1, 0)) == Approx(0.0001f));
CHECK(CRayTracerMath::SchlicksApproximation(1.02f, vec3f(0, 1, 0), vec3f(0.707107f, 0.707107f, 0)) == Approx(0.00225f));
CHECK(CRayTracerMath::SchlicksApproximation(1.02f, vec3f(0, 1, 0), vec3f(0.866025f, 0.5f, 0)) == Approx(0.03134f));
CHECK(CRayTracerMath::SchlicksApproximation(1.02f, vec3f(0, 1, 0), vec3f(0.965926f, 0.258819f, 0)) == Approx(0.22375f));
CHECK(CRayTracerMath::SchlicksApproximation(1.02f, vec3f(0, 1, 0), vec3f(0.996195f, 0.087156f, 0)) == Approx(0.63388f));
}
@iondune
iondune / SPixelContext.h
Created May 12, 2017 05:19
Sample struct to make raytracer diagnostics possible.
struct SPixelContext
{
enum class EIterationType
{
Primary = 0,
Reflection = 1,
Refraction = 2
};
struct SShadowInfo
@iondune
iondune / CMakeLists.txt
Created April 5, 2017 19:26
Basic CPP CMakeLists Template
cmake_minimum_required(VERSION 2.8)
# Name of the project
project(raytrace)
# Use glob to get the list of all source files.
file(GLOB_RECURSE SOURCES "src/*.cpp")
# We don't really need to include header and resource files to build, but it's
# nice to have them show up in IDEs.
@iondune
iondune / CPaintFiller.h
Last active March 1, 2017 23:45
Paint filling algorithm implemented in OO style!
#pragma once
#include <glm/glm.hpp>
namespace Relic
{
class CPaintFiller