-
Notifications
You must be signed in to change notification settings - Fork 102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[1.0] Fix v0 compatible render queue parsing #995
Conversation
The new procedure lists all used render queues and generate new render queue offsets in the same order See: https://github.com/vrm-c/vrm-specification/blob/master/specification/VRMC_materials_mtoon-1.0-beta/README.ja.md#render-queue
Array.from(renderQueuesTransparent) | ||
.sort() | ||
.forEach((queue, i) => { | ||
const newQueueOffset = Math.min(Math.max(i - renderQueuesTransparent.size + 1, -9), 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
renderQueuesTransparent.sizeが10より大きい時は警告が出るが処理は継続する。
そのためnewQueueOffset-9が複数回セットされることはありあえる。
@@ -328,21 +344,88 @@ export class VRMMaterialsV0CompatPlugin implements GLTFLoaderPlugin { | |||
|
|||
/** | |||
* Convert v0 render order into v1 render order. | |||
* This uses a map from v0 render queue to v1 compliant render queue offset which is generated in {@link _populateRenderQueueMap}. | |||
*/ | |||
private _v0ParseRenderQueue(materialProperties: V0Material): number { | |||
const isTransparent = materialProperties.keywordMap?.['_ALPHABLEND_ON'] ?? false; | |||
const enabledZWrite = materialProperties.floatProperties?.['_ZWrite'] === 1; | |||
|
|||
let offset = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OPAQUEやMASKの場合はoffsetは0となる
|
||
if (v0Queue != null) { | ||
if (enabledZWrite) { | ||
offset = this._renderQueueMapTransparentZWrite.get(v0Queue)!; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isTransparent が true で、renderQueが存在するときのみ_renderQueueMapTransparent(ZWrite)にaddされる。
getは成功すると期待してよさそう。
|
||
// create a map from v0 render queue to v1 render queue offset | ||
Array.from(renderQueuesTransparent) | ||
.sort() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sortが入ってるのでrenderQueueの大小関係は維持される
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
みました!
Description
This PR will make this parse v0 render queues properly.
It lists all render queues used in the VRM 0.0 model and creates a map to v1 compliant render queue offset in the same order.
See: https://github.com/vrm-c/vrm-specification/blob/master/specification/VRMC_materials_mtoon-1.0-beta/README.ja.md#render-queue
Points need review