MCPcopy
hub / github.com/EngoEngine/engo / generateBufferContent

Method generateBufferContent

common/render_shaders_blendmap.go:429–482  ·  view source on GitHub ↗
(ren *RenderComponent, space *SpaceComponent, buffer []float32)

Source from the content-addressed store, hash-verified

427}
428
429func (s *blendmapShader) generateBufferContent(ren *RenderComponent, space *SpaceComponent, buffer []float32) bool {
430 // We shouldn't use SpaceComponent to get width/height, because this usually already contains the Scale (which
431 // is being added elsewhere, so we don't want to over-do it)
432 w := ren.Drawable.Width()
433 h := ren.Drawable.Height()
434
435 tint := colorToFloat32(ren.Color)
436
437 u, v, u2, v2 := ren.Drawable.View()
438
439 if ren.Repeat != NoRepeat {
440 u2 = space.Width / (ren.Drawable.Width() * ren.Scale.X)
441 w *= u2
442 v2 = space.Width / (ren.Drawable.Height() * ren.Scale.Y)
443 h *= v2
444 }
445
446 var changed bool
447
448 //setBufferValue(buffer, 0, 0, &changed)
449 //setBufferValue(buffer, 1, 0, &changed)
450 setBufferValue(buffer, 2, u, &changed)
451 setBufferValue(buffer, 3, v, &changed)
452 setBufferValue(buffer, 4, tint, &changed)
453
454 setBufferValue(buffer, 5, w, &changed)
455 //setBufferValue(buffer, 6, 0, &changed)
456 setBufferValue(buffer, 7, u2, &changed)
457 setBufferValue(buffer, 8, v, &changed)
458 setBufferValue(buffer, 9, tint, &changed)
459
460 setBufferValue(buffer, 10, w, &changed)
461 setBufferValue(buffer, 11, h, &changed)
462 setBufferValue(buffer, 12, u2, &changed)
463 setBufferValue(buffer, 13, v2, &changed)
464 setBufferValue(buffer, 14, tint, &changed)
465
466 //setBufferValue(buffer, 15, 0, &changed)
467 setBufferValue(buffer, 16, h, &changed)
468 setBufferValue(buffer, 17, u, &changed)
469 setBufferValue(buffer, 18, v2, &changed)
470 setBufferValue(buffer, 19, tint, &changed)
471
472 // Since each sprite in the batch has a different transform, we can't just send the model matrix into
473 // the shader and let the GPU take care of it. Instead, we need to multiply the current sprite's model matrix
474 // with the position component for each vertex of the current sprite on the CPU, and send the transformed
475 // positions to the shader directly.
476 modelMatrix := s.makeModelMatrix(ren, space)
477 s.multModel(modelMatrix, buffer[:2])
478 s.multModel(modelMatrix, buffer[5:7])
479 s.multModel(modelMatrix, buffer[10:12])
480 s.multModel(modelMatrix, buffer[15:17])
481 return changed
482}
483
484func (s *blendmapShader) multModel(m *engo.Matrix, v []float32) {
485 tmp := engo.MultiplyMatrixVector(m, v)

Callers 1

updateBufferMethod · 0.95

Calls 7

makeModelMatrixMethod · 0.95
multModelMethod · 0.95
colorToFloat32Function · 0.85
setBufferValueFunction · 0.85
WidthMethod · 0.65
HeightMethod · 0.65
ViewMethod · 0.65

Tested by

no test coverage detected