Skip to content

Commit

Permalink
[shgraph] Fix preview applying shader to materials without a shadergraph
Browse files Browse the repository at this point in the history
  • Loading branch information
EspeuteClement committed Nov 20, 2024
1 parent 253b4e7 commit 4f2f38a
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions hide/view/shadereditor/ShaderEditor.hx
Original file line number Diff line number Diff line change
Expand Up @@ -376,8 +376,8 @@ class ShaderEditor extends hide.view.FileView implements GraphInterface.IGraphEd
override function onHide() {
super.onHide();
if (isLoaded) {
meshPreviewScene.dispose();
graphEditor.previewsScene.dispose();
meshPreviewScene?.dispose();
graphEditor.previewsScene?.dispose();
isLoaded = false;
}
}
Expand Down Expand Up @@ -1419,9 +1419,10 @@ class ShaderEditor extends hide.view.FileView implements GraphInterface.IGraphEd
if (newShader == null)
return;

var found = false;

@:privateAccess
for (m in mesh.getMaterials()) {
var found = false;

var curShaderList = m.mainPass.shaders;
while (curShaderList != null && curShaderList != m.mainPass.parentShaders) {
Expand Down Expand Up @@ -1454,8 +1455,10 @@ class ShaderEditor extends hide.view.FileView implements GraphInterface.IGraphEd

curShaderList = curShaderList.next;
}
}

if (!found) {
if (!found) {
for (m in mesh.getMaterials()) {
m.mainPass.addShader(newShader);
}
}
Expand All @@ -1476,7 +1479,7 @@ class ShaderEditor extends hide.view.FileView implements GraphInterface.IGraphEd
}

@:privateAccess
if (meshPreviewScene.s3d != null) {
if (meshPreviewScene != null && meshPreviewScene.s3d != null) {
meshPreviewScene.s3d.renderer.ctx.time = graphEditor.previewsScene.s3d.renderer.ctx.time;
}

Expand Down

0 comments on commit 4f2f38a

Please sign in to comment.