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
custom_math::vector_3 grav_acceleration(const custom_math::vector_3 &pos, const custom_math::vector_3 &vel, const double G) | |
{ | |
custom_math::vector_3 grav_dir = sun_pos - pos; | |
float distance = grav_dir.length(); | |
grav_dir.normalize(); | |
float alpha = (vel.length()*vel.length()) / (speed_of_light * speed_of_light); | |
alpha = pow(alpha, 0.01); // suit to taste |
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
#include <iostream> | |
#include <fstream> | |
#include <complex> | |
#include <vector> | |
using namespace std; | |
#include "Eigen/Dense" | |
using Eigen::VectorXcf; | |
using Eigen::VectorXf; |
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
layout(location = 2) rayPayloadEXT bool shadowed; | |
bool is_clear_line_of_sight(vec3 pos_start, const vec3 pos_end) | |
{ | |
shadowed = true; // Make sure to set this to the default before tracing the ray! | |
traceRayEXT(topLevelAS, gl_RayFlagsTerminateOnFirstHitEXT | gl_RayFlagsOpaqueEXT | gl_RayFlagsSkipClosestHitShaderEXT, 0xFF, 0, 0, 1, pos_start, 0.001, pos_end, 10000.0, 2); | |
return !shadowed; | |
} |
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
float trace_path2(out vec3 final_pos, const int steps, const vec3 origin, const vec3 direction, const float hue, float eta) | |
{ | |
const RayPayload r = rayPayload; | |
vec3 hitPos = vec3(0.0); | |
float ret_colour = 0; | |
vec3 o = origin; |
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
vec3 o_reflect = hitPos + rayPayload.normal * 0.01; | |
vec3 d_reflect = reflect(d, rayPayload.normal); | |
vec3 temp_o = o_reflect; | |
vec3 temp_d = d_reflect; | |
if(rayPayload.reflector < 1.0) // if less than fully reflective, do scattering | |
{ | |
vec3 o_scatter = hitPos + rayPayload.normal * 0.01; | |
vec3 d_scatter = cosWeightedRandomHemisphereDirection(rayPayload.normal, prng_state); |
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
void main() | |
{ | |
const int steps = 10; | |
float max_hue = rgb2hsv(vec3(1.0, 0.0, 1.0)).x; | |
float min_hue = rgb2hsv(vec3(1.0, 0.0, 0.0)).x; | |
const float max_eta = 0.9; | |
const float min_eta = 0.6; |
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
#version 460 | |
#extension GL_EXT_ray_tracing : require | |
#extension GL_EXT_nonuniform_qualifier : enable | |
struct RayPayload { | |
vec3 color; | |
vec3 pure_color; | |
float distance; | |
vec3 normal; |
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
#include "VulkanRaytracingSample.h" | |
#include "VulkanglTFModel.h" | |
#include <vector> | |
using std::vector; | |
#include <fstream> | |
using std::ofstream; | |
#include <ios> |
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
virtual void render() | |
{ | |
if (!prepared) | |
return; | |
VulkanExampleBase::prepareFrame(); | |
submitInfo.commandBufferCount = 1; | |
submitInfo.pCommandBuffers = &drawCmdBuffers[currentBuffer]; | |
VK_CHECK_RESULT(vkQueueSubmit(queue, 1, &submitInfo, fence)); |
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
... | |
VkBufferImageCopy copyRegion{}; | |
copyRegion.bufferOffset = 0; | |
copyRegion.bufferRowLength = 0; | |
copyRegion.bufferImageHeight = 0; | |
copyRegion.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; | |
copyRegion.imageSubresource.mipLevel = 0; | |
copyRegion.imageSubresource.baseArrayLayer = 0; |
NewerOlder