Repository navigation
Built-in skybox - #8275
Built-in skybox#8275
Conversation
|
Currently this is not used in any examples. Should it be? Also, what should we do about the existing skybox example? |
|
I'm happy that this exists! Unsure if this is the right crate for it: I really wish the rendering crate structure was better split up so users could more easily pull in only the things they need for their games. |
This should be used to replace the existing skybox example please. |
|
Part of the value of the current skybox example is to show use of cubemaps with some different compressed texture types. So, I would say, update the current skybox example to use this plugin. |
superdump
left a comment
There was a problem hiding this comment.
This isn't a full review but there are some significant things to address.
JonahPlusPlus
left a comment
There was a problem hiding this comment.
Looks good to me. I liked how you used the vertex shader to put the vertices on the far plane.
I was going to ask whether it handles split screen, but I see it adds the mesh during the pipeline, so that works. You could probably remove that match statement for drawing indexed/unindexed since you know the mesh before hand.
Other than that, there was some talk about using a fullscreen triangle? Did that not work out, or is it planned for a future PR? Either way, this works fine and probably makes the math for sampling easier.
|
A fullscreen triangle is probably possible, but I couldn't figure out the math myself. This seems simpler, and works. Someone else could try and get the triangle working if they want. |
No Mesh is needed.
Skybox fullscreen triangle
| // | ||
| // The top-left has UV 0,0, the bottom-left has 0,2, and the top-right has 2,0. | ||
| // This means that the UV gets interpolated to 1,1 at the bottom-right corner | ||
| // of the clip-space rectangle that is at 1,-1 in clip space. |
There was a problem hiding this comment.
For other reviewers, I added this documentation as part of figuring out how to do the fullscreen triangle approach.
robtfm
left a comment
There was a problem hiding this comment.
looks good.
it's not this pr's fault i think, but it doesn't line up with environment mapping.
on the example i added a box mesh and an environment map with the skybox cubemap texture to check it looked right. it looks correct (i.e. reflects the skybox) from above and below, and looking at +/- x, but when i look at +z or -z the reflection is the same as the skybox behind so i suspect we need the same handedness switch for environment maps.
| let clip_position = vec4( | ||
| f32(vertex_index & 1u), | ||
| f32((vertex_index >> 1u) & 1u), | ||
| 0.25, | ||
| 0.5 | ||
| ) * 4.0 - vec4(1.0); |
There was a problem hiding this comment.
| let clip_position = vec4( | |
| f32(vertex_index & 1u), | |
| f32((vertex_index >> 1u) & 1u), | |
| 0.25, | |
| 0.5 | |
| ) * 4.0 - vec4(1.0); | |
| let clip_xy = vec2<f32>(f32(vertex_index & 1u), f32(vertex_index >> 1u)) * 4.0 - 1.0; | |
| let clip_position = vec4<f32>(clip_xy, 0.0, 1.0); |
just to keep the logic closer to fullscreen.wgsl and reduce cognitive load a bit.
There was a problem hiding this comment.
I would agree but I remember it being argued by industry peeps that my version is faster. I don’t see how though.
Co-authored-by: robtfm <50659922+robtfm@users.noreply.github.com>
|
@robtfm is the environment map sampling now correct? |
I checked, it is now correct! :) |
Objective
Solution
Changelog
Skybox.EnvironmentMapLightnow renders in the correct orientation.Migration Guide
EnvironmentMapLightmaps if needed to match how they previously rendered (which was backwards).