noeska
18-01-2008, 09:22 PM
It is possible to convert almost any shader format to arb vertex and fragment shaders. This is possible with the ati ashli viewer available at: http://ati.amd.com/developer/ashli.html . It converts from:
- Renderman Shaders
- HLSL Shaders (directx)
- GLSL Shaders (directx)
to ARB vertex and ARB fragment shaders.
At first i thought is was fixed to the examples supplied, but you can add your own scenes and shaders.
For Renderman shaders you need to modify: ashliViewerListRMan.dat
For GLSL Shaders you need to modify: ashliViewerListGLSL.dat
For HLSL Shaders you need to modify: ashliViewerListHLSL.dat
You will find these files in: C:\Program Files\ATI Technologies\Ashli Viewer 1.7.0\bin if you installed the ashli viewer in the default location.
The format for adding your own scene is:
program Ambient
shader basic.glsl
shader ambient.glsl
scene ambientduckie.scn
The program is the entry in the treeview and the sader and scene are showed when click on the + in the treeview. Each program needs to be seperated by a blank line.
The .glsl files and .scn file need to be in the ShadersGLSL subfolder.
Used textures need to be in the Textures subfolder and should be in .tga format.
Used models need to be in the Models subfolder and are in a custom format that should easy to understand:
Object("room") {
Specular3f(1.0, 1.0, 1.0);
// unique vertices: 9445
Normal3f(-0.000015, 0.997051, -0.076735);
Color3f(0.615686, 0.000000, 0.000000);
TexCoord2f(0, -30.370804, -12.178762);
Vertex3f(105.282875, 56.890732, -192.224258);
etc ...
// faces: 11785
// material Material #124
UseMaterial("simple");
Triangle(5491,5492,543);
Triangle(5494,5495,5496);
etc ...
Triangle(9364,9369,9362);
ObjectFit(2,1.0);
} /* end of object sofa */
But for the moment i am confused by how the triangle indices work.
More important are the material names as you can assign shaders to them in the .scn file. So for now i name my material after an material available in an object.
Setting up a scene with materials is done like this:
object rubberduckie
background ramp
rotate x 280
rotate z 45
translate z -3
material duckie
shader ambient.glsl
float Ka 1.0
float intensity1 1
color lightcolor1 1 1 1
vshader basic.glsl
lightparams
1 intensity1 lightcolor1
end
First you need to specify the model you want to use
Next a background (don't know where these are specified)
Next you specify how the object is positioned
Now we need to specify the materials
As you can see you can set default values for globals in the glsl shader. Also using one shader you can make multiple materials if your shader is flexible enough. The above is an basic scene. But things can get complicated.
Finaly you need to setup some lights.
On opening the scene you can compile arb fragment and vertex shaders that you can view and copy and post for use with your opengl application.
You can optimize shaders for nvidia and or ati video cards.
Oh before i forget you can also compile to directx shaders.
Ok this should get you started converting shaders to something less readeable... (be sure to keep your original :wink: )
- Renderman Shaders
- HLSL Shaders (directx)
- GLSL Shaders (directx)
to ARB vertex and ARB fragment shaders.
At first i thought is was fixed to the examples supplied, but you can add your own scenes and shaders.
For Renderman shaders you need to modify: ashliViewerListRMan.dat
For GLSL Shaders you need to modify: ashliViewerListGLSL.dat
For HLSL Shaders you need to modify: ashliViewerListHLSL.dat
You will find these files in: C:\Program Files\ATI Technologies\Ashli Viewer 1.7.0\bin if you installed the ashli viewer in the default location.
The format for adding your own scene is:
program Ambient
shader basic.glsl
shader ambient.glsl
scene ambientduckie.scn
The program is the entry in the treeview and the sader and scene are showed when click on the + in the treeview. Each program needs to be seperated by a blank line.
The .glsl files and .scn file need to be in the ShadersGLSL subfolder.
Used textures need to be in the Textures subfolder and should be in .tga format.
Used models need to be in the Models subfolder and are in a custom format that should easy to understand:
Object("room") {
Specular3f(1.0, 1.0, 1.0);
// unique vertices: 9445
Normal3f(-0.000015, 0.997051, -0.076735);
Color3f(0.615686, 0.000000, 0.000000);
TexCoord2f(0, -30.370804, -12.178762);
Vertex3f(105.282875, 56.890732, -192.224258);
etc ...
// faces: 11785
// material Material #124
UseMaterial("simple");
Triangle(5491,5492,543);
Triangle(5494,5495,5496);
etc ...
Triangle(9364,9369,9362);
ObjectFit(2,1.0);
} /* end of object sofa */
But for the moment i am confused by how the triangle indices work.
More important are the material names as you can assign shaders to them in the .scn file. So for now i name my material after an material available in an object.
Setting up a scene with materials is done like this:
object rubberduckie
background ramp
rotate x 280
rotate z 45
translate z -3
material duckie
shader ambient.glsl
float Ka 1.0
float intensity1 1
color lightcolor1 1 1 1
vshader basic.glsl
lightparams
1 intensity1 lightcolor1
end
First you need to specify the model you want to use
Next a background (don't know where these are specified)
Next you specify how the object is positioned
Now we need to specify the materials
As you can see you can set default values for globals in the glsl shader. Also using one shader you can make multiple materials if your shader is flexible enough. The above is an basic scene. But things can get complicated.
Finaly you need to setup some lights.
On opening the scene you can compile arb fragment and vertex shaders that you can view and copy and post for use with your opengl application.
You can optimize shaders for nvidia and or ati video cards.
Oh before i forget you can also compile to directx shaders.
Ok this should get you started converting shaders to something less readeable... (be sure to keep your original :wink: )