You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: blog/2024/2024-10-17-glsl-development-made-shrimple/index.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -61,7 +61,7 @@ Writing the same structure definitions for buffers in both C or C++ and GLSL is
61
61
is to abuse macros. It also requires shading language includes.
62
62
63
63
The first step is to write a "shared header" of common definitions that can be understood by both GLSL and C++. This file is split into sections that are only compiled in one language or the other:
64
-
```c
64
+
```glsl
65
65
#ifndef COMMON_H
66
66
#define COMMON_H
67
67
@@ -83,7 +83,7 @@ The first step is to write a "shared header" of common definitions that can be u
83
83
```
84
84
85
85
The second step is to put structure definitions in a file that both languages understand. This can be a separate header, or in the body of the shader itself. For an example of the latter:
I suggest testing your normalization by plugging in a known-good analytical phase function like Henyey-Greenstein or Schlick's. These integrate to 1 and so don't require hacky normalization:
163
163
164
-
```cpp
164
+
```glsl
165
165
float phaseHG(float g, float cosTheta)
166
166
{
167
167
return (1.0 - g * g) / (4.0 * M_PI * pow(1.0 + g * g - 2.0 * g * cosTheta, 1.5));
@@ -180,7 +180,7 @@ After normalizing the data, we can put it into a 1D texture.
180
180
181
181
We only need to keep in mind that the our LUT-based phase function is parameterized by theta (unlike HG and Schlick above). Here's how you might access it in GLSL:
0 commit comments