GithubHelp home page GithubHelp logo

eirys / ft_vox Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 13.9 MB

A procedural voxel terrain rendering engine in C++ and Vulkan

License: Apache License 2.0

Makefile 1.12% GLSL 3.25% C++ 95.00% C 0.58% Dockerfile 0.04%
cpp engine game perlin-noise real-time-rendering terrain vulkan

ft_vox's Introduction

ft_vox

A voxel rendering engine in C++ and Vulkan

The main challenge is to have nice performances in rendering fluidity.

ft_vox's People

Contributors

eirys avatar

Watchers

 avatar

ft_vox's Issues

Fix pos building

CPP code

inline int32_t	toChunkPos(float x, float y, float z) noexcept {
	// TODO: Add render distance in ubo
	int32_t chunk_address =
		(int32_t)x / CHUNK_SIZE |
		((int32_t)z / CHUNK_SIZE) << 8 |
		((int32_t)y / CHUNK_SIZE) << 16;

	x = (int32_t)x % CHUNK_SIZE;
	y = (int32_t)y % CHUNK_SIZE;
	z = (int32_t)z % CHUNK_SIZE;

	return
		static_cast<int32_t>(x) |
		static_cast<int32_t>(y) << 4 |
		static_cast<int32_t>(z) << 8 |
		chunk_address << 12;
}

HLSL code

// Extract actual vertex position from input
float4	extractPos(int input) {
	// Local position in chunk
	float3	pos = float3(
		input & 0xF,
		(input >> 4) & 0xF,
		(input >> 8) & 0xF);
	
	// Chunk position in world
	int chunk_x = (input >> 12) & 0xFF;
	int chunk_z = (input >> 20) & 0xFF;
	int chunk_y = (input >> 28) & 0xF;
	
	return float4(
		(chunk_x * 16) + pos.x,
		(chunk_y * 16) + pos.y,
		(chunk_z * 16) + pos.z,
		1.0
	);
}

Change `cursor++` to `++cursor`

Actually, it's a Windows feature:
Every line feed (\LF) on Linux are actually interpreted as carriage-return/line-feed (\CRLF).
The "fix" is in the readExcept lambda function:

ParseNumberFn	readExcept = [this]() -> uint8_t {
	if (cursor >= base::data.size()) {
		throw PpmParseError("unexpected end of file");
	}
	// replace `cursor++` to `++cursor`:
	return base::data[++cursor];
};

Fix function comment

In matrix.cpp, comment is "Produces orthographic projection matrix" l.422.
Replace with "Produces perspective projection matrix".

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.