Vertex and Pixel Shaders

VertexProgram vp = new VertexProgram(aString,new Vector4f[]{… … …});

or
VertexProgram vp = new VertexProgram();
vp.setProgram(aString);
vp.setProgramInput(new Vector4f[]{… … …});
vp.setEnable(true);
shapeAppearance.setVertexProgram(vp);

FragmentProgram fp = new FragmentProgram(aString);
fp.setProgramInput(new Vector4f[]{… … …});
fp.setEnable(true);
shapeAppearance.setFragmentProgram(fp);

Yuri are you there ;D ;D

What about having an Interface for shader code

public interface ShaderProgram

And then, have an external Java tool that can take common shader code (cg or so) and compile it into an Object that implements ShaderProgram?

Would that be an approach?

Worrorz (understand horrors), no CG compiling, or at the very least, make it up to the programmer whetheir to use CG or not.
Reason is, I sometimes notice that CG compiled code can have 5 times as many instructions as hand tweaked code would have, now that’s outrageous.
All I wanna do is simple vertex and pixel shading pleaaase…
PS: There should a routine checking the vertex or the fragment program to see if VS and PS are supported and if yes, if their version matches the hardware.
Should be easy, and I’m willing to give it a go :stuck_out_tongue:

How do hand-coded shader programs look like? Kind of a assembly, right?
CG only would be ONE possibility to create ShaderProgram objects…

Still, the approach would work without the need for explicit string literals in the sourcecode.


abstract class SimpleShaderProgram implement ShaderProgram

  protected final setProgram( String program )
  {
    // ...
  }


There could be generated code like that:


class MyShaderProgram extends SimpleShaderProgram
{

 public MyShaderProgram()
 {
    setProgram( /* your shader code */ );
 }
}

There could be utility programs like

[]cg2xith
[
]shader2xith
[*]oglsl2xith

Know what I mean?

Here I am.

Yes, the idea of JCD post is quite similar to one I was going (and still want) to suggest.

I have personal preferences regarding the shader languages, but 100% sure that we should leave shader programming interface generic enough to support both low-level and high-level GPU programming.

You know I already made a poll on this topic, but if we will follow the polling results right now we will get in big troubles on the nearest stages.

The major problem for all languages except Cg that they do not have good abstraction layer for parameter passing, which is 100% needed to isolate Xith3D data structures, such as Vertex4f[], from specific extension implementation details.

On longer range I will definitely vote for high-level languages, such as GLslang and Cg, but low-level programming should be always an option, but at this stage don’t expect cross-compilers that will adapt your low-level programs from one extension type to another.

I think that Xith3D should support shader program input abstraction layer, similar to one implemented in JOGL/Cg module; this layer should be compatible with different shading languages; alternate shading programs should be supported.

Now on realistic plans. Due to my personal schedule, please don’t expect that I will start implementing this functionality within nearest three weeks. But then I will need this functionality very urgent, so I guess we will have some progress with it :).

Yuri

P.S. I would like to see all your ideas on how GPU programming interfaces should look in Xith3D.

Lemmie see if I can implement some PS and VS 1.1 effects tonight :slight_smile:

Making a VertexProgram following the steps of those who did the Texture classes (keep in mind that Vertex shaders needs to be generated and assigned an ID first, just like textures) but for some &^%&%&^%&* reason my ide & compilers (NetBeans & TextPad) can’t seem to find any class that I just created.
For example when I compile the class Appearance and Texture, well everything runs just fine, however if I adda class “exture” that is simply the same than “Texture” (I only tool the t off), and call it from within Appearance or any other class that is in the same folder, it throws an error about non finding the newly created class…
Grrrrr so much frustration
[

Please delete this thread, there is another one where we can talk about the topic at hand