0
\$\begingroup\$

So I am implementing a deferred rending model for my engine, and I want to be able to send all scene geometry into a single shader to calculate ambient, diffuse, normal, ect thats not the question.

Once I have all of this data buffered into the GPU I can render all of that geometry from a camera perspective defined by a uniform for the cameras position in the scene. I am wondering if I can reuse this model data already in VRam in another shader translated by a light sources projection matrix to calculate the shadows on this scene geometry without needing to send the same data to the GPU again.

Is there a way to tell my light shader, hey all that juicy geometry/scene data you want is already in V-Ram, just use this matrix transformation instead.

Alternatively when I am sending the VAO to the GPU is there a way to send it to two shades in parallel, one for the deferred rending model, one for shadow casing light sources?

Thanks so much!

\$\endgroup\$
4
  • \$\begingroup\$ Generally you have two steps: 1) upload a buffer of geometry information to the GPU, 2) invoke a particular shader program using that geometry information. These are wholly separate operations. Step 2 doesn't delete the step 1 data from the GPU and force you to re-upload it again. It's still there. You can just do step 2 again with the same geometry buffer and a different shader program. Where have you run into difficulty implementing this? \$\endgroup\$ Commented Oct 7, 2020 at 17:27
  • \$\begingroup\$ Ah! I didn't realize the buffers were not flushed when using a different shading program. So i should just be able to use shader A, buffer my VAO into V-Ram do shader A's drawArraysInstanced then use shader B for lights, and the data will still be there. Cool Cool, did not realize this! \$\endgroup\$ Commented Oct 7, 2020 at 17:30
  • \$\begingroup\$ Always test and profile to see if it's behaving as you want. If it's not, post here with a Minimal Complete Verifiable Example showing how you've implemented the feature and how the results differ from what you want/expect. \$\endgroup\$ Commented Oct 7, 2020 at 17:36
  • \$\begingroup\$ This was more of an approach question, I haven't tried to implement this yet, I wanted to know if there was a way to send data in parallel to multiple shaders. It was probing for information on how to implement this concept to help me better decide how to do what I want to do. \$\endgroup\$ Commented Oct 7, 2020 at 17:41

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.