Page 1 of 2

Material & Shaders editor

Posted: Tue May 22, 2012 10:05 am
by Kelebrindae
Hi!

Here's a little tool that lets you edit ".material" and ".fx" files and see the results in (almost) real-time.
The preview is obtained by killing and re-launching a second exe as a child window every time a change is made in the editor.
Image

Download it here: http://keleb.free.fr/codecorner/downloa ... Editor.zip
It contains the sources for the editor (materialEditor.pb) and the preview (materialPreview.pb), the Visual Editor file, icons, etc..
Quite a lot of things are included in the editor's exe via "includeBinary": the preview's exe, a default material with shader and textures, the teapot mesh, some PNGs... All these files are stored in the "included" folder.

For those who don't bother the code and simply want to try it, here's the compiled version (32bits Win):
http://keleb.free.fr/codecorner/downloa ... torExe.zip
Engine3D.dll is included: unzip it in some folder, and it should work (hopefully :P ).

How to use it:
- cursor keys + pageUp pageDown to move the camera in the preview;
- F5 to refresh the preview.
- The horizontal menu allows to save/load a project. The save files include the meshes, the textures, the shaders files, and the material file; all these are "packed" in the save file, and "unpacked" when loaded.
- The menu also allows to "export" a project: the material and all its dependancies are then unpacked to the target directory along with a short PB source that demonstrates how to use them.
- There are tooltips on every button; please read them if you're confused.

To import an existing material, no automation: you have to use the "import" buttons on each page of the panel gadget.
Example, with the "SphereMap" material in purebasic/examples/3d/data/scripts:
- On the "material" tab, click on the "import" button (first one, with a yellow folder on it) and choose "spheremap.material" => the file's content is loaded into the editor;
- On the "Shader" tab, delete all (this material doesn't use shaders. If it did, they would be referenced after the keyword "source" in the material);
- On the "Textures - meshes" tab, delete all the textures and import the two files used in the "textures units" of the material: "rustySteel.jpg" and "spheremap.png" (they are in purebasic/examples/3d/data/textures);
- Press "F5" to refresh the preview => it should work.

Limitations:
- The editor only manages a single material per ".Material" file, and a single ".Material" file per project. So one project = one material (but there's no limit on the number of meshes, shaders or textures files).
- When you enable the "ground" display, it also activates the shadows in "Modulative" mode, which may be annoying sometimes; I'll add a combo-box to select the type of shading later...

Well, that's it. There are still some bugs and unpractical things, but it is already quite usable and it speeds up the writing, tuning and conversion of materials for PB. I hope it will be useful! :wink:

Bonus: Two material projects to load in the editor
http://keleb.free.fr/codecorner/downloa ... iLight.pbm
http://keleb.free.fr/codecorner/downloa ... olcano.pbm

[EDIT] Updated to PB v5.00b2

Re: Material & Shaders editor

Posted: Tue May 22, 2012 10:55 am
by [blendman]
Hi Kelebrindae

It's a great tool, it would be interesting to have this sort of tool include with the official release of Purebasic, to Help the users to create their material and Shader ;).

Thank you to share this application (and code).

Re: Material & Shaders editor

Posted: Thu May 24, 2012 2:31 pm
by Kelebrindae
Thanks!

Here's two more materials:
http://keleb.free.fr/codecorner/downloa ... xtured.pbm
http://keleb.free.fr/codecorner/downloa ... xtured.pbm

I've found them here: http://www.ogre3d.org/tikiwiki/Shaders& ... e=Cookbook and ported them from Cg to hlsl with nVidia's Cg toolkit.
Once ported to hlsl, there's still 2-3 things to fix to get them to work with PB, but my little editor makes things a lot faster and easier, I must say... :wink:

Re: Material & Shaders editor

Posted: Fri May 25, 2012 4:28 pm
by Kelebrindae
Two more :mrgreen: :
http://keleb.free.fr/codecorner/downloa ... /glass.pbm
http://keleb.free.fr/codecorner/downloa ... refrac.pbm

- The first one is a transparent material with a cubeMap reflection.
- The second one http://www.purebasic.fr/english/viewtop ... 16&t=41426. Not really transparent: what you see through is actually a cubeMap, so this material is only suited for static scenes.

Re: Material & Shaders editor

Posted: Sun May 27, 2012 11:01 pm
by Kelebrindae
New version:
I fixed a couple of bugs and added the ability to switch from DirectX to OpenGL or vice versa; simply use the menu "Subsystem".
=> The editor can now manage GLSL shaders.
Download here: [url] http://keleb.free.fr/codecorner/downloa ... torExe.zip [/ url]

Re: Material & Shaders editor

Posted: Mon Jun 04, 2012 5:31 pm
by [blendman]
Great !!
Thank you very much !

Re: Material & Shaders editor

Posted: Tue Sep 18, 2012 9:09 am
by Kelebrindae

Re: Material & Shaders editor

Posted: Tue Sep 18, 2012 1:00 pm
by marc_256
Hi Kelebrindae,

Nice, but your website is blocked by my browser/anti spy detector.

and seems to be dangerous ??

Marc,

Re: Material & Shaders editor

Posted: Tue Sep 18, 2012 1:26 pm
by Kelebrindae
Wha... ?! :shock:
Well, that's new...

Knowing that PB's exe are prone to trigger false positives in some antivirus, I suppose Google has scanned the site content and assumed it was dangerous. Not cool. :x

I assure you that there's no virus or malware here: you can safely ignore the warning. Promised!

(On a side note, does anyone know how to tell Google they're wrong?)

Re: Material & Shaders editor

Posted: Tue Sep 18, 2012 1:47 pm
by Comtois
http://safebrowsing.clients.google.com/ ... torExe.zip
You ask how report that your site is safe? Apparently you can request a review of your site
https://accounts.google.com/ServiceLogi ... ers/tools/

Re: Material & Shaders editor

Posted: Tue Sep 18, 2012 1:58 pm
by marc_256
I assure you that there's no virus or malware here: you can safely ignore the warning. Promised!
There we go ...


Marc,

Re: Material & Shaders editor

Posted: Tue Sep 18, 2012 2:59 pm
by Kelebrindae
@marc_256:
Thanks for your confidence! (and inform me if your computer blows up... :mrgreen: )

@Comtois:
Ok, thanks for the link. I'll try it ASAP and fix whatever can be.

[EDIT] I've found some reference to a Bitcoin script in some of my pages (an old experiment I forgot to delete), and that was what alarmed the Google Bots => I've fixed the problem and asked Google for a new scan.
This morning, my account says there's no malware on my site, so I guess all is well now...

Re: Material & Shaders editor

Posted: Sun Sep 23, 2012 7:54 pm
by Polo
Haven't checked it out, is this working on OSX?

Re: Material & Shaders editor

Posted: Mon Sep 24, 2012 9:04 am
by Kelebrindae
Probably not, sorry.

There's an API call in the "setLinePosInEditor" procedure, but it's not a critical feature, so you could just comment it. Also, the default setting for the subsystem is "DirectX", but it's possible to switch to OpenGL in the menu.
=> with these slight fixes, it should be possible to compile the sources for OSX.

Re: Material & Shaders editor

Posted: Mon Sep 24, 2012 12:41 pm
by Fred
You could use ScintillaGadget() for your editor, it is supported on 3 OS and brings a lot more options