-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Addresses issue #6587 #6665
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Addresses issue #6587 #6665
Changes from all commits
227fe69
8e2d05c
317d915
917de2f
5139c0a
45e33d5
1d54fad
1ff8702
6cd7856
4401ebd
37751d9
93b8b50
66dc0dc
cffda69
751b16a
29e7a14
7981fdc
e7cd392
f30af0e
d51c4a8
38bcaab
2558755
773198a
bbc7c72
ffd9097
cc77e7e
518b0f0
c124738
38e6e84
a585ef5
f118a3b
2da03d1
5961be8
4515c09
be6d27f
6dc9916
3133e80
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Adapted from: https://learnopengl.com/PBR/IBL/Diffuse-irradiance | ||
IN vec3 localPos; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In my opinion I feel for maximum compatibility, we can do this one in GL ES 100 instead of 300? Using attribute instead of IN, using the spacial variable gl_FragColor instead of defining an OUT_COLOR, and using texture2D() instead of texture()? What you feel? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well I started from that only , and was getting a lot of errors and from Dave's suggestion of using the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmmm...It looks like you need to use both webgl-1 and webgl-2 modes on shaders. |
||
|
||
uniform sampler2D equirectangularMap; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you have hard-coded the value of equirectangularMap to "0" which won't work or its actually a float value. |
||
|
||
const vec2 invAtan = vec2(0.1591, 0.3183); | ||
|
||
vec2 SampleSphericalMap(vec3 v) | ||
{ | ||
vec2 uv = vec2(atan(v.z, v.x), asin(v.y)); | ||
uv *= invAtan; | ||
uv += 0.5; | ||
return uv; | ||
} | ||
|
||
void main() | ||
{ | ||
vec2 uv = SampleSphericalMap(normalize(localPos)); | ||
vec3 color = TEXTURE(equirectangularMap, uv).rgb; | ||
|
||
OUT_COLOR = vec4(color, 1.0); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Adapted from: https://learnopengl.com/PBR/IBL/Diffuse-irradiance | ||
layout (location = 0) IN vec3 aPosition; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks good, but I feel like do we actually need this layout(). Can it be done just with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well honestly speaking , I'm also not sure about what exactly it signifies here, but as i searched on web , I found this glBindAttribLocation(program, 0, "aPosition"); If your application does not do this, you should keep Also , just to mention , I tried running the test sketch by omitting this, and the results were similar , So I think we should keep it for a safer side as its not causing any error. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, this should not give any errors. Since, vertex shaders are just dealing with the positions, I think we don't have layout(...) at other files and they are working perfectly. But the main reason in my mind is, since we only use |
||
|
||
OUT vec3 localPos; | ||
|
||
uniform mat4 uProjectionMatrix; | ||
uniform mat4 uModelViewMatrix; | ||
|
||
void main() | ||
{ | ||
localPos = aPosition; | ||
gl_Position = uProjectionMatrix * uModelViewMatrix * vec4(localPos, 1.0); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure but I feel diffusedLight is also a sampler2D texture, could it be passed as a uniform with samplerCube texture?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here, diffusedLight is obtained from
getDiffusedTexture
, which returns aCubemapTexture
object. SinceenvironmentMapDiffusedCubemap
in the shader expects a cubemap texture (samplerCube), so I thinkdiffusedLight
is being correctly assigned to theenvironmentMapDiffusedCubemap
uniform in the shader, which is of typesamplerCube
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oooh...sorry. I overlooked this, previously we had diffusedLight with
sampler2D
texture so I got confused. I see you have updated getDiffusedTexture()