question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Sprite Material support

See original GitHub issue

Imagine a RPG style game where each player has a nameplate. For example ( https://i.imgur.com/KxgTpuu.jpg ).

Working with MeshBasicMaterial or MeshPhongMaterial we would need to use an onBeforeRender handler that adjusts the whole group's world matrix based on camera frustum on each frame as you’ve suggested here.

A Sprite Material has these optimizations baked in to handle this exact scenario. It feels like following your suggestion will lead to rolling our own Sprite Material, which is likely going to have much worse performance and usability than Three’s.

It will also really complicate solutions. Imagine all the other use cases in the scene that need a Sprite’s behavior but belong to different object groups with different object hierarchy’s. There would never be a one size fits all in the same way a Three’s Sprite behaves.

Would really appreciate support for Sprite Material as it would both improve performance of our implementation along with developer usability of your library.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:8

github_iconTop GitHub Comments

1reaction
lojjiccommented, Dec 21, 2022

I’ve updated the CodeSandbox example to the latest libraries.

1reaction
lojjiccommented, Feb 5, 2021

Here’s an example in action, using createDerivedMaterial from troika-three-utils. You should be able to use that directly. https://codesandbox.io/s/createbillboardmaterial-xl6mt?file=/src/createBillboardMaterial.js

I do think I’ll formalize this, with some fixes to normals so lighting works as expected. It’s a very flexible approach – any material can be used as the base, and it can be applied to any mesh.

Keep in mind though that it does have drawbacks, like not being raycastable.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Sprite Renderer - Unity - Manual
Define the Material used to render the Sprite texture. Draw Mode, Define how the Sprite scales when its dimensions change. Select one of...
Read more >
Animated Sprite with custom shader (material) - Help & Support
In some of our games we use custom material chunks on sprites, image and text elements and it work fine but with animated...
Read more >
2D SPRITE BASICS IN UNITY | Getting Started With Unity
In this Unity tutorial I will teach you about 2D sprites in Unity! ... lesson material, and for a small fee you can...
Read more >
Bug - Sprites with default material not showing on editor when ...
Shaders: Fixed sprites using default sprite material not rendering in the Editor when build target is set to console (1318066).
Read more >
unity - Sprite doesn't change material or picture
I found something that might help. I changed the Emission of the material inside the obejct inspector and added the picture of the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found