knightcrawler25 / glsl-pathtracer Goto Github PK
View Code? Open in Web Editor NEWA toy physically based GPU path tracer (C++/OpenGL/GLSL)
License: MIT License
A toy physically based GPU path tracer (C++/OpenGL/GLSL)
License: MIT License
The way you calculting tangent and bitangent in the function 0nb() looks very simple. But is it right?
void Onb(in vec3 N, inout vec3 T, inout vec3 B)
//-----------------------------------------------------------------------
{
vec3 UpVector = abs(N.z) < 0.99999 ? vec3(0, 0, 1) : vec3(1, 0, 0);
T = normalize(cross(UpVector, N));
B = cross(N, T);
}
I think it will not produce right results, it may flip coordinates of normal map. Shouldn't we precompute tangent and bitangent based on triangle's edges and UV coordinates as something like dP/dUV?
Is it possible to interactively move lights in a scene?
Older versions before the BRDF rework had an option for extinction of spec. transmission. Why exactly was this option removed ? Was it incompatible with the new BRDF model that allows for volumes ?
hi
I have compiled successfuly up to 100% but I get a linker error:
...
[ 96%] Building CXX object CMakeFiles/PathTracer.dir/thirdparty/imguizmo/ImGuizmo.cpp.o
[100%] Linking CXX executable PathTracer
/usr/bin/ld: cannot find -lOpenImageDenoise
collect2: error: ld returned 1 exit status
I see OpenImageDenoise.lib
under GLSL-PathTracer/thirdparty/oidn/lib
, is it not the library the linker needs?
I am on Ubuntu 18.04, cmake 3.18.
Do you have any idea?
thanks
edit: I realise there are only .dll or .lib files for the oidn thirdparty folder, no .so neither .a file. After googling a bit, it seems it is an Intel library. on there website they say "You need a CPU with SSE4.1 support or Apple Silicon to run Intel Open Image Denoise"
Now, I am running on a Jetson machine, Linux for tegra, i.e. ARM cpu, so I cannot use this lib anyway.
If so, then can I compile without image denoising? if yes, how can I do it?
Hi, thanks for the great project!
In the shader code in tonemap.glsl, tonemap is applied to all pixels, which is not correct if a constant background color is desired. See the effects below:
I think whether it is background can be recorded as the w component in pathTraceTexture. Maybe there are other better ideas?
Hello.
Is 2.0 * PI * PI changing to 2.0 * TWO_PI are correct? Or it is error or typo?
Please explain this changing
Wouldn't the transmission pdf be weighted by the chance of sampling transmission (i.e., state.mat.transmission
)?
I find it hard to understand everything that's going on in the shader folder, do you have any reference i can look up to?
Hi! I notice that SampleGGXVNDF
is used to sample ggx distribution and this method is for isotropic ggx. In some cases (anisotopic != 0
) ggx distribution will be anisotropic. Could you please add the anisotropic version of importance sampling?
What I plan to do:
What I'd like to have:
To experiment:
How do you define quad lights in .scene file? There is position, v1, v2 parameters.
Is 'position' a coordinates of the center of light? What are 'v1' and 'v2' vectors?
UPDATE
I think position, v1, v2 are just coordinates of the first three vertices of area light, right?
Hi,
I have a some suggestions about materials values in pathtrace shader.
I think that gamma correction should be used also if plain color is selected:
GLSL-PathTracer/src/shaders/common/pathtrace.glsl
Lines 102 to 103 in 272915a
else
mat.albedo = pow(mat.albedo, vec3(2.2));
Rigth now, the color selected from picker looks quite different from result.
The same also applies for metallic-roughness values.
Moreover, roughness value may be 0 if it comes from a texture and this may cause problems with transmission.
GLSL-PathTracer/src/shaders/common/pathtrace.glsl
Lines 105 to 112 in 272915a
I believe that it is better to apply the 0.001 minimum value also here, like this:
if (int(mat.texIDs.y) >= 0) {
vec2 matRgh;
matRgh = pow(texture(textureMapsArrayTex, vec3(texUV, int(mat.texIDs.y))).zy, vec2(2.2));
mat.metallic = matRgh.x;
mat.roughness = max(matRgh.y, 0.001);
}
else {
mat.metallic = pow(mat.metallic, 2.2);
mat.roughness = max(pow(mat.roughness, 2.2), 0.001);
}
Last thing, if I'm not mistaken, here should be used the real face normal:
Onb(state.normal, T, B);
Hope this can be helpful.
Thanks for the great work!
Hello could you please add option to render to file (not screenshot) so can render say 4k even tiled to file is fine
many thanks and great work
i did find this link so it can be done but my opengl/glsl skills arnt great
https://stackoverflow.com/questions/14785007/can-i-use-opengl-for-off-screen-rendering
On the latest graphics driver version for Intel Iris Plus Graphics (27.20.100.9168) there is an error when running Version 0.2.1.
C:\Users\jacob\Downloads\Path Trace>PathTracer.exe
Loading Scene..
Model ./assets/cornell_box/cbox_ceiling.obj loaded
Model ./assets/cornell_box/cbox_floor.obj loaded
Model ./assets/cornell_box/cbox_back.obj loaded
Model ./assets/cornell_box/cbox_smallbox.obj loaded
Model ./assets/cornell_box/cbox_largebox.obj loaded
Model ./assets/cornell_box/cbox_greenwall.obj loaded
Model ./assets/cornell_box/cbox_redwall.obj loaded
Building BVH for ./assets/cornell_box/cbox_ceiling.obj
Building BVH for ./assets/cornell_box/cbox_floor.obj
Building BVH for ./assets/cornell_box/cbox_back.obj
Building BVH for ./assets/cornell_box/cbox_smallbox.obj
Building BVH for ./assets/cornell_box/cbox_largebox.obj
Building BVH for ./assets/cornell_box/cbox_greenwall.obj
Building BVH for ./assets/cornell_box/cbox_redwall.obj
Building scene BVH
Compiling Shader ./shaders/common/vertex.glsl -> 1
Compiling Shader ./shaders/tiled.glsl -> 2
Shader compilation error ./shaders/tiled.glsl
ERROR: 0:86: 'samplerBuffer' : reserved word
ERROR: 0:86: 'samplerBuffer' : syntax error syntax error
C:\Users\jacob\Downloads\Path Trace>
Really nice job with the path tracer, the implementation is very clean.
One potential issue I'm not sure about is that in the Disney BSDF paper for the transmission BSDF the half-vector for the refraction case is:
they then specify
The BRDF is reciprocal but the BTDF is not, so care must be taken when choosing i and o. In particular, for path tracing from the camera, i would represent the view direction and o the light direction.
It looks like that is currently backwards in your implementation?
I'm also wondering where the 4.0 factor comes from in your bsdf eval for transmission:
bsdf = state.mat.albedo * transmittance * (1.0 - F) * D * G * VDotH * LDotH * 4.0 * state.eta * state.eta / (denomSqrt * denomSqrt);
I know the benefit of path tracing is that it enables dynamic, photorealistic lighting but would it (theoretically) be possible to bake the path traced lighting into a scene or asset?
Feel free to just close the issue if this is a stupid question; I'm new to graphics and such.
Hi, I am writing an SDF modeler and for the ray marching to be correct I need to know if the path tracer state is currently inside or outside an object.
Would that be somehow evident from the State struct ?
Thanks
I'm Blender user and I'd like to export my scene from Blender as OBJ file and then would like to render inside the engine, but how to do this?
Thanks advance.
New feature request :)
I don't know if it fits your roadmap but I'd like to see displacement texture in the material. I'm working a lot with heightmap/displacement map and I'd like to plug the renderer over that. Thanks !
Hi,
I am porting the renderer over to my GPL based SDF modeler / renderer.
I have some questions re data structures for the lights:
For radiusAreaType, x is the radius for sphere lights, z is a switch between sphere and quad lights and Y is the volume of the light source, right ?
Also what would be the best way to support directional (sun) light ? I guess just setting the lightDir variable directly to the direction without any falloff I guess ?
And thanks for the easy to understand source code.
Hello,
The scene list looks ok in Debug mode but is filled only by first .scene file in Release Configuration
Thanks for this amazing work
Philippe
Hello,
I have a problem that seems to be related to the measure unit adopted. I would like to use obj models in scale 1.0 unit = 1mm.
This is a screenshot of the teapot.scene where the object is scaled up to be 100 times bigger.
I previously tried a version of this path tracer in October 2020 and I didn't experienced this issue.
Thanks and congrats for your great job.
NEE isn't working correctly when path traced subsurface scattering/transmission is used. BSDF Eval and Pdf functions need to be refactored to get rid of ray type
I noticed on this line
L
to estimate the fresnel term. Wonder if this is valid😮?link_directories(
${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/glfw/lib-vc2013
)
I found version 2013 of glfw would cause link errors. version 2015 is OK.
So glfw version should be auto selected according to Visual Studio version.
I'm trying load scene CoffeeCart.scene. Paths like ./assets/bathroom/floor.obj can't be loaded on window VS 2019. Assert genarated
Here is a small list of things I'd like to do/like to see in the coming weeks/months (no particular order):
provide API for rendering progress feedback
dearimgui UI : load scene, change rendering mode, dump infos
use cmake and move files (3rd party libs are not properly placed)
PathTracer_d.exe!GLSLPathTracer::RenderOptions::operator=(const GLSLPathTracer::RenderOptions & __that) C++
PathTracer_d.exe!loadScene(int index) Line 55 C++
PathTracer_d.exe!main() Line 230 C++
[External Code]
On Windows 10, Debug version.
I think you should put assignment statement after checking.
scene = LoadScene(std::string("./assets/")+sceneFilenames[index]);
scene->renderOptions = renderOptions;
if (!scene)
{
std::cout << "Unable to load scene\n";
exit(0);
}
Hi,
I'm not sure, maybe this is normal ? But the window freeze and this is really slow.
This is really difficult to use gizmo for displace object or modifying value on the GUI.
Maybe there is some update problem ?
My graphics card is an rtx 2080s.
Thanks.
Please show in pictures what was before this fix and after.
Thank you
Dmitry
Hi,
I may have a fix for the screenshot crashes.
The reason must be non POT textures, so i've just added:
glPixelStorei(GL_PACK_ALIGNMENT, 1);
before
GLSL-PathTracer/src/core/TiledRenderer.cpp
Line 411 in 272915a
Hi, I was looking through your scenes and they reference some missing files, was this done on purpose because they are closed source or just an oversight?
The scenes are beautiful and I would love to test them in my raytracer.
Is there some example code or a fork which shows how to sample sun light for a given sun light direction ?
Thanks
The actual resolution of window is different if you have retina display (like MacOS), thus we need to query from SDL once more after we have created the window to get the actual drawable size. Thus will fix the black range in the rendering window
auto window_flags = (SDL_WindowFlags) (SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE |
SDL_WINDOW_ALLOW_HIGHDPI);
loopdata.mWindow = SDL_CreateWindow("GLSL Raytracing", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
renderOptions.windowResolution.x, renderOptions.windowResolution.y,
window_flags);
// Query actual drawable window size
int w, h;
SDL_GL_GetDrawableSize(loopdata.mWindow, &w, &h);
renderOptions.windowResolution.x = w;
renderOptions.windowResolution.y = h;
Hi,
I am working on an programmatic SDF modeler / ray marcher and I wonder how to handle light sources behind glass. Right now the shadow rays hit the glass and just produce a shadow.
What is the correct way, when hitting glass, skipping through the glass (i.e. ignoring it) for shadow rays or something more complex, i.e. refracting the shadow rays ?
Thanks!
?Is it possible to get the normal and albedo values from the shader to OIDN? It will improve the image quality by a lot.
Please when you implement new features, add test files for checking it
Hello.
Why in bsdfSampleRec.f * abs(dot(state.ffnormal, bsdfSampleRec.L)) / bsdfSampleRec.pdf; and same in other places in code
abs(dot(state.ffnormal, bsdfSampleRec.L)) is removed?
Why specular parameter is removed?
I get an openGL error reported when trying to render glassboy with a progressive renderer
GL Debug (ERROR - HIGH) Error has been generated. GL error GL_INVALID_ENUM in TexStorage3D: (ID: 1669289888) Generic error
this corresponds to https://github.com/knightcrawler25/GLSL-PathTracer/blob/master/PathTracer/src/Renderer.cpp#L83
I am trying to imporve woo rendering with normal map texture to see wood grain but I have an issue (image) when loading this asset.zip :
To see the crash you need to modify ST-CL3-009-00.scene
// without crash
line 47 : normalTexture ST-CL3-009-00\images\wood_normal_grey**.xxx.**png
// with crash
line 47 : normalTexture ST-CL3-009-00\images\wood_normal_grey.png
Is there any known limitation regarding texture size, or POT/NPOT, or format (png vs jpeg) ?
We can see weird patterns in the samples.
Maybe it is related to the RNG ?
I had a similar issue that I fixed on my toy renderer using another RNG.
For reference:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.