Ho to project a shader on an alpha bended map?


I managed to create shaders on others objects, and on a map where there is some procedural textures, but when i try on a map where textures are display in function of alpha maps (like TestIsland) the maps become all black ?

I made a lot of test, but i dont find the way to success  :oops:

Do you have an idea ? 

You gotta make sure the shader passes the alpha value from the texture, e.g:

uniform sampler2D myTex;

void main(){
    vec4 texColor = texture2D(myTex, gl_TexCoord[0].xy);
    gl_FragColor = vec4(texColor.rgb, texColor.a); // notice the alpha of the texture being passed to gl_FragColor

Thanks for your answer, but i'm not sure too get your exemple  :expressionless:

can you detail a bit more on what I may be wrong, or the solution of it ?

Sorry I'm a newbe on JME :wink:

I think it's probably because i'm using a PassNode to be able to overlay different textures.

Is there another way ? how would you do to provide shaders of object on the ground of a map like the one used for TestIsland ?

You're trying to use shaders for the maps in TestIsland? Sorry but that probably won't work. TestIsland has a special setup where the new maps are "blended" in with the previous to create the texture splatting effect. It requires that you multiply the alphamap by the detailmap in the shader and pass the alpha to gl_FragColor like I did in my example. If you don't have experience with shaders I suggest you try to understand them better before trying to use them for something like this.

Thanks for your reply, it's what i understood by analyzing the code.

But what you are saying is that there still a way to have nice map (with road painted on it for exemple) and shadows projected on the map, right ?

Did you already did it ?