MCPcopy
hub / github.com/g3n/engine / RenderSetup

Method RenderSetup

light/spot.go:125–150  ·  view source on GitHub ↗

RenderSetup is called by the engine before rendering the scene

(gs *gls.GLS, rinfo *core.RenderInfo, idx int)

Source from the content-addressed store, hash-verified

123
124// RenderSetup is called by the engine before rendering the scene
125func (l *Spot) RenderSetup(gs *gls.GLS, rinfo *core.RenderInfo, idx int) {
126
127 // Calculates and updates light position uniform in camera coordinates
128 var pos math32.Vector3
129 l.WorldPosition(&pos)
130 var pos4 math32.Vector4
131 pos4.SetVector3(&pos, 1.0)
132 pos4.ApplyMatrix4(&rinfo.ViewMatrix)
133 l.udata.position.X = pos4.X
134 l.udata.position.Y = pos4.Y
135 l.udata.position.Z = pos4.Z
136
137 // Calculates and updates light direction uniform in camera coordinates
138 var dir math32.Vector3
139 l.WorldDirection(&dir)
140 pos4.SetVector3(&dir, 0.0)
141 pos4.ApplyMatrix4(&rinfo.ViewMatrix)
142 l.udata.direction.X = pos4.X
143 l.udata.direction.Y = pos4.Y
144 l.udata.direction.Z = pos4.Z
145
146 // Transfer uniform data
147 const vec3count = 5
148 location := l.uni.LocationIdx(gs, vec3count*int32(idx))
149 gs.Uniform3fv(location, vec3count, &l.udata.color.R)
150}

Callers

nothing calls this directly

Calls 6

SetVector3Method · 0.95
ApplyMatrix4Method · 0.95
WorldPositionMethod · 0.80
WorldDirectionMethod · 0.80
LocationIdxMethod · 0.80
Uniform3fvMethod · 0.45

Tested by

no test coverage detected