Jump to content

Using exported GLSL shaders from Blender


MoustafaChamli
 Share

Recommended Posts

I used the GLSL export plugin from Blender in order to use with the game engine as a material, but I can't seem to use it properly.

 

I tried following the information provided by the Leadwerks wiki, but I'm not a programmer, so I don't know how to properly call the .vert and .frag files into Leadwerks. Any indication of what to do would be greatly appreciated!

 

http://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts/Game_Engine/Export_GLSL

Link to comment
Share on other sites

Better convert a general cartoon shader code tutorial to LE3 than try converting specific shader code made for Blender i think.

A very good tutorial :

http://digitalerr0r.wordpress.com/2009/03/22/xna-shader-programming-tutorial-7-toon-shading/

What is great is that it uses a gradient map, so you could really customize your shader with few to lot of tones shading :

b4bc6638ec36448c21bd3773c58567c0.jpg?w=300

 

ab20b036a5d7869a72af000bf707db65.jpg?w=300

 

Another tutorial , seems good also ?

http://rbwhitaker.wikidot.com/toon-shader

 

screenshot1.png

Stop toying and make games

Link to comment
Share on other sites

I'm trying to get an understanding as to how I would go about to do this, but it would seem the documentation for this is either sparse, or outdated.

 

I don't seem to find any shaders.pak file, and there's no indication as to how I'm supposed to use a .vert and .frag file to get a Leadwerks compatible shader.

 

Please note that I'm essentially doing this to assist our programmer. My actual skills are still in the early stages, so not knowing where what goes in which directory/file is a bit problematic.

 

Even just a base "put file in this directory and compile" would be a good start.

 

Thanks.

Link to comment
Share on other sites

LE3 doesn't use the shaders.pak any more. Instead there should be a "Shaders" folder somewhere (most likely on top-level) in your project folder. Each material uses only one shader (and one for shadows), which includes the vertex- AND the fragment-shader in a single .shader - file.

As far as I understand, you have to annotate, where the vertex-shader starts using

@OpenGL2.Vertex

(Just use the minimum OpenGL-version, your shader is compatible to.)

And your fragment-shader should start with

@OpenGL2.Fragment

(Don't know if this is sufficient. Just have a look at one of the example-shaders in that folder.)

 

Then in the editor you create a material and assign the shader.

(Compiling of the shader is done while loading)

Link to comment
Share on other sites

  • 1 month later...

If you open those files inside Leadwerks, it will parse them and correctly categorize the shader parts (vertex, fragment etc)

 

I've tried that, and it wouldn't read them correctly. But now that I'm a bit more familiar with how it works, I'll try again to see the results, and what needs to be corrected.

Link to comment
Share on other sites

I'm getting a better grasp at GLSL overall, and it would seem I'd need to update the code to work with OpenGL4 as it seems Blender mostly uses OpenGL2.1

 

Getting a 3.3 and OGL2.1 fallback would be great overall, to be quite honest. I know Josh is working on a OGL3.3 fallback, so there's that.

Link to comment
Share on other sites

Actually, initial OGL4 support is arriving on Linux, although it might take some time before most distros adopt it (http://www.phoronix.com/scan.php?page=news_item&px=MTcyNzI)

 

That said, I'm getting close to a working solution, having looked around the web for some guides. Right now, I'm mostly stuck with an invalid operand on line 88 of the fragment code.

 

Here's a link to the Fragment:

http://pastebin.com/nDtDFnLx

 

I figure that if I can get this, I should be able to get a working "toon" shader for the game.

 

Just note that there are a lot of commented functions, as I'm still messing around with the code.

Link to comment
Share on other sites

You have to sample the textures before they are usable. So line 88 should read something like :

 

vec4 outcolor = ambientmaterial + df * texture(texture0,ex_texcoords0) + sf * texture(texture2,ex_texcoords0);

 

There is a toon shader ala borderlands style already with the game engine. (Post process).

HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB

Link to comment
Share on other sites

That doesn't quite work, as this makes the model go completely black. I ended up doing this:

vec3 color = ambientmat + df*ex_diffuse + sf*specmat;
fragColor = vec4(color, 1.0) + texture(texture0,ex_texcoords) * 1.0;

 

But that doesn't take into account the "toon" shading. I'll take a look at your code for the post-effects shader, see if I can use bits of it. I'm not looking for something that's like Borderlands (see screenshot above).

Link to comment
Share on other sites

  • 5 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...