Shader Inj......Nah... Shader Nodes!

Hi @nehon,

First of all, nice work!!! this feature is excelent!

I will describe a couple of issues that I’m having using the shader node editor. Sorry if this is not the correct place. I updated the SDK an hour ago.

1.- I add a Output color node but I cann’t delete it.

2.- I go to create a new material definiton template, I change to Editor view. Then, I get a NullPointerException when a select the any of the 4 default nodes.

[java]
java.lang.NullPointerException
at com.jme3.gde.materialdefinition.editor.MatDefEditorlElement.selectionChanged(MatDefEditorlElement.java:239)
at com.jme3.gde.materialdefinition.editor.Diagram.select(Diagram.java:325)
at com.jme3.gde.materialdefinition.editor.NodePanel.mousePressed(NodePanel.java:247)
at java.awt.Component.processMouseEvent(Component.java:6285)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
at java.awt.Component.processEvent(Component.java:6053)
at java.awt.Container.processEvent(Container.java:2041)
at java.awt.Component.dispatchEventImpl(Component.java:4651)
at java.awt.Container.dispatchEventImpl(Container.java:2099)
at java.awt.Component.dispatchEvent(Component.java:4481)
at com.jme3.gde.materialdefinition.editor.NodePanel$LabelMouseMotionListener.mousePressed(NodePanel.java:425)
at java.awt.AWTEventMulticaster.mousePressed(AWTEventMulticaster.java:262)
at java.awt.Component.processMouseEvent(Component.java:6285)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
at java.awt.Component.processEvent(Component.java:6053)
at java.awt.Container.processEvent(Container.java:2041)
at java.awt.Component.dispatchEventImpl(Component.java:4651)
at java.awt.Container.dispatchEventImpl(Container.java:2099)
at java.awt.Component.dispatchEvent(Component.java:4481)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4577)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4235)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)
at java.awt.Container.dispatchEventImpl(Container.java:2085)
at java.awt.Window.dispatchEventImpl(Window.java:2478)
at java.awt.Component.dispatchEvent(Component.java:4481)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:643)
at java.awt.EventQueue.access$000(EventQueue.java:84)
at java.awt.EventQueue$1.run(EventQueue.java:602)
at java.awt.EventQueue$1.run(EventQueue.java:600)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:98)
at java.awt.EventQueue$2.run(EventQueue.java:616)
at java.awt.EventQueue$2.run(EventQueue.java:614)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:613)
at org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:158)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
[/java]

  1. yes that’s still on the todo list.
  2. Did it happen once or every time? I don’t have this issue.
@nehon said: 2. Did it happen once or every time? I don't have this issue.

It happens once, but if I close the SDK an open it, issue happens again. After I get the error, Properties panel is not updated according to the node selected even selecting the others (because of the issue I guess).

Yeah i think i got how it happens now, something seems dirty in how i initialize the navigator panel.
thanks for reporting, i’m gonna fix this.

1 Like

Bump because of awesome :stuck_out_tongue_winking_eye:

1 Like
@normen said: Bump because of awesome ;P
oh boy, you shouldn't, I heard the moderators here are not funny ;)

@H about the issue in the editor it should be fixed now.
Also now the text view and the editor view are synchronized.
Something i didn’t say before though, the visual editor does not allow you to do all the stuffs the j3md supports (yet), but of course you can still edit the file text style as before.

1 Like

One thing I would really like is the possibility of writing shaders inline in the j3md/shadernode files. Especially for very short shaders it would be nice if everything was self-contained =)

@kwando said: One thing I would really like is the possibility of writing shaders inline in the j3md/shadernode files. Especially for very short shaders it would be nice if everything was self-contained =)
uh? you mean inside the description file? Idk...i agree it can be handy....but that sounds messy to me. @normen, @pspeed, @Momoko_Fan what do you think?

Also, i’d like to make a shaderNode editor (j3sn enditor), so you can easily create and edit your shader nodes. There would be a bridge between the j3md and the j3sn editors so you could easily go from one to the other.
The j3sn editor would have an upper panel with some swing style ui where you could add/remove inputs and outputs, edit the doc and so on… and a lower part where you could edit the shader code itself (i’d like to plug in the shader syntax plugin we have). This would save the 2 files (j3sn and vert or frag). So you would be able to edit both the definition and the code itself in one editor.
Maybe this would suit your need.

Wow. A few months of the radar and such big changes… Nice. A great new feature.

Is there a plan how to add multiple material definitions to a material, because currently you want be able to add ‘glow’ or similar techniques. (Of corse i know how to do it manually and its not a problem for me)

You can add any technique you want to a j3md. Just like before.
For now the graphic editor only supports one technique, but I’ll change that soon.

@nehon said: uh? you mean inside the description file? Idk...i agree it can be handy....but that sounds messy to me.
My thought was to replace the path to the shader with a block in the j3md (see the .frag part) [code] MaterialDef Example {
MaterialParameters {
    Texture2D Texture
    Color Color (Color)
}

Technique {
    VertexShader GLSL100:   Common/MatDefs/Gui/Gui.vert
    FragmentShader GLSL100: {
        void main(){
            gl_FragColor.rgb = vec3(0.5);
        }     
    }

    WorldParameters {
        WorldViewProjectionMatrix
    }

    Defines {
        TEXTURE : Texture
    }
}

Technique {
}

}
[/code]

Note that I have not convinced myself about the usefulness of this idea yet =P. I agree with you, handy but potentially messy in the long run…

Hopefully your work with all the shader stuff will make it less painful to write shaders in the future =) now you have to flip back and forth through several files and make sure you propagate changes to all places they are needed… but I guess you are familiar with that =P

Very nice

Idk about the inline thing… Lets see if we get along without for now, if theres really loads of two-line shader node files popping up then we can think about it again. Generally I’d say this is mainly a way to create lots of boiler plate code :wink:

@kwando said: Note that I have not convinced myself about the usefulness of this idea yet =P. I agree with you, handy but potentially messy in the long run...

Another way would be to make a really advanced editor, say that the name of the shader-file is a hyperlink so you can open it in a separate editor (I think that is not so hard to build in Swing). More advanced it could make an editor fold of the contents of the referenced file. So like, you click a little [+] in the gutter and see the content of the shader file inlined, maybe even editing it inline (might be complicated to build, don’t know enough of the NB editor component).

@jmaasing said: Another way would be to make a really advanced editor, say that the name of the shader-file is a hyperlink so you can open it in a separate editor (I think that is not so hard to build in Swing). More advanced it could make an editor fold of the contents of the referenced file. So like, you click a little [+] in the gutter and see the content of the shader file inlined, maybe even editing it inline (might be complicated to build, don't know enough of the NB editor component).

Yeah, some things are not as simple to implement as in plain swing if you don’t want to either ignore existing APIs for that or just plain add ugly subsystems that require different maintenance. Like for example it might be the NetBeans platform moves to JavaFX at some point, by using the existing APIs we’d then get that “for free” as well. But possible, definitely.

@nehon said: @H about the issue in the editor it should be fixed now.

Same issue still :-/ . Updated a few minutes ago.

[java]
java.lang.NullPointerException
at com.jme3.gde.materialdefinition.editor.MatDefEditorlElement.selectionChanged(MatDefEditorlElement.java:246)
at com.jme3.gde.materialdefinition.editor.Diagram.select(Diagram.java:325)
at com.jme3.gde.materialdefinition.editor.NodePanel.mousePressed(NodePanel.java:247)
at java.awt.Component.processMouseEvent(Component.java:6287)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
at java.awt.Component.processEvent(Component.java:6055)
at java.awt.Container.processEvent(Container.java:2039)
at java.awt.Component.dispatchEventImpl(Component.java:4653)
at java.awt.Container.dispatchEventImpl(Container.java:2097)
at java.awt.Component.dispatchEvent(Component.java:4481)
at com.jme3.gde.materialdefinition.editor.NodePanel$LabelMouseMotionListener.mousePressed(NodePanel.java:425)
at java.awt.AWTEventMulticaster.mousePressed(AWTEventMulticaster.java:262)
at java.awt.Component.processMouseEvent(Component.java:6287)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
at java.awt.Component.processEvent(Component.java:6055)
at java.awt.Container.processEvent(Container.java:2039)
at java.awt.Component.dispatchEventImpl(Component.java:4653)
at java.awt.Container.dispatchEventImpl(Container.java:2097)
at java.awt.Component.dispatchEvent(Component.java:4481)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4575)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4233)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4166)
at java.awt.Container.dispatchEventImpl(Container.java:2083)
at java.awt.Window.dispatchEventImpl(Window.java:2482)
at java.awt.Component.dispatchEvent(Component.java:4481)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:648)
at java.awt.EventQueue.access$000(EventQueue.java:84)
at java.awt.EventQueue$1.run(EventQueue.java:607)
at java.awt.EventQueue$1.run(EventQueue.java:605)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:98)
at java.awt.EventQueue$2.run(EventQueue.java:621)
at java.awt.EventQueue$2.run(EventQueue.java:619)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:618)
at org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:158)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
[/java]

I downloaded the trunk folder (http://jmonkeyengine.googlecode.com/svn/trunk) in order to build the jME3-SDK and debug the Shader Node Editor, but when I run build command I get
[java]
E:0 Java\eclipse-jee-juno-win32-x86_64\workspace\jMonkeyTrunk\build.xml:17: The following error occurred while executing this line:
E:0 Java\jmonkeyplatformrc2\harness\suite.xml:184: The following error occurred while executing this line:
E:0 Java\jmonkeyplatformrc2\harness\build.xml:174: Cannot compile against a module: E:0 Java\jmonkeyplatformrc2\platform\modules\org-openide-text.jar because of dependency: org.openide.text > 6.49.3
BUILD FAILED (total time: 2 minutes 57 seconds)
[/java]

I don’t know how to fix this. Perhaps I need to get a older version of org.openide.text.jar file.

uh ok…I really don’t get what’s going on…
I think the NPE occurs on the navigator panel, but now it should never be null at this point…
What are the exact steps you take to get there?

@nehon said: uh ok....I really don't get what's going on... I think the NPE occurs on the navigator panel, but now it should never be null at this point... What are the exact steps you take to get there?

Create a new Basic Game project (File -> New Project… Select JME3 -> BasicGame. Click Next. Enter a name. Click Finish).
Right click on assets/MatDefs folder. New -> Other… Material -> Material Definition Template. Click Next. Enter a name. Click Finish.
Double click on the j3md file.
Click on Editor button.
Select an element from the visual editor. All the elements throw the same execption.

Perhaps I need to install additionals plugins, I don’t know.

1 Like

ok thanks i’m gonna test it like this.

Hi @nehon,

Today I cleaned my pc (uninstall SDK and deleted jmonkeyplatform folders from my harddrive (even hidden folders)) because I was having an issue building the sdk. So, I installed SDK again in order to get the code, build it from svn successfully and debug the NullPointerException issue that I mentioned in the previous post. But after install and update with nightly repo files, I was not able to reproduce the issue again, all work fine. So, or you fixed it (thanks by the way) or it was an issue on my local env.

Thanks for your help