Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions public/assets/img/cubemap/credit.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Cubemap image available under a Creative Commons Attribution 3.0 Unported License at https://www.humus.name/index.php?page=Textures&ID=58
2 changes: 1 addition & 1 deletion sample/cubemap/meta.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export default {
name: 'Cubemap',
description:
'This example shows how to render and sample from a cubemap texture.',
'This example shows how to render and sample from a cubemap texture. Cubemap image available under a Creative Commons Attribution 3.0 Unported License at https://www.humus.name/index.php?page=Textures&ID=58',
filename: __DIRNAME__,
sources: [
{ path: 'main.ts' },
Expand Down
8 changes: 6 additions & 2 deletions sample/cubemap/sampleCubemap.frag.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@ fn main(
@location(1) fragPosition: vec4f
) -> @location(0) vec4f {
// Our camera and the skybox cube are both centered at (0, 0, 0)
// so we can use the cube geomtry position to get viewing vector to sample the cube texture.
// The magnitude of the vector doesn't matter.
// so we can use the cube geometry position to get viewing vector to sample
// the cube texture. The magnitude of the vector doesn't matter.
var cubemapVec = fragPosition.xyz - vec3(0.5);
// When viewed from the inside, cubemaps are left-handed (z away from viewer),
// but common camera matrix convention results in a right-handed world space
// (z toward viewer), so we have to flip it.
cubemapVec.z *= -1;
return textureSample(myTexture, mySampler, cubemapVec);
}