Skip to main content
Cleanup
Source Link
DMGregory
  • 141k
  • 23
  • 258
  • 401

Share custom lighting data struct with GLSL: Create global structs vertex & fragment shaders

So I've reached normal maps as I was learning OpenGL, and I decided to calculate the tangents on the CPU. Now the

The issue is that my lighting uses custom structs and it would be impractical to do TBN calculations on the fragment shader when I can do it on the vertex shader itself, this. This means I need to transfer over my structs into the vertex shader. Then I need to pass them to the fragment shader in the same struct format but only the data in tangent space.

Do anyone have any idea howHow can I could achieve this?

GLSL: Create global structs

So I've reached normal maps as I was learning OpenGL and I decided to calculate the tangents on the CPU. Now the issue is that my lighting uses custom structs and it would be impractical to do TBN calculations on the fragment shader when I can do it on the vertex shader itself, this means I need to transfer over my structs into the vertex shader. Then I need to pass them to the fragment shader in the same struct format but only the data in tangent space.

Do anyone have any idea how I could achieve this?

Share custom lighting data struct with GLSL vertex & fragment shaders

I've reached normal maps as I was learning OpenGL, and I decided to calculate the tangents on the CPU.

The issue is that my lighting uses custom structs and it would be impractical to do TBN calculations on the fragment shader when I can do it on the vertex shader itself. This means I need to transfer over my structs into the vertex shader. Then I need to pass them to the fragment shader in the same struct format but only the data in tangent space.

How can I achieve this?

Source Link

GLSL: Create global structs

So I've reached normal maps as I was learning OpenGL and I decided to calculate the tangents on the CPU. Now the issue is that my lighting uses custom structs and it would be impractical to do TBN calculations on the fragment shader when I can do it on the vertex shader itself, this means I need to transfer over my structs into the vertex shader. Then I need to pass them to the fragment shader in the same struct format but only the data in tangent space.

Do anyone have any idea how I could achieve this?