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
8 changes: 4 additions & 4 deletions src/scene/shader-lib/chunks-wgsl/chunks-wgsl.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ import litForwardMainPS from './lit/frag/pass-forward/litForwardMain.js';
import litForwardPostCodePS from './lit/frag/pass-forward/litForwardPostCode.js';
import litForwardPreCodePS from './lit/frag/pass-forward/litForwardPreCode.js';
import litMainVS from './lit/vert/litMain.js';
// import litOtherMainPS from './lit/frag/pass-other/litOtherMain.js';
import litOtherMainPS from './lit/frag/pass-other/litOtherMain.js';
import litShaderArgsPS from './standard/frag/litShaderArgs.js';
import litShaderCorePS from './standard/frag/litShaderCore.js';
import litShadowMainPS from './lit/frag/pass-shadow/litShadowMain.js';
Expand Down Expand Up @@ -143,7 +143,7 @@ import parallaxPS from './standard/frag/parallax.js';
// import particle_stretchVS from './particle/vert/particle_stretch.js';
// import particle_TBNVS from './particle/vert/particle_TBN.js';
// import particle_wrapVS from './particle/vert/particle_wrap.js';
// import pickPS from './common/frag/pick.js';
import pickPS from './common/frag/pick.js';
import reflDirPS from './lit/frag/reflDir.js';
import reflDirAnisoPS from './lit/frag/reflDirAniso.js';
import reflectionCCPS from './lit/frag/reflectionCC.js';
Expand Down Expand Up @@ -289,7 +289,7 @@ const shaderChunksWGSL = {
litForwardPostCodePS,
litForwardPreCodePS,
litMainVS,
// litOtherMainPS,
litOtherMainPS,
litShaderArgsPS,
litShaderCorePS,
litShadowMainPS,
Expand Down Expand Up @@ -354,7 +354,7 @@ const shaderChunksWGSL = {
// particle_stretchVS,
// particle_TBNVS,
// particle_wrapVS,
// pickPS,
pickPS,
reflDirPS,
reflDirAnisoPS,
reflectionCCPS,
Expand Down
9 changes: 9 additions & 0 deletions src/scene/shader-lib/chunks-wgsl/common/frag/pick.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export default /* wgsl */`
uniform meshInstanceId: u32;

fn getPickOutput() -> vec4f {
let inv: vec4f = vec4f(1.0 / 255.0);
let shifts: vec4u = vec4u(16u, 8u, 0u, 24u);
let col: vec4u = (vec4u(uniform.meshInstanceId) >> shifts) & vec4u(0xffu);
return vec4f(col) * inv;
}`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// main shader entry point for the lit material for other render passes
export default /* wgsl */`

#ifdef PICK_PASS
#include "pickPS"
#endif

#ifdef PREPASS_PASS
#include "floatAsUintPS"
#endif

@fragment
fn fragmentMain(input: FragmentInput) -> FragmentOutput {
var output: FragmentOutput;

evaluateFrontend();

#ifdef PICK_PASS
output.color = getPickOutput();
#endif

#ifdef DEPTH_PASS
output.color = vec4(1.0, 1.0, 1.0, 1.0);
#endif

#ifdef PREPASS_PASS
output.color = float2vec4(vLinearDepth);
#endif

return output;
}
`;
2 changes: 1 addition & 1 deletion src/scene/shader-lib/chunks/common/frag/pick.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export default /* glsl */`
uniform uint meshInstanceId;

vec4 getPickOutput() {
const vec4 inv = vec4(1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0);
const vec4 inv = vec4(1.0 / 255.0);
const uvec4 shifts = uvec4(16, 8, 0, 24);
uvec4 col = (uvec4(meshInstanceId) >> shifts) & uvec4(0xff);
return vec4(col) * inv;
Expand Down