-
-
Notifications
You must be signed in to change notification settings - Fork 356
feat(accessibility): Barrel Zoom for 3D shooters #1741
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: master
Are you sure you want to change the base?
Changes from all commits
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 |
|---|---|---|
|
|
@@ -16,16 +16,23 @@ layout(push_constant) uniform PC { | |
| float gamma; | ||
| float outW; | ||
| float outH; | ||
| float barrelStrength; | ||
| float barrelHeight; | ||
| float barrelCylindricalRatio; | ||
| } pc; | ||
|
|
||
| layout(location = 0) in vec2 fragTexCoord; | ||
| layout(location = 0) in vec2 fragTexCoord; | ||
| layout(location = 1) in vec3 vUVBarrel; | ||
| layout(location = 2) in vec2 vUVDotBarrel; | ||
|
|
||
| layout(location = 0) out vec4 outColor; | ||
|
|
||
| const int EFFECT_MASK_TOON = 1; | ||
| const int EFFECT_MASK_FXAA = 2; | ||
| const int EFFECT_MASK_VIVID = 4; | ||
| const int EFFECT_MASK_CRT = 8; | ||
| const int EFFECT_MASK_NTSC = 16; | ||
| const int EFFECT_MASK_BARREL_DISTORTION = 32; | ||
|
|
||
| bool hasEffect(int mask) { | ||
| return (pc.effectMask & mask) != 0; | ||
|
|
@@ -264,6 +271,8 @@ vec3 applyNTSC(vec2 uv, vec3 color) { | |
| return clamp(mix(color, shifted + vec3(bleed), 0.65), 0.0, 1.0); | ||
| } | ||
|
|
||
|
|
||
|
|
||
| void main() { | ||
| vec2 uv = fragTexCoord; | ||
| vec4 src = texture(texSampler, uv); | ||
|
|
@@ -284,7 +293,12 @@ void main() { | |
| if (hasEffect(EFFECT_MASK_VIVID)) rgb = applyVivid(rgb); | ||
| if (hasEffect(EFFECT_MASK_CRT)) rgb = applyCRTOverlay(uv, rgb); | ||
| if (hasEffect(EFFECT_MASK_NTSC)) rgb = applyNTSC(uv, rgb); | ||
| if (hasEffect(EFFECT_MASK_BARREL_DISTORTION)) { | ||
| vec3 puv = dot(vUVDotBarrel, vUVDotBarrel) * vec3(-0.5, -0.5, -1.0) + vUVBarrel; | ||
| rgb = texture(texSampler, puv.xy / puv.z).rgb; | ||
|
Contributor
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. P1: Barrel distortion overwrites the brightness/contrast/gamma adjustments applied just above it. The barrel branch re-samples from the raw texture ( Suggestion: re-apply Prompt for AI agents |
||
| } | ||
| } | ||
|
|
||
|
|
||
| outColor = vec4(rgb, pc.useTexAlpha != 0 ? src.a : 1.0); | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.