Skip to content

Commit

Permalink
feat: compatible with material renderstate
Browse files Browse the repository at this point in the history
  • Loading branch information
Sway007 committed Sep 13, 2024
1 parent a828991 commit 98de462
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions packages/core/src/shader/Shader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,21 +113,22 @@ export class Shader implements IReferable {
);

const renderStates = passInfo.renderStates;
const renderState = new RenderState();

shaderPassContent._renderState = renderState;
// Parse const render state
const { constantMap, variableMap } = renderStates;
for (let k in constantMap) {
Shader._applyConstRenderStates(renderState, <RenderStateElementKey>parseInt(k), constantMap[k]);
}

// Parse variable render state
const renderStateDataMap = {} as Record<number, ShaderProperty>;
for (let k in variableMap) {
renderStateDataMap[k] = ShaderProperty.getByName(variableMap[k]);
if (Object.keys(renderStates.constantMap).length > 0 || Object.keys(renderStates.variableMap).length > 0) {
// Parse const render state
const renderState = new RenderState();
shaderPassContent._renderState = renderState;
for (let k in constantMap) {
Shader._applyConstRenderStates(renderState, <RenderStateElementKey>parseInt(k), constantMap[k]);
}

// Parse variable render state
const renderStateDataMap = {} as Record<number, ShaderProperty>;
for (let k in variableMap) {
renderStateDataMap[k] = ShaderProperty.getByName(variableMap[k]);
}
shaderPassContent._renderStateDataMap = renderStateDataMap;
}
shaderPassContent._renderStateDataMap = renderStateDataMap;

return shaderPassContent;
});
Expand Down

0 comments on commit 98de462

Please sign in to comment.