VertexBuffer for specific UV behavior Shaders

Hello, I would like to know if anyone know a way to send specification to the Shader about how to react to certain vertex group. I m actually using Tessellation and Vertex Displacement on a single Texture but the roof as to act differently if i want it to merge correctly with the rest of the model.

I know that i could make a specialize Shader with pre define Vertex Coord Condition but i would like to be able to tell the Vertex what to do for more flexibility with the same shader.

mhh nnot sure I understand your question, but seems that you need an extra vertex buffer in the mesh with and index or something similar for each vertex.

Yea I understand that it s hard to know what i m trying to do.

You see I m Tessellating all my building in my game and since it s a builder game, I need to add a roof. But i would like that roof to be part of the same material for each building to make the game Lighter. At the moment i am Displacing the Z axis of each building face and I would like to make an exception for the Roof so the border would displace in x,y instead(Yea my coord are messed up since i used the Basic Quad class and did a rotation :stuck_out_tongue: )

So at the moment all my wall displace just fine, but the roof would only displace on one side.

So my question is, Can i assign a special VertexBuffer and how could I get the Bufffer data in the .vert Shader if possible?

Also if you want the Shader i made to be add as OpenSource in the engine i don’t mind, People may want to do some Tessellation Quick on basic Surface like road, I Also have a Bezier base RoadMesh Generator which build road from a List of 4 vector(start, Control Point 1, Control Point 2,end) with no Stretching and easy to resize. It support Tessellation and no Tessellation. Also it generate a Single Model.

So if you guys think it could be nice to have this kind of Shader/Custom Mesh let me know

Well it’s related to custom mesh
Basically you are going to add another mesh buffer (like Position, Normal, or TaxCoord).
you can see all types of vertex buffer you can have here jmonkeyengine/ at master · jMonkeyEngine/jmonkeyengine · GitHub

Unfortunately, JME doesn’t allow custom vertex buffers, so you’ll have to use an existing one. Can feel a bit of a hack but you don’t have any choice.
I suggest you use one of the TexCoord (not the first one though :p). For example if you use the TexCoord3, and set it as a 3 float component you’ll be able to use in your vertex shader

attribute vec3 TexCoord3;
1 Like

omg yea i didn’t though about the Multiple Texture Coord :smile: That will technically do the job if they are set to 1 for that mesh Vextex!

I am certainly interested in this.

You have to know that there is what i would call, Threshold on and i think there is still glitch sadly :frowning:
But i would be happy to share the Mesh, And Shader for the road Mesh

If that was directed at me. I’m interested in the shader as ive tried to make something similar before.

The Shader and the Mesh or Just the Shader? I can make a Git and make all the file public, But you will need to reassign the File location your self :stuck_out_tongue: But that s normal ^^

@n3cr0 I guess it would help to have the mesh to see it work with the shader.
Thanks for your help.

I failed to Put the mesh at the right place but it s at the root :stuck_out_tongue: Also don’t try anything extreme it may explode weirdly :stuck_out_tongue:

Edit: Also change the FIle Location for the Material! and the Mesh

Thanks for the code and mesh, if you wanted to know i plan on doing something that looks like this.

I’ll figure out how to get it to work, i remember mine failing when the 2 start and end points were exactly the same.

1 Like

oh yea, the start and end point, I don’t know if i got this fix yet. Maybe i fix it while fixing the curve low distance… Btw Height is Road segment length, Width is how large the road is. Smaller length and larger width give better result in road precision. also you can add hole in the path and use a HeightMap to lift the road and keep the hole lower :P, I don’t think physic will apply correctly although :stuck_out_tongue:

Here it is in my game but no textures, ill do that later.

does it work as intended?
Edit: Btw how did you mark the road? Also the Tesselation Shader Doesn’t support shadows i think. You will have to use the Lighting Shader or your own :slight_smile:

Yes, it works better than what i had.
If you mean the tyre marks on the road thats just a thing the game does.

For shading: I haven’t tried to make any kind of shaders or textures yet, would it just be adding the relevant parts from the lighting material into the new material?

Mine support the Lighting, but not the shadows, I don’t know if it was only adding the Material code or more so i left it on the side. :stuck_out_tongue: You could probably still try to add a shadow and test the Tessellation Shader to see for your self :slight_smile:

Or i could also just add shadow to my own building… lol

Sorry, im not really on top of all the words for textures/material things.

I just gave this a quick Unshaded.j3md to get it work and show up.
I won’t be able to test the tessellation shader or the shadows until about 8 hours from now, but it looks like the j3md file contains the shadow fields but the .vert or the .frag don’t.

I fixed all the texture file names.
Tested the shadows, shows work fine.

The texture though, I just used any generic image i had already in the project.
It shows up as completely opaque. (not posting a screenshot of that its boring.

Code that loads the road: (my texture stuff is in assets/mat…)

List<Vector3f> list = new ArrayList<Vector3f>(); 
add(new Vector3f(0,98,0));
add(new Vector3f(30,98,0));
add(new Vector3f(100,110,80));
add(new Vector3f(100,110,100));
new RoadMesh(3, 6, list);
geo = new Geometry("road", mesh);
mat = new Material(App.rally.getAssetManager(), "assets/mat/road/Tesselation.j3md");
setTexture("DiffuseMap", app.getAssetManager().loadTexture("assets/image/asphalt_tile.jpg"));