PDA

View Full Version : Shadereditor experiment


oc2k1
10-27-06, 06:20 PM
Hi @ all,

because ther's no shadereditor for Linux, I've wrote my own... on the first pic I've create a Earthsphere with simple dot3 Bumpmapping (I've copy Colormap and Normalmap together in one texture) One the second I've load a OBJ file, that I exported from Blender.

How does it work?:
As first create a node, a script, two or more GLSL shaders (Vertex and fragment) and textures via contextmenu.
Then load a model, create a testobject or script OpenGL commands, to get something visible.
As last run the script.

Things that work:
Load & Editing shaders and scripts with simple highligting
Loading textures
Loading simple OBJ files (via script)
Create testsphere with Tangendvectors (via script)
Draw indexed an nonindexed VBOs via script. It's partly possible to modify these with scripts.

To do:
Implement a working save function
Implement more freatures
Add support for multipass rendering.
Add a stop button for render scripts.
Add Tools for modifiing meshes.

To Hope:
Better QSA performance. (A really fast CPU or a better scriptengine are more realistic)
NVX_instanced_arrays (I need that really. That's no joke, but nobody seems to know how usefull it is...)

oc2k1
10-29-06, 05:37 AM
29 Views? In this forum are to much bugreports.

Please move this topic to General Linux.

TPG
10-29-06, 09:31 AM
I noticed this is QT/KDE app so maybe you should post about it on kde-apps.org? Maybe there you will gain more response :)

oc2k1
10-29-06, 10:08 PM
Now multiple TMUs are working.
I've add new pic. That's a simple dot3 Bumpmapping with an additional unrealistic specular term :captnkill:

pe1chl
10-30-06, 04:19 AM
Maybe you will have more response when sourcecode is attached so people can try it themselves...

oc2k1
10-30-06, 01:15 PM
Some source:
http://cpux.de/opengl.qsa7.tar.bz2

For recompiling use "qmake && make" the sorce depends to QT-3.3.x, QSA-1.1.x and Glew. Don't use QT4.x with QSA-1.2.x that doesn' work.
Start the program via shell "./gl" to see the GLSLcompiler warnings and errors.

Known Bugs:
All objects should have different names, because they are used by scripts. That's not checked jet. Rename objects using F2.
Testobjectscript: Only sphere is working.
OBJ importer: LWO name is wrong. Many OBJ files use multiple Indexstreams but that's incompatible to VBOs.
Don't close the cam.

A Simple Test:

Make a leftklick on the Wold and add a "node".
Add via Nodes contexmenu: Vertexshader, Fragmentshader, Script and a Texture
Texture : Load media/2kEarth_comp.jpg via contextmenu
Klick on the Node to select it, than run plugins/test_object.js from "Scripts" menu and say create.

Script:
shader = gl.Shader(Vertexshader,Fragmentshader);
shader.Uniformi("Tex0",0);

function render(){
Texture.Bind(0);
shader.Bind();

Sphere.UvCoords.Bind();
Sphere.Tangent.Bind(shader.Loc("Tangent"));
Sphere.Vertex.Bind();
Sphere.Normal.Bind();

Sphere.Index.Draw(gl.QUADS);

Sphere.Normal.Unbind();
Sphere.UvCoords.Unbind();
Sphere.Tangent.Unbind();
Sphere.Vertex.Unbind();

shader.Unbind();
}

Vertexshader:
varying vec3 T,B,N;
attribute vec3 Tangent;
varying vec3 col;
void main(void){
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
gl_TexCoord[0] = gl_MultiTexCoord0 * vec4(1,.5,1,1) + vec4(0.35,0,0,0);
N = gl_Normal;
T = Tangent;
B = cross (T,N);
}

Fragmentshader:
uniform sampler2D Tex0;
varying vec3 T,B,N;
vec3 lvec= vec3(0.707,0,0.707);
void main(void){
vec3 nmap = -1 + 2* texture2D(Tex0, vec2(gl_TexCoord[0]));
nmap = normalize(vec3(dot(T,nmap),dot(B,nmap), dot(N,nmap)));
float l = dot(nmap,lvec);
l += 1 * pow(max(dot(reflect (lvec,nmap),vec3(0,0,-1)), 0),4);
gl_FragColor =l * texture2D(Tex0, vec2(gl_TexCoord[0])+vec2(0,.5));
}

Then selelct "Run Script" from Scriptcontextmenu. You should see the dot3 bumpmapped earth.

oc2k1
10-31-06, 11:03 AM
Reliefmapping works now too. I've get some nice textures from here
http://www.bencloward.com/textures_extra.shtml
that I use for rendering the attached pic...

oc2k1
11-14-06, 04:30 PM
A small update: DDS Files, Timebased animation and torus works.

http://cpux.de/opengl.qsa8.tar.bz2

Now I'm thinking what should add as next...
Multiple renderpasses and FBOs,
Other testobjects,
or something for better animation...

oc2k1
11-20-06, 09:13 PM
I've wrote a simple furshader :D

ari.reads
11-20-06, 09:27 PM
why not growing this into a sourceforge project? it looks really neat.

oc2k1
12-02-06, 04:28 PM
I've wrote a new shader for rendering fur. The new one is able to run on any GPU that have Pixelshader 2.0 capabilities. I the reliefshader part is replaced by a single texturelookup. With the 2 other lookups for normalmap an colormap it's need only 3 texturelookups instead many for a smooth reliefshading.
The compiled version needs 71 instruction in vf40 profile and ~81 in ps_2_0

El_Presidente
12-02-06, 04:31 PM
really nice what you do ;)
please dont stop posting your efforts here

oc2k1
12-03-06, 09:03 PM
Changing the hair direction is now possible too. The next version should be able to read the direction from a texture... (hmm it's time to add the stanford bunny)

oc2k1
12-05-06, 07:20 PM
I've add a simple noisemodulation. I think it looks a little bit more realistic (16x AA clears all.

PS: fract(tan(float) * 43758.5453)*2-1 is a usable replacement for noise(float). sin() and cos() instead tan() are working too. That random numbers are good enough for graphics (but not for crypto....)

oc2k1
12-12-06, 08:03 PM
I've wrote a importer. The texcoords/tangents aren't very good so the image has many artefacs. Because the tangents aren't aligned, I couldn't change the hairdirection.

oc2k1
12-31-06, 10:06 AM
Last night I've installed QT4 and QSA1.2 (unfortunately it kills my QT3/QSA1.1 installation, so I can't recompile my old program). In the next days I'll port my code to the new QT version, so it would be able to run at windows too.

The model on the atached picture has round about 110K polygons.

My new roadmap for the next days:
Port to QT4
replace the MDI
Move the scripts from mainmenu to the items contextmenus
write more scripts

oc2k1
01-05-07, 05:48 PM
Porting to QT4 is slow :( . I have some troubles with removing Objects from the tree.
I'm also thinking about using the developers verion of QT that support QScript, which should be a QSA replacement in QT4.3 and it should run with a speed like Spidermonkey :D

oc2k1
01-09-07, 04:53 PM
80% of porting to QT4 is complete. The scriptlaucher is missing in this version, so it's impossible to load a model.

http://cpux.de/Lumina-0.0.1.tar.bz2

It would be nice if somebody could check if that code would compile on windows. Theoretical it should be plattform independent (maybe some changes in lumina.pro are needet)

Also I've registered my project at sf.net, but it will take some time. When it's done, I should have add the missing scriptlauncher.

oc2k1
01-13-07, 08:02 PM
My sf.net project is online:
http://sourceforge.net/project/screenshots.php?group_id=186618&ssid=50796

oc2k1
01-21-07, 02:13 PM
I've loaded a new file up. The next step is to check if shadowalgorithms could run in Lumina.

oc2k1
02-01-07, 06:41 AM
I have uploaded a new version at sf.net http://sourceforge.net/projects/lumina/ (the new gear scripts aren't includet)

http://www.nvnews.net/vbulletin/attachment.php?attachmentid=23827&stc=1&d=1170332874
The same object as smal video http://cpux.de/gears.avi

oc2k1
03-01-07, 03:01 PM
I've uploadet a new relaise. The new version supports load and save and has a new DDS load with volume and cubemap support.
http://sourceforge.net/project/showfiles.php?group_id=186618