playcanvas / playcanvas/engine

SpriteComponent _showFrame ignores SpriteComponent.material

Open
#5,354 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
16.8k
Forks
2k
Avg merge
4h 9m
Merged PRs (30d)
218

Description

Hi! It looks like according to the code referenced below, _showFrame in SpriteComponent initially creates its _meshInstance using the sprite component's material, but then immediately and subsequently always overwrites it with system.defaultMaterial. I suspect this crept in when support for the sliced & tiled modes came in. Should this be considered a bug now? It makes an animated sprite's material impossible to override, e.g. if you want to change the blend mode, or apply shader effects.
https://github.com/playcanvas/engine/blob/cf28baf6f1ccd5568597946c62c1696a4ad9919e/src/framework/components/sprite/component.js#L659-L692

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read src/framework/components/sprite/component.js around lines 659-692, starting at _showFrame and tracing how the sprite component material and system.defaultMaterial are assigned. Confirm the expected material behavior for animated sprites, then verify that an overridden material remains effective for blend modes or shader effects.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
computer-graphics, game-dev
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.