How do I create a texture coordinates buffer for a sphere?
I already know how to do this with a Quad:
FloatBuffer tex1 = BufferUtils.createVector2Buffer(4);
for (int x = 0; x < 4; x++)
tex1.put(1.0f).put(0.0f);
q.setTextureCoords(new TexCoords(tex1), 1);
FloatBuffer tex2 = BufferUtils.createVector2Buffer(4);
for (int x = 0; x < 4; x++)
tex2.put(0.0f).put(1.0f);
q.setTextureCoords(new TexCoords(tex2), 2);
I need this for the parallax shader to bumpmap a sphere. Like in the TestFragmentProgramState.class but now with a sphere. My search in the forum and in the www was not that successfuly.
The parallax shader creates a quad right? So all you need to do is to replace "new Quad(…)" with "new Sphere(…)" and you have the parallax shader on a sphere.
I already did that, with no success … I need more input please!
I thought it's because of the float buffer and the setTextureCoord() method which doesn't work with a sphere that I did not use while testing it with a sphere.
So is it right than, that I don't need to create a float buffer for the sphere cause this class already has one?
If so, how do I can access this buffer?
Do I need to change the texture coordinates of the sphere like I have to do it with the quad (see first post) to get the parallax shader working?
And if so, how do I change them?
I tested my 3 textures (color, normal map, specular map) with the Fragment test case on a quad and they all worked very well, but when I apply this shader to a sphere they are only be overlayed on the sphere without bump mapping.
1+2. Spatials do have their own texture coordinate buffer. You can access it with getTextureCoords() and setTextureCoords().
3. You don't have to!
If you want to apply a parallax shader, or any other, to a spatial (i.e. a sphere), use the GLSLShaderObjectsState instead of trying to do it like in the TestFragmentProgramState.java described. Especially if you don't have any idea what's going on in the used shader files .vp and .fp for this example. (I think they do work only for quads!?)
How to use a GLSLShaderObjectsState, for a normalmap or parallax shader, is well described in the jmetest/renderer/loader/TestNormalmap.java