Giter Site home page Giter Site logo

Comments (20)

trsh avatar trsh commented on July 28, 2024

@Angelo1211 pls help

from hybridrenderingengine.

Angelo1211 avatar Angelo1211 commented on July 28, 2024

@trsh Hey Trsh! what are you setting your working directory to? It seems like it's failing to find the folder because the code uses a relative path and you might be executing from somewhere else. Depending on how you're compiling this project there are options to set that. If that still does not work try going to line 21 in scene.cpp and changing to your direct path like so:

if( !FLOAD::checkFileValidity(folderPath + sceneName + fileExtension) ){

to:

`if(!FLOAD::checkFileValidity("C:/direct-path-to-your-sponza.json"))"

And recompile and run. If this doesn't work we can pursue other options.

Cheers!

from hybridrenderingengine.

trsh avatar trsh commented on July 28, 2024

After changing to absolute path:

Beginning Scene load, checking scene description file:
C:\Users\trsh\Downloads\HybridRenderingEngine-master\HybridRenderingEngine-master\assets\scenes\Sponza.json is a valid file

2020-02-22_175909

from hybridrenderingengine.

Angelo1211 avatar Angelo1211 commented on July 28, 2024

Nice! So it looks like it now checked the file and detected it as valid, it's just the code later on that fails since you've only hardcoded it in one place. Are you running this from an IDE like visual studio? It seems like you might have to change the working directory in the configuration properties to "{path-to-your-project-dir}/build " and that should do the trick! Also remember to revert the previous change :)

from hybridrenderingengine.

trsh avatar trsh commented on July 28, 2024

I download the repo. I run cmake .. The solution file is generated. Then i open it. I select hybridRenderer as startup project. I press run for 64x debug, the code compiles and I got an error.

2020-02-22_193911

However the Debug fir is created with exe in it. When I run that exe (double click), I got the Cannot access ../assets/scenes/Sponza.json error.

from hybridrenderingengine.

trsh avatar trsh commented on July 28, 2024

I fixed the working dir, now it's this:

Beginning Scene load, checking scene description file:
../assets/scenes/Sponza.json is a valid file
Loading camera...
Loading models...
../assets/models/Sponza/Sponza.gltf is a valid file
Loading skybox...
Loading lights...
Loading directional light...
Loading point light...
Generating environment maps...
Reticulating splines...
Loading Complete!...

Initializing Renderer.
Loading FBO's...
Loading Shaders...
Fragment shader compilation failed 0(213) : error C1101: ambiguous overloaded function reference "mod(uint, float)"
    (0) : gp5 float64_t mod(float64_t, float64_t)
    (0) : float mod(float, float)

Error loading rendering Shaders!
Shaders failed to be initialized correctly.
Failed to initialize Render manager.
HRE could not initialize successfully. Shutting down.
Closed input manager.
Closed renderer manager.
Closed scene manager.
Closed display manager.

C:\Users\trsh\Downloads\HybridRenderingEngine-master\HybridRenderingEngine-master\Debug\hybridRenderer.exe (process 11084) exited with code 0.
To automatically close the console when debugging stops, enable Tools->Options->Debugging->Automatically close the console when debugging stops.
Press any key to close this window . . .

from hybridrenderingengine.

Angelo1211 avatar Angelo1211 commented on July 28, 2024

Looks like an OpenGL bug during compilation, I checked your driver version and card and they look compatible with the version (4.6) I would suggest looking for that error message in other forums since I've never seen it. If that doesn't work you could also try changing the openGL version to something lower maybe 3.3 and getting the glad headers again at the link in the project description.

from hybridrenderingengine.

trsh avatar trsh commented on July 28, 2024

@Angelo1211. Ok will try. Btw Im bit confused how you are generating the Clusters. Fallowing the code it happens in RenderManager::preProcess > clusterShader.comp. But there is no loop orsmth, so one cluster is generated? Or where does the magic happen?

from hybridrenderingengine.

Angelo1211 avatar Angelo1211 commented on July 28, 2024

Good luck! So the clusterShader is a computer shader, you need to specify the number of threads it will run ahead of time, in our case it gets one thread per cluster. We execute those threads in the dispatch here:

 //Building the grid of AABB enclosing the view frustum clusters
    buildAABBGridCompShader.use();
    buildAABBGridCompShader.setFloat("zNear", sceneCamera->cameraFrustum.nearPlane);
    buildAABBGridCompShader.setFloat("zFar", sceneCamera->cameraFrustum.farPlane);
    buildAABBGridCompShader.dispatch(gridSizeX, gridSizeY, gridSizeZ);

The gridsize was manually specified in renderManager.h here:

    //The variables that determine the size of the cluster grid. They're hand picked for now, but
        //there is some space for optimization and tinkering as seen on the Olsson paper and the ID tech6
        //presentation.
        const unsigned int gridSizeX = 16;
        const unsigned int gridSizeY =  9;
        const unsigned int gridSizeZ = 24;
        const unsigned int numClusters = gridSizeX * gridSizeY * gridSizeZ; 

The cluster data in itself was initialized in RenderManager::initSSBOs() here:

//Buffer containing all the clusters
    {
        glGenBuffers(1, &AABBvolumeGridSSBO);
        glBindBuffer(GL_SHADER_STORAGE_BUFFER, AABBvolumeGridSSBO);

        //We generate the buffer but don't populate it yet.
        glBufferData(GL_SHADER_STORAGE_BUFFER, numClusters * sizeof(struct VolumeTileAABB), NULL, GL_STATIC_COPY);
        glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 1, AABBvolumeGridSSBO);
        glBindBuffer(GL_SHADER_STORAGE_BUFFER, 0);
    }

Also I wrote an article explaining cluster shading in detail here check it out & it should clarify where the magic happens ;) Let me know if you finally get it to work!

from hybridrenderingengine.

trsh avatar trsh commented on July 28, 2024

@Angelo1211 I dont understand the This compute shader is ran once per cluster and aims to obtain the min and max points of the AABB encompassing said cluster part. How is it run once per cluster? For me it seems to be run only one time at all, at buildAABBGridCompShader.dispatch(gridSizeX, gridSizeY, gridSizeZ);.

from hybridrenderingengine.

trsh avatar trsh commented on July 28, 2024

I think I understood it. Some Compute shader noobing going on here :)

from hybridrenderingengine.

Angelo1211 avatar Angelo1211 commented on July 28, 2024

So the .cpp and .h code is all CPU side code that gets executed (mostly) in a single thread in your CPU, hence it normally would run only once as you say . However, we're not only talking about CPU code here, once we bring Shaders into the mix (in this project stored as .vert .frag and .comp files in asserts/shaders ) things change. These are programs that are executed on the GPU many times in parallel. There are many types of shaders but in this project we only actually use 4: Vertex, Fragment, Geometry and Compute shaders. The first three are fairly common shaders that are used when rendering objects to the screen. The fourth one is a special kind of shader that just does math, but it does a shitton of it in parallel. Refer to the following for more rigurous details:

The dispatch function is actually a CPU side instruction that is sent to the GPU driver with information about how many times that shader should be ran in parallel on the GPU. In our case GridXGridYGridZ times simultaneously. So, what you're actually seeing in the dispatch there is the CPU telling the GPU driver "hey! I want you to run this program this many times and fill in this buffer please. " Then we wait for the GPU to be done with it before continuing.

So, to summarize. it is actually executing the code multiple times in parallel in the GPU but the CPU only has to send the command (dispatch) once to the GPU to do its work.

from hybridrenderingengine.

Angelo1211 avatar Angelo1211 commented on July 28, 2024

No worrries! Compute stuff is hard but super cool. Happy to help :)

from hybridrenderingengine.

trsh avatar trsh commented on July 28, 2024

@Angelo1211 last question. Do the clusters need to be recalculated when camera moves, or lights move?

from hybridrenderingengine.

Angelo1211 avatar Angelo1211 commented on July 28, 2024

That's the magic of it :), you don't really need to recalculate them because the cluster bounds are defined in camera space, and that will only changes if you change the near plane, far plane, or FOV. If you don't change those at all the clusters will be the same and you can perform clustering with the same data structure without issue. Even if it did change though it's not a terribly expensive step.

from hybridrenderingengine.

trsh avatar trsh commented on July 28, 2024

Strange. The other examples Im checking out update the clusters on every frame. For example https://github.com/illDivino/Project5-WebGL-Clustered-Deferred-Forward-Plus/blob/master/src/renderers/clusteredDeferred.js#L165 > https://github.com/illDivino/Project5-WebGL-Clustered-Deferred-Forward-Plus/blob/master/src/renderers/clustered.js#L34

from hybridrenderingengine.

Angelo1211 avatar Angelo1211 commented on July 28, 2024

So I looked at that code briefly, and what they're doing there is not recalculating the clusters but repopulating the light lists within the clusters. That's something that you definitely need to do every frame. It's done here in HRE:

void RenderManager::render(const unsigned int start){
...
//4-Light assignment
    cullLightsCompShader.use();
    cullLightsCompShader.setMat4("viewMatrix", sceneCamera->viewMatrix);
    cullLightsCompShader.dispatch(1,1,6);  
...

I refer you to the original paper where you can see the different stages, specifically section 3 of the paper:

  1. Clustered Deferred Shading Algorithm :
    http://www.cse.chalmers.se/~uffe/clustered_shading_preprint.pdf

Let me know if you do manage to fix the shader compilation issue so I can close this issue. But feel free to email me at the address in the source code or message me on twitter if you've got any other questions! Cheers!

from hybridrenderingengine.

trsh avatar trsh commented on July 28, 2024

Im looking at assets\shaders\ComputeShaders\clusterCullLightShader.comp and have no idea where pointLight was populated. Can you en-light me?

from hybridrenderingengine.

Angelo1211 avatar Angelo1211 commented on July 28, 2024

All SSBO's are initialized in bool RenderManager::initSSBOs() these ones in particular are initialized in:

//Setting up lights buffer that contains all the lights in the scene
    {
        glGenBuffers(1, &lightSSBO);
        glBindBuffer(GL_SHADER_STORAGE_BUFFER, lightSSBO);
        glBufferData(GL_SHADER_STORAGE_BUFFER, maxLights * sizeof(struct GPULight), NULL, GL_DYNAMIC_DRAW);

        GLint bufMask = GL_READ_WRITE;

        struct GPULight *lights = (struct GPULight *)glMapBuffer(GL_SHADER_STORAGE_BUFFER, bufMask);
        PointLight *light;
        for(unsigned int i = 0; i < numLights; ++i ){
            //Fetching the light from the current scene
            light = currentScene->getPointLight(i);
            lights[i].position  = glm::vec4(light->position, 1.0f);
            lights[i].color     = glm::vec4(light->color, 1.0f);
            lights[i].enabled   = 1; 
            lights[i].intensity = 1.0f;
            lights[i].range     = 65.0f;
        }
        glUnmapBuffer(GL_SHADER_STORAGE_BUFFER);
        glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 3, lightSSBO);
        glBindBuffer(GL_SHADER_STORAGE_BUFFER, 0);
    }

from hybridrenderingengine.

Angelo1211 avatar Angelo1211 commented on July 28, 2024

I figure the original issue has been fixed. Closing this now, feel free to email me for any further questions.

from hybridrenderingengine.

Related Issues (20)

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.