[SOLVED] Shaders hot swap

I do not see any feature to refresh materials/shaders without game restart automatically when shader code is changed. Is it implemented or planned?


  1. launch game
  2. edit shader code
  3. click “make” in IDE (it’s fast, because incremental)
  4. see up to date shader in game.
1 Like

“We’ve tried nothing and we’re fresh out of ideas.”

1 Like

If you want to reload a material, you can remove that key from the assetmanager’s cache and load it again.

And now my fear is that we’ll enter into the "But"s that should have been explained in the first post.

1 Like

Sorry, there wasn’t channel with Simpsons on my TV when I was child, and when it apprears I was already fan of another things. So, I can’t understand your reference exact enough.

Do you mean I searched too short?

Sorry, I didn’t specified it in zero post (just fixed zero post). I mean automatically refresh shaders. without writing any application code for this. Like IDE swaps java classes in Debug mode.

You are right. I need to increase my skill of clear explanation.

Actually, I think about to implement such hot-swap, because it’s very useful. It allows to make very quick experiments with shader code (which may compensate absence of debugger) and thus do not afraid of it.

What do you think? Is it good intention from jME development process point?

It’s not part of a game engine but you are welcome to implement it yourself.

The SDK already has something like this anyway for shader nodes, etc… so it’s been done before. The only tricky part is “going back” if the shader starts crashing the renderer and stuff.

But since it sounds like you are writing an IDE/SDK, you may want to look at the existing shader nodes stuff in the official SDK. It does some kind of hot swap already.

I meant you provided us no information on what you’d already tried and why that wasn’t what you wanted. It leaves the burden on us to guess a whole bunch of things (incorrectly) until the game of “20 questions” is done.

I also feel like most of the time only putting as much effort into my answer as the OP (you) put into their question.

So from my perspective, it was just like a bunch of guys standing around looking at a problem that when the expert comes they just say “We’ve tried nothing and we’re fresh out of ideas.” ie: no help at all. It’s a common enough engineering joke and appropriate in all the right ways in so many situations.

…in this case, the “experts” didn’t even know what we were looking at until you clarified that much at least.

  1. jME is self-sufficient as library, so I do not use jME SDK.
  2. From my experience of browsing jME sources - there are no something like hot-swap feature for materials in jME core.
  3. I checked documentation and haven’t found anything like hot swap for materials.
  4. I installed JME SDK and tried to find something like hot swap among it’s buttons and menus (with launch to see if it performs material hot-swap by default) - and didn’t discovered something like hot swap for materials.
  5. Then I created the topic “Shaders hot swap” with the qeustion about “is there such feature”? And then got very agressive answer.

You still angry for my yesterday joke? Or I bother you too much with my long discussions for any occasion? I just try to be friendly and useful for community.
I spent about hour today to ask this question (and about hour to understand what’s wrong). It’s not even request for help - it’s just request for information that you either know or not. Isn’t these efforts from my side enough to justificate your “Yes, there is such feature” or “No, there are no” or even “I do not understand what do you exactly mean, please clarify”?
What else should I’ve done?
What was unclear in my question? I do not understand.

Anyway, I appreciate what you and your team do - the engine development and enthusiasm you communicate at forum with, and will respect you even if you do not like me for some reason.

You created a topic with almost no information. I responded in kind. It was not aggressive. It was just a humorous way of asking for more information.

I’ve asked folks for more information approximately 1,000,000 times over the last 10 years. It becomes difficult to type it the same way every time.

…but only 20 seconds to write it… and provide none of the information about what you looked into already.

Your original question:

To which the answer is yes it’s implemented from my perspective… all of the parts in JME core needed to support it are there.

…but I already knew that wouldn’t be a satisfying answer. I just didn’t know why.

Ok, then give me a second try, please.

Example of use the “shaders hot swap” feature I wonder about:

  1. Open IDE
  2. write some code, that use shaders
  3. launch game using IDE’s “Run” or “Debug” feature
  4. Perform some game actions to reach the point where shader is seen
  5. verify that shader is not good enough
  6. alt+tab to IDE, change code of shader
  7. (optional) press “Make” in IDE
  8. alt+tab to game and see that shader works much better.

Are there something similar in JME?

(is this formulation good enough?)

I think there may be a misunderstanding somewhere “lost in translation”… to to be clear, here is how I read the thread, a summary:

you: initial question about hot swapping without any real information

me: (snarky/humorous) quoted comment about not enough information

remy_vd: attempting to answer one interpretation of your question

me: predicting that it wasn’t a good answer because not enough information was provided.

you: asking me about the quote

you: saying “oops” and then providing necessary information in your original post. (good!)

you: adding another comment about utility of said feature

me: answering that it’s not a game feature but a game development feature and so is unlikely to be part of jme-core the way you have described. I refer to the SDK as an example you can look at if you want to implement the feature in your game.

me: responding to the question explaining where the quote comes from.

you: taking offense at me explaining the quote as if I was continuing the argument.
(I was not.)

At this point, your information is good enough and your question has already been answered.

Bottom line: we do not add IDE-only features to the core engine. The engine already has the features to support loading a shader at runtime. From the engine’s perspective, that is all that a game will need and we won’t be bloating jme-core with IDE-specific features.

Even just the question of “How will the game know to reload the shader?” is a question that will answered a little differently by everyone who wants this feature. And that’s the easy code to write in a game-specific way.

Thanks for explanation of your vision of dialog. No complaints from my side.

I haven’t found anything like this in JME SDK (in text part of documentation and by manual examination of SDK).

I didn’t see any hot discussion about this, so decided to start this one. My reference point is the way how hot reload usually works in java web development and how shaders hot reload implemented in another popular engine - very similar to java web dev way.

I’d propose to have some “dev mode” AssetManager that just watch files of all loaded materials for changes and reloads changed materials right now and here. In case of broken material it shows pink stub at place of broken material (and shows correct version as soon it’s fixed).

And actually, in background of this discussion I’ve found this topic about MaterialDebugAppState class that is already in core jar, which allows to configure “watchers” for specified assets names. The only difference from my proposal is that solution of my dream watches all existing (or just used) materials by default.

1 Like

Mmm… that class should not have been in core. :slight_smile: nehon knew better but now he’s gone so I can’t nudge him for it. :wink:

Anyway, so, yes, we already have it. lol