Skip to content

Instantly share code, notes, and snippets.

@mdomrach
mdomrach / ScreenshotDepth
Created August 14, 2017 13:47
ScreenshotDepth
void FVulkanScreenGrab::ScreenshotDepth(FVulkanDevice vulkanDevice, FVulkanSwapChain swapChain, VkCommandPool commandPool, VkQueue queue, VkImage srcImage, const char* filename)
{
// Get format properties for the swapchain color format
VkFormatProperties formatProps;
auto depthFormat = FVulkanCalculator::FindDepthFormat(vulkanDevice.physicalDevice);
// Check if the device supports blitting from optimal images (the swapchain images are in optimal format)
vkGetPhysicalDeviceFormatProperties(vulkanDevice.physicalDevice, depthFormat, &formatProps);
if (!(formatProps.optimalTilingFeatures & VK_FORMAT_FEATURE_TRANSFER_SRC_BIT_KHR))
{
@mdomrach
mdomrach / CreateRenderPass
Created August 14, 2017 13:46
CreateRenderPass
void FVulkanApplication::CreateRenderPass()
{
VkAttachmentDescription colorAttachment = {};
colorAttachment.format = swapChain.colorFormat;
colorAttachment.samples = VK_SAMPLE_COUNT_1_BIT;
colorAttachment.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
colorAttachment.storeOp = VK_ATTACHMENT_STORE_OP_STORE;
colorAttachment.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
colorAttachment.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
colorAttachment.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
@mdomrach
mdomrach / CreateDepthResources
Created August 14, 2017 13:46
CreateDepthResources
void FVulkanApplication::CreateDepthResources()
{
VkFormat depthFormat = FVulkanCalculator::FindDepthFormat(vulkanDevice.physicalDevice);
FVulkanImageCalculator::CreateImage(vulkanDevice, swapChain.extent.width, swapChain.extent.height, depthFormat,
VK_IMAGE_TILING_OPTIMAL, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT,
depthImage, depthImageMemory);
depthImageView = FVulkanFactory::ImageView(vulkanDevice.logicalDevice, depthImage, depthFormat, VK_IMAGE_ASPECT_DEPTH_BIT);
FVulkanImageCalculator::TransitionImageLayout(
vulkanDevice.logicalDevice, commandPool, graphicsQueue,
depthImage, depthFormat, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL);
void FVulkanApplication::CreateDepthResources()
{
VkFormat depthFormat = FVulkanCalculator::FindDepthFormat(vulkanDevice.physicalDevice);
FVulkanImageCalculator::CreateImage(vulkanDevice, swapChain.extent.width, swapChain.extent.height, depthFormat,
VK_IMAGE_TILING_OPTIMAL, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT,
depthImage, depthImageMemory);
depthImageView = FVulkanFactory::ImageView(vulkanDevice.logicalDevice, depthImage, depthFormat, VK_IMAGE_ASPECT_DEPTH_BIT);
FVulkanImageCalculator::TransitionImageLayout(
vulkanDevice.logicalDevice, commandPool, graphicsQueue,
depthImage, depthFormat, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL);
using UnityEngine;
using System.Collections.Generic;
public class Tile : MonoBehaviour {
public Tile pathParent;
public int gScore;
public int fScore;
public List<Tile> neighbors = new List<Tile>();
}
using UnityEngine;
using System.Collections.Generic;
public class Search : MonoBehaviour
{
int gridSize = 10;
void Start()
{
Tile[,] tiles = new Tile[gridSize, gridSize];
for (int x = 0; x < gridSize; x++)
using UnityEngine;
using System.Collections.Generic;
[RequireComponent(typeof(MeshRenderer))]
[RequireComponent(typeof(MeshFilter))]
public class GridMesh : MonoBehaviour
{
public int GridSize;
void Awake()