Giter Club home page Giter Club logo

3d-graphics-rendering-cookbook's People

Contributors

capnramses avatar corporateshark avatar disusdev avatar divyavijayan123 avatar gcem avatar ghidosoft avatar josepha-packt avatar mohammedyusufimaratwale avatar packt-itservice avatar packtutkarshr avatar paulbglodon avatar resetius avatar zalexx91 avatar zixin96 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

3d-graphics-rendering-cookbook's Issues

MultiMeshRenderer::updateIndirectBuffers, vkMapMemory size seems wrong

vkMapMemory(vkDev.device, indirectBuffersMemory_[currentImage], 0, 2 * sizeof(VkDrawIndirectCommand), 0, (void **)&data);

void MultiMeshRenderer::updateIndirectBuffers(VulkanRenderDevice& vkDev, size_t currentImage, bool* visibility)
{
	VkDrawIndirectCommand* data = nullptr;
	vkMapMemory(vkDev.device, indirectBuffersMemory_[currentImage], 0, 2 * sizeof(VkDrawIndirectCommand), 0, (void **)&data);

	for (uint32_t i = 0 ; i < maxShapes_ ; i++)
	{
		const uint32_t j = shapes[i].meshIndex;
		const uint32_t lod = shapes[i].LOD;
		data[i] = {
			.vertexCount = meshData_.meshes_[j].getLODIndicesCount(lod),
			.instanceCount = visibility ? (visibility[i] ? 1u : 0u) : 1u,
			.firstVertex = 0,
			.firstInstance = i
		};
	}
	vkUnmapMemory(vkDev.device, indirectBuffersMemory_[currentImage]);
}

the size passed to vkMapMemory is set to 2*sizeof(VkDrawIndirectCommand), should this be maxShapes_ * sizeof(VkDrawIndirectCommand)?

Missing include directories

After bootstrapping, running

C:\3D-Graphics-Rendering-Cookbook\Chapter5\GL01_Grid\build> cmake .. -G "Visual Studio 16 2019" -A x64

then

C:\3D-Graphics-Rendering-Cookbook\Chapter5\GL01_Grid\build> cmake --build . --config Release

yields:

C:\3D-Graphics-Rendering-Cookbook\Chapter5\GL01_Grid\src\main.cpp(5,10): fatal error C1083: Cannot open include file: 'shared/glFramework/GLFWApp.h': No such file or directory [C:\3D-Graphics-Rendering-Cookbook\Chapter5\GL01_Grid\build\Ch5_SampleGL01_Grid.vcxproj]

Cannot open shader file

  • Visual Studio 2022
  • Os : Windows 11

After building everything,
========== Build: 57 succeeded, 0 failed, 16 up-to-date, 3 skipped ==========

But when running : \build\Chapter3\VK01_GLSLang\Debug>Ch3_SampleVK01_GLSLang_Debug.exe, the window closes immediately, and when executing it in command prompt, the following error occurs :

I/O error. Cannot open shader file 'data/shaders/chapter03/VK01.vert'
I/O error. Cannot open shader file 'data/shaders/chapter03/VK01.frag'

Both shaders files are present in the data/ directory.

Black spot in PBR implementation

Thank you for this awesome book. I discovered this black spot in the PBR implementation and wonder what the cause is.

Screenshot from 2022-02-27 20-37-29
Screenshot from 2022-02-27 20-36-41

It's present in the Vulkan and OpenGL implementation and was captured on an Nvidia GTX 1060 on Linux.

Just for the record:
Seems to be fixed with this change in the PBR.sp shader

vec2 brdfSamplePoint = clamp(vec2(pbrInputs.NdotV, 1.0 pbrInputs.perceptualRoughness), vec2(0.001, 0.001), vec2(0.009, 0.009));

Assimp library needs "ASSIMP_BUILD_ZLIB" turn on

I was trying to generate the solution through CMake, but I constantly received this error

CMake Error at CMakeLists.txt:125 (set_property):
set_property could not find TARGET zlibstatic. Perhaps it has not yet been created.

While issuing this commands in the root directory of the project

python bootstrap.py

mkdir build
cd build
cmake .. -G "Visual Studio 17 2022" -A x64

The only way to let the generation complete successfully, in my case, was by turning on the flag "ASSIMP_BUILD_ZLIB" in CMake.

Is it something excpected with Visual Studio 2022?
If not, what can I check to see if I have all the dependencies installed correctly?

data/meshes directory is missing assets

for example Ch8_SampleGL02_SSAO needs
GLSceneData sceneData1("data/meshes/test.meshes", "data/meshes/test.scene", "data/meshes/test.materials");
GLSceneData sceneData2("data/meshes/test2.meshes", "data/meshes/test2.scene", "data/meshes/test2.materials");
none of them are there.

Some QA before publishing please, I did not buy your to debug your build process!

missing files

missing data/meshs/*

bistro_all.materials
bistro_all.meshes
bistro_all.scene
test.materials
test.meshes
test.scene
test.meshes.instances
test_graph.materials
test_graph.meshes
test_graph.scene
test2.materials
test2.meshes
test2.scene
cube.material
cube.meshes
cube.scene
test.boxes
test_graph.boxes
test2.boxes
test.meshes.drawdata
test_duck.materials
test_duck.meshes
test_duck.scene

createTexturedVertexBuffer() causes y-flip of texture

When loading a gltf file through createTexturedVertexBuffer() the resulting texture is y-flipped.

To reproduce:

  1. In ../Chapter4/VK01_DemoApp/src/main.py change the image file in call to make_unique<ModelRenderer> to "/data/rubber_duck/textures/Duck_baseColor.png"
  2. Compile and run "./bin/Ch4_SampleVK01_DemoApp"

The result, the texture does not match the duck geometry, which can be seen around its eyes.

This may be fixed e.g. by the following change:

diff --git a/shared/UtilsVulkan.cpp b/shared/UtilsVulkan.cpp
index 38b50a5..d322bc3 100644
--- a/shared/UtilsVulkan.cpp
+++ b/shared/UtilsVulkan.cpp
@@ -2408,7 +2408,7 @@ bool createTexturedVertexBuffer(VulkanRenderDevice& vkDev, const char* filename,
 	{
 		const aiVector3D v = mesh->mVertices[i];
 		const aiVector3D t = mesh->mTextureCoords[0][i];
-		vertices.push_back({ .pos = vec3(v.x, v.z, v.y), .tc = vec2(t.x, t.y) });
+		vertices.push_back({ .pos = vec3(v.x, v.z, v.y), .tc = vec2(t.x, 1.0-t.y) });
 	}
 
 	std::vector<unsigned int> indices;

An alternate fix would be to y-flip the image texture, or invert the v coordinate the fragment shader.

BRDF LUT compute shader divides by zero

The computer shader that is used to generate the BRDF LUT texture generates texture coordinates this way:

vec2 uv;
uv.x = float(gl_GlobalInvocationID.x) / float(BRDF_W);
uv.y = float(gl_GlobalInvocationID.y) / float(BRDF_H);

this will lead to uv.x == 0 and uv.y == 0 when gl_GlobalInvocationID == vec2(0, 0). This in turn will lead to division by zero in

float G_Vis = (G * dotVH) / (dotNH * dotNV);

and yields an incorrect BRDF LUT texture.

Other resources like LearnOpenGL generate the BRDF LUT texture with a fragment shader. This causes the texture coordinates to be interpolated and will avoid a division by zero.

Can't compile on OSX

Running

cmake .. -G "Unix Makefiles"
cmake --build . --config Release

Results in the following error while compiling ImGuizmo

3D-Graphics-Rendering-Cookbook/deps/src/ImGuizmo/ImGuizmo.cpp:2546:21: error: expected ';' at end of declaration
      bool boxes[27]{};

Generating an XCode project with cmake .. -G "Xcode", opening the XCode project and compiling gives the same error

I think both of them come from the fact that CLang 13 has partial support for C++20

Installing GCC 12 and forcing it's usage with

CC=gcc-12 CXX=gcc-12 cmake .. -G "Unix Makefiles"
cmake --build . --config Release

shows the following error when linking EtcLib

ld: symbol(s) not found for architecture arm64

Just wondering if someone had any luck at compiling the project

Error while generating in cmake in Windows

While I am generating using cmake in Windows, I get the following error:

CMake Error at CMakeLists.txt:125 (set_property):
set_property could not find TARGET zlibstatic. Perhaps it has not yet been
created.

I tried installing zlib using conda, but it is not working. Any help please? Thank you.

Question: Why normal matrix uses only inverted model matrix?

Here:

void main()
{
	mat4 model = in_Model[gl_DrawID];
	mat4 MVP = proj * view * model;

	vec3 pos = getPosition(gl_VertexID);
	gl_Position = MVP * vec4(pos, 1.0);

	tc = getTexCoord(gl_VertexID);

	mat3 normalMatrix = transpose( inverse(mat3(model)) );

	normal = normalMatrix  * getNormal(gl_VertexID);
	worldPos = ( in_Model[gl_DrawID] * vec4(pos, 1.0) ).xyz;
}

Usually when you calculate normal matrix you need to use inverse of view model matrix.

Problem building in build dir with cmake

After following the procedure in README.md
mkdir build
cd build
cmake ..
I was told by the errors to do the following
sudo apt-get install mercurial
sudo apt-get install libxrandr-dev
sudo apt-get install libxinerama-dev
sudo apt-get install libxcursor-dev
Then, after trying cmake .. again, I got the following error that indicates that a file is missing:
CMake Error at CMake/CommonMacros.txt:35 (add_executable):
Cannot find source file:

/home/evannibbe/ComputerScience/ComputerGraphics/deps/src/etc2comp/EtcTool/EtcFile.cpp

Tried extensions .c .C .c++ .cc .cpp .cxx .cu .m .M .mm .h .hh .h++ .hm
.hpp .hxx .in .txx
Call Stack (most recent call first):
Chapter2/08_ETC2Comp/CMakeLists.txt:7 (SETUP_APP)

-- Generating done
CMake Generate step failed. Build files cannot be regenerated correctly.

However, when I search for that file myself, I find it!
evannibbe@xxx:~/ComputerScience/ComputerGraphics/3D-Graphics-Rendering-Cookbook/deps/src/etc2comp/EtcTool$ ls
Args.txt CMakeLists.txt EtcComparison.cpp EtcFile.h EtcMemTest.cpp EtcSourceImage.h Makefile
CMakeFiles EtcAnalysis.cpp EtcComparison.h EtcFileHeader.cpp EtcMemTest.h EtcTool.cpp
cmake_install.cmake EtcAnalysis.h EtcFile.cpp EtcFileHeader.h EtcSourceImage.cpp EtcTool.h

This seems to mean that I must copy the deps folder one folder level upward (I just used ln -s 3D-Graphics-Rendering-Cookbook/deps ./deps with the current working directory one higher), which is annoying, but allows everything to work.

LOD array indexing

  1. The LOD generation code can create up to 8 LODs
  2. Mesh::lodOffset is defined with size 8
  3. Mesh::getLODIndicesCount(uint32_t lod) references lodOffset[lod+1]
    So, getting the number of indices in your 8th LOD is not defined.
    This can cause problems trying to merge scenes considering all LODs.

macOS

Now that MoltenVK supports Vulkan 1.2, is it feasible to use this book with macOS?

Renderer pattern design question

Just purchased a copy of this book and am reading through it. Really like the structure of the book and content, however I have a question about the renderer concept and design that's used in the book.

The book describes the different renderers and how to leverage that pattern. It also describes using the frustum to cull by turning off geometry by setting the instance count to 0.

That works fine for a geometry & textures that fit on the GPU, however, how can the renderer pattern be used for a very large landscape with lots of trees etc.? I have a quadtree for culling, and can't seem to find a way to fit that into the pattern.

Ideally, I'd want to leverage the quadtree for culling, and be able to stream geometry (and textures) into and out of the GPU based on some algorithm based on the camera and distance.

Any suggestions on how the renderer pattern could be modified for that?

Thanks!

Cannot find OptickCored.dll

I am relatively new to CMake. I have an issue with launching chapters related to Optick. When executing them, it throws an error saying that OptickCored.dll cannot be found.

I also tried with a simpler project. Here is the source tree:

  • CMakeLists
  • src
    • CMakeLists
    • main.cpp
  • optick

The first CMakeLists is:
`cmake_minimum_required(VERSION 3.7)

project( OptickTest )

set_property(GLOBAL PROPERTY USE_FOLDERS ON)

add_subdirectory(optick)
add_subdirectory(src)
`

and the one inside the src folder is:
`cmake_minimum_required(VERSION 3.7)

add_executable( OptickTest "main.cpp" )

target_link_libraries( OptickTest OptickCore )`

I could handle libraries such as GFLW, but this one gives me trouble. I don't understand why it cannot find the dll.

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.