Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
92925b1
feat: lighting basics
0x00002a Feb 5, 2024
8be02c2
chore: trying to get lighting to work
0x00002a Feb 9, 2024
bc25e25
Fix lighting
Jhynjhiruu Feb 12, 2024
c1b7cf2
chore: switch set_position back to fvec3
0x00002a Feb 12, 2024
3153e7d
chore: cleanup code
0x00002a Feb 12, 2024
e04b730
fix: Light not send + sync
0x00002a Feb 12, 2024
1502f41
fix: LightEnv not send + sync
0x00002a Feb 12, 2024
3d4ba6c
fix: no uvs in example
0x00002a Feb 12, 2024
eeb3c96
feat: add couple more bindings for Light
0x00002a Feb 12, 2024
214312c
fix: soundness issues with pinned lights
0x00002a Feb 12, 2024
fa06deb
feat: LutData from rust fn
0x00002a Feb 13, 2024
dcb6a53
feat: fresnel selector
0x00002a Feb 13, 2024
085ab59
fix: red and blue channels swapped in material rendering
0x00002a Feb 15, 2024
1fcbb44
feat: add disconnect lut
0x00002a Feb 15, 2024
54e8c4b
fix: missing basic derives for Lut types
0x00002a Feb 15, 2024
6c635f9
chore: LutData -> LightLut
0x00002a Feb 15, 2024
d81514b
feat: improve docs on luts
0x00002a Feb 15, 2024
5a7b44f
feat: add distance attenuation
0x00002a Feb 15, 2024
64f6e3a
fix: build with latest ctru-sys
0x00002a Jun 18, 2024
4e4620f
fix: fragment light example
0x00002a Jun 18, 2024
921a267
chore: bump pin array min version
0x00002a Jun 18, 2024
c64460b
chore: cleanup and improve API of Light
0x00002a Jun 18, 2024
ae7a39d
Merge remote-tracking branch '0x00002a/0x2a/feat/lighting' into feat/…
Meziu Aug 27, 2025
391c30d
Fmt and clippy fixes
Meziu Aug 27, 2025
7012bdd
Fix light banding by increasing near sample rate
Meziu Aug 27, 2025
1bb2c93
Basic spotlights working
Meziu Aug 27, 2025
0083d2a
Cleaner idx logic
Meziu Aug 28, 2025
94cd3ff
Rename cutoff spotlight
Meziu Aug 28, 2025
0417a98
Fix set-unset edge cases for spotlight
Meziu Aug 29, 2025
1f30315
Enable destroying lights
Meziu Aug 29, 2025
3d31424
Enable binding different LightEnvironments and even turning it off
Meziu Aug 29, 2025
89d9c2b
Light module documentation
Meziu Aug 29, 2025
11b67ba
Docs and move of materials
Meziu Aug 30, 2025
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# IDE files
.zed

# Generated by Cargo
# will have compiled files and executables
debug/
Expand Down
1 change: 1 addition & 0 deletions citro3d/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ ctru-rs = { git = "https://github.com/rust3ds/ctru-rs.git" }
ctru-sys = { git = "https://github.com/rust3ds/ctru-rs.git" }
document-features = "0.2.11"
libc = "0.2.175"
pin_array = "0.1.2"

[features]
default = ["glam"]
Expand Down
74 changes: 74 additions & 0 deletions citro3d/examples/assets/frag-shader.pica
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
; modified version of https://github.com/devkitPro/3ds-examples/blob/ea519187782397c279609da80310e0f8c7e80f09/graphics/gpu/fragment_light/source/vshader.v.pica
; Example PICA200 vertex shader

; Uniforms
.fvec projection[4], modelView[4]

; Constants
.constf myconst(0.0, 1.0, -1.0, 0.5)
.alias zeros myconst.xxxx ; Vector full of zeros
.alias ones myconst.yyyy ; Vector full of ones
.alias half myconst.wwww

; Outputs
.out outpos position
.out outtex texcoord0
.out outclr color
.out outview view
.out outnq normalquat

; Inputs (defined as aliases for convenience)
.in inpos
.in innrm
.in intex

.proc main
; Force the w component of inpos to be 1.0
mov r0.xyz, inpos
mov r0.w, ones

; r1 = modelView * inpos
dp4 r1.x, modelView[0], r0
dp4 r1.y, modelView[1], r0
dp4 r1.z, modelView[2], r0
dp4 r1.w, modelView[3], r0

; outview = -r1
mov outview, -r1

; outpos = projection * r1
dp4 outpos.x, projection[0], r1
dp4 outpos.y, projection[1], r1
dp4 outpos.z, projection[2], r1
dp4 outpos.w, projection[3], r1

; outtex = intex
mov outtex, intex

; Transform the normal vector with the modelView matrix
; TODO: use a separate normal matrix that is the transpose of the inverse of modelView
dp3 r14.x, modelView[0], innrm
dp3 r14.y, modelView[1], innrm
dp3 r14.z, modelView[2], innrm
dp3 r6.x, r14, r14
rsq r6.x, r6.x
mul r14.xyz, r14.xyz, r6.x

mov r0, myconst.yxxx
add r4, ones, r14.z
mul r4, half, r4
cmp zeros, ge, ge, r4.x
rsq r4, r4.x
mul r5, half, r14
jmpc cmp.x, degenerate

rcp r0.z, r4.x
mul r0.xy, r5, r4

degenerate:
mov outnq, r0
mov outclr, ones

; We're finished
end
.end
Loading
Loading