1

I'm currently trying to mimic Gouraud shading in JavaFX. Specifically, I want to be able to apply vertex colors to textured polygons.

The problem is, I'd rather not have to generate unique textures for all of the used vertex color / texture combinations, due to resource limitations.

My solution is to setup the model without vertex coloring, then overlay faces on top, with (relatively) small transparent textures which overlay on top to create the intended look.

However, my problem is that, I cannot seem to find any information or techniques to procedurally make the texture which when overlayed will create the intended effect.

Generating the "colored texture" uses the original texture, and multiplies the rgb values by brightness values which are unique for each pixel. My problem is, I need to figure out how to mimic this process, by just overlaying one face upon another.

I have tried changing the BlendMode, however no matter what I set it to, the MeshViews both completely disappear when I do this. I do not know why this happens.

Petersnow2
  • 69
  • 5
  • If there is some kind of math expression for the color of each vertex, it can be easily done with one texture image created on the fly. The [FXyz3D](https://github.com/FXyz/FXyz) library has a `TexturedMesh` that applies this concept to create density maps, like in this [picture](https://github.com/FXyz/FXyz/blob/master/resources/SpringMesh.png). Would this work for you? – José Pereda Feb 24 '20 at 23:24
  • @JoséPereda I just took a look at that, and gonna be honest, I'm not entirely sure I understand how it applies color like this. – Petersnow2 Feb 24 '20 at 23:34
  • This [question](https://stackoverflow.com/questions/26831871/coloring-individual-triangles-in-a-triangle-mesh-on-javafx) might explain it. – José Pereda Feb 24 '20 at 23:35
  • I see. Yes, so the problem is in this technique. The problem is that I want to combine vertex coloring with textures on the same face. This requires duplicating the texture on the texture map for each combination of vertex colors and textures. This scales incredibly poorly. – Petersnow2 Feb 24 '20 at 23:47
  • So, I'd like to do an additional translucent face on top, which applies shading without needing to create so many unique textures. – Petersnow2 Feb 24 '20 at 23:49
  • That's why I asked about a math expression, to create one single texture (as combination of all the required coloring per vertex). You can't apply two different textures (Phong material only supports one) to a single mesh. To do so you will have to combine two meshes and that doesn't work well. – José Pereda Feb 24 '20 at 23:52
  • A math expression would be perfect, can Fxyz do that in addition to a texture? – Petersnow2 Feb 24 '20 at 23:53
  • See [setTextureModeVertices3D](https://github.com/FXyz/FXyz/blob/master/FXyz-Core/src/main/java/org/fxyz3d/shapes/primitives/TexturedMesh.java#L180), or an [example](https://stackoverflow.com/questions/50976389/apply-gradient-to-sphere-object-with-javafx) – José Pereda Feb 25 '20 at 00:07
  • Perhaps I'm missing something. I can't figure out what the heck the point of the 1530 value is. – Petersnow2 Feb 25 '20 at 01:35
  • That is a given number of colors to create a texture. For instance, using the HSB palette the number is 1530 (6x255), however you can use a different number or create directly a palette of colors. Explore the API and run the FXyz sampler. – José Pereda Feb 25 '20 at 08:47

0 Answers0