Shader Question

So let’s say that I want to use the unshaded material with my mesh but I also wanted to write a shader that does some other function. Is there any way to do this without modifying the unshaded material? To use a shader does it HAVE to be a material? Thanks for the help.

Well, it could be easy if we had some kind of shader code injection system…oh wait!!

To answer your questions (backward):

@okelly4408 said: To use a shader does it HAVE to be a material?
Yes. That's the basis of our material system.
@okelly4408 said: Is there any way to do this without modifying the unshaded material?
Yes but it's still a bit experimental and not yet fully featured. We have something called Shader nodes, that is a shader composition system. Right now in the core you have a material called UnshadedNodes.j3md that uses this system. You coudl use it and just code the "other functions" you wanted to add as additional nodes. I don't recommend doing it if you don't have at least some shader coding experience though. here is a link to a post where I explain everything http://hub.jmonkeyengine.org/forum/topic/shader-inj-nah-shader-nodes/ I recommend reading the documentation ofc ;)
1 Like

I see. Well playing with the GPU will probably be my next project so I will try to work with that…either that or just switching to c++. :slight_smile: Anyway, thanks for the advice.

@okelly4408 said: I see. Well playing with the GPU will probably be my next project so I will try to work with that...either that or just switching to c++. :) Anyway, thanks for the advice.

Yeah, because switching to c does change the problems that are based in the shader language? WTF

I feel that it allows more direct customization…giving more options. Plus it’s probably better to start at a more basic level to get into shader-languages.

GLSL is used in a fashion alike that of SQL: It’s a separate language, compiled and executed outside your program.
The GLSL compiler sits inside the graphics card.

So it doesn’t matter whether you program in Java, C++, or Intercal, from the program’s perspective, the shader code is just a string that you send to the graphics driver.

1 Like

Yea that’s true but using shaders specifically with jmonkey involves working with other shaders which I did not write and thus do not have a complete understanding of them. This can obviously lead to much stress when just starting to work with shaders.

<cite>@okelly4408 said:</cite> Yea that's true but using shaders specifically with jmonkey involves working with other shaders which I did not write and thus do not have a complete understanding of them. This can obviously lead to much stress when just starting to work with shaders.

So by using C++ you’re saying that you won’t have to learn GLSL and will get your a COMPLETE UNDERSTANDING of shaders? Wow, I might jump on that boat too. A language that gives you the knowledge of other languages without effort. Cool.

You do realize how dumb you sound right? And yes, I’m being rude, but your reasoning is, to be extremely very polite, damn flawed.

<cite>@okelly4408 said:</cite> Yea that's true but using shaders specifically with jmonkey involves working with other shaders which I did not write and thus do not have a complete understanding of them. This can obviously lead to much stress when just starting to work with shaders.

You do not have to use the bundled jME shaders, you can create your own (and that is rather easy once you get the hang of it). I have built many custom shaders in jME so I know.

Rebuilding a whole rendering engine in C++ (or any language for that matter) is a massive undertaking and if you ever succeed with that before hell is freezing over shaders should be no match.

But why build a wooden boxcar yourself when stranding next to the free jME Ferrari, when all you have to learn is how to change the wheels?