Pages: [1]
  Print  
Author Topic: GLSL Shader and Tessellation Support  (Read 4338 times)
Offline (Male) Goombert
Posted on: March 23, 2013, 09:03:52 PM

Developer
Location: Cappuccino, CA
Joined: Jan 2013
Posts: 3151

View Profile


Just a head's up to everyone ENIGMA now supports GLSL shader's and hardware tessellation  (Y)
« Last Edit: March 24, 2013, 12:26:27 AM by Robert B Colton » Logged
I think it was Leonardo da Vinci who once said something along the lines of "If you build the robots, they will make games." or something to that effect.

Offline (Unknown gender) TheExDeus
Reply #1 Posted on: March 24, 2013, 03:32:04 PM

Developer
Joined: Apr 2008
Posts: 1886

View Profile
Check here: http://enigma-dev.org/edc/games.php?game=44
Logged
Offline (Male) Goombert
Reply #2 Posted on: March 24, 2013, 09:09:57 PM

Developer
Location: Cappuccino, CA
Joined: Jan 2013
Posts: 3151

View Profile
That was my stupidity my bad exdeus, that's the old hardware performance tester, I've updated the link on the EDC sorry  :)
Logged
I think it was Leonardo da Vinci who once said something along the lines of "If you build the robots, they will make games." or something to that effect.

Offline (Unknown gender) TheExDeus
Reply #3 Posted on: March 25, 2013, 10:23:52 AM

Developer
Joined: Apr 2008
Posts: 1886

View Profile
Well its better, but there is still no d3d_set_texturing. I can't seem to find such a function in GLd3d.h on git as well. If I remove the two places this function is called, then I can run the example. So a few things:
1) It runs solid 30FPS on my machine (quite old Core2Duo with 8800GTS) and 40 when I disable FPS limit (which is weird, as it should go trough the roof). But still good.
2) The cube geometry can be optimized. I see that it is drawn by d3d_draw_block() and in both wireframe and when flying in the block it can be seen that there are 2 useless triangles going in a diagonal. This would effectively remove 16k unseen triangles.
3) Anisotropic filtering is on by default (when value is 0)? There seem to be no difference between anisotropy 0x and 16x, while a change from 0x to 2x give a massive degradation. Which seems to be that 0x is set to max anisotropic filtering, not none. But in the code everything seems to be fine, so I guess the smallest value is actually 1.
4) For me shaders don't work. They at least don't show up. I checked the return value of shader_load() and it returned 3, which by source seem to be mean that everything is ok (though I would suggest negative values for errors, especially when return type is int). But shader_program_validate() return 0 (false). The error seems to be this:
Quote
0(3) : warning C7555: 'varying' is deprecated, use 'in/out' instead
0(10) : error C7533: global variable gl_LightSource is deprecated after version 120
0(20) : warning C7533: global variable gl_FragColor is deprecated after version 120
So gl_LightSource needs to be changed into something else as that is the only error. The rest are warnings.

Also, you should add a function to add a shader from a string. So it would be possible to include the shaders as scripts and then do shader_load(toonfshader, scr_toon_shader());.

p.s. I will also try porting my WebGL water test to ENIGMA. It does look really cool.

edit: Also add functions to set/get uniforms.
« Last Edit: March 25, 2013, 11:31:06 AM by TheExDeus » Logged
Offline (Male) Goombert
Reply #4 Posted on: March 25, 2013, 01:48:59 PM

Developer
Location: Cappuccino, CA
Joined: Jan 2013
Posts: 3151

View Profile
Ahhh you must have a way more up to date OGL version than I do, I don't understand though I got the shader script from a source that's OGL 3.0 but allot has changed in GLSL, you just need to change the two .glsl scripts included to make it work like a newer shader that output was generated by the GLSL compiler.

But hey don't worry about speed yet, I just rewrote the models to use VBO's in the new graphic's system, that means moving everything graphic's related onto the GPU freeing the CPU up for heavy calculation's such as Aritificial Intelligience so the speed difference will be negligible unless your game is doing allot of calculation's. But as for this example, those cube's are drawn with vertex array pointer's we have a special technique to make it faster, you should be getting at least 100 fps on that, and you will by the time I am finished with the new graphic's system  ;)

As far as anisotropic filtering, you can't just enable it without mipmapping, the point of anisotropic filtering is to increase resolution at oblique angle's, that blurriness that Aniso fixes is caused by mipmapping so you have to use the two hand in hand, set mipmapping to bilinear/trilinear then movew the camera right next to the floor and watch the grid between the textures as you change the aniso level you'll see the lines get much straighter.

Edit: Ohh I forgot to d3d_set_texturing was the function to toggle whether texturing was enabled it's renamed to texture_set_enabled now
« Last Edit: March 25, 2013, 02:00:49 PM by Robert B Colton » Logged
I think it was Leonardo da Vinci who once said something along the lines of "If you build the robots, they will make games." or something to that effect.

Offline (Unknown gender) TheExDeus
Reply #5 Posted on: March 25, 2013, 02:05:22 PM

Developer
Joined: Apr 2008
Posts: 1886

View Profile
I know what VBO and vertex arrays are. I was just saying that the model generated by d3d_draw_block() have incorrect triangles in it, which cannot be seen unless the camera is inside the cube. So that should be fixed, as it would remove a lot of triangles that are uselessly drawn.

I also know what anisotropic filtering is. I was just saying that 16x and 0x didn't have any difference (ergo, it couldn't be turned off). I then read that filtering of 1 is off, not 0 (at is has to be more than 1 and less than max).

I will try writing my own shaders and see how that works.

edit: The new OGL also gets rid of all matrix functions like glTranslate() or glRotate(), so what is the plan there? We could write our own functions or just use a 3rd party solution like VSMathLib. We need to figure this out before we can write some real shaders as most need access to model/view matrix which needs to be passed as a uniform. I know that Three.JS also implements its own matrix functions and all the matrices are appended to the top of all shader code, so they all can be accessed. It also appends things like light positions and so on. Else you will have to pass a lot of vectors as uniforms for all shaders. So the questions are:
1) Do we take an existing library for matrix math? And do we take a specific for GL (like VSMathLib) or a general purpose one that has to be changed for all the specific GL stuff? I wrote a templated matrix lib myself a few weeks ago for work and it seems to work quite fast. It can't do more than addition, subtraction, mult, div, invert and transpose as I wrote it specific for Kalman filter, but it was written as optimized as I could think of while still having templates.
2) Do we append most used stuff to shaders before compiling them? Like all d3d_light positions, model/view matrices etc. This could break some general purpose shaders, but it would make ENIGMA specific shaders to be written a lot simpler. It seems that this is the general way to do this anyway. Even though all GL shaders are GLSL almost none of them can be interchanged between programs.
« Last Edit: March 25, 2013, 02:49:33 PM by TheExDeus » Logged
Offline (Male) Goombert
Reply #6 Posted on: March 25, 2013, 02:08:49 PM

Developer
Location: Cappuccino, CA
Joined: Jan 2013
Posts: 3151

View Profile
Ohhh ok, im sorry, yes I am aware I haven't gotten the cube's just right yet, there going to use a VBO with scaling/transformation so that should really boost the speed up from having to rebuild them on the CPU everytime.

The aniso thing sound's wierd, I think it might be your graphic's card...
http://www.tweakguides.com/images/Anisotropic.gif <- heres a gif animation of anisofiltering.

 (Y)
Logged
I think it was Leonardo da Vinci who once said something along the lines of "If you build the robots, they will make games." or something to that effect.

Offline (Unknown gender) TheExDeus
Reply #7 Posted on: March 25, 2013, 02:53:57 PM

Developer
Joined: Apr 2008
Posts: 1886

View Profile
The link cannot be opened.
And the read my edit.

Also, do you have difference between 0x and 16x yourself? As this seems to be OpenGL spec thing not a hardware thing. The spec says that it has to be more than 1 and less than max. Though I don't know what value should mean its off. I think its 1, as then the anisotropic map would equal mipmap.
Logged
Offline (Male) Goombert
Reply #8 Posted on: March 25, 2013, 03:31:38 PM

Developer
Location: Cappuccino, CA
Joined: Jan 2013
Posts: 3151

View Profile
That's weird the link opens fine for me?

But yes I notice a difference all the way up to 16x, it get's a little bit unnoticeable after 8x though but you can definitely see it. You can look at the function code all it does is query the ARB extension for the maximum supported level, so if you're seeing the option for 16x your hardware definitely supports it.

As far as your other edit, that is discerning I do not think Josh was aware of this, I'll have to confer with him about it.

Edit: And hey sorry I didn't add the function's yet for the uniform location's and stuff, I wanted to set up material's first so I could ensure multitexturing was working by doing a bumpmap shader, and for me to do that I had to rewrite the models/primitives first to use VBO's so I could extend the function API to allow multitextured coordinates. Right now I am trying to outline a shell for a DX9.0 graphics system and boot it into WINE to get it at least drawing a basic triangle, to save work for the next guy's who come along and want a DX graphics port.
« Last Edit: March 25, 2013, 03:33:48 PM by Robert B Colton » Logged
I think it was Leonardo da Vinci who once said something along the lines of "If you build the robots, they will make games." or something to that effect.

Offline (Unknown gender) TheExDeus
Reply #9 Posted on: March 25, 2013, 03:57:07 PM

Developer
Joined: Apr 2008
Posts: 1886

View Profile
Quote
HOTLINKING BLOCKED
This site is linking directly to an image without permission
To view the original image visit www.TweakGuides.com
But do you see difference between 16x and 0x? Like when you have 16x, take a screenshot, then press the button again to go to 0x and make a screenshot again. For me they don't change, as 0 seems to be invalid value. It has to be at least 1.

And I could make uniform functions and the like myself, but the problem is that I can't write a single working shader without the matrices passed to the shader. I will check your code and try to fix it first.
« Last Edit: March 25, 2013, 03:59:05 PM by TheExDeus » Logged
Offline (Male) Goombert
Reply #10 Posted on: March 25, 2013, 04:26:05 PM

Developer
Location: Cappuccino, CA
Joined: Jan 2013
Posts: 3151

View Profile
Does that appear when you open the dropbox link or when trying to enlarge the screenshot? Because the screenshot's are uploaded on the Wiki, I don't know if they coded something into the back end to ensure people are linking images on it or not.

Now is not a good time to work edit anything with the new graphic's system untill I stabilize it more and finish with the models and primitives and basic shapes, I have some work I have not committed yet so please hold off. Will edit here when I get the screenshots for you.

Edit:
16x
http://oi48.tinypic.com/2qbu88x.jpg
8x
http://oi48.tinypic.com/300e8li.jpg
0x
http://oi46.tinypic.com/2s13v5z.jpg

Like I said I clearly notice a difference o_O Even from 0x to 1x...
« Last Edit: March 25, 2013, 05:11:09 PM by Robert B Colton » Logged
I think it was Leonardo da Vinci who once said something along the lines of "If you build the robots, they will make games." or something to that effect.

Offline (Unknown gender) TheExDeus
Reply #11 Posted on: March 25, 2013, 05:40:36 PM

Developer
Joined: Apr 2008
Posts: 1886

View Profile
I don't what dropbox link you are thinking about. I am referring to the http://www.tweakguides.com/ one you posted which clearly cannot be linked to.

And I guess 0x is just undefined and so its implementation specific what it should do. GL specs says this:
Quote
"When the texture's value of TEXTURE_MAX_ANISOTROPY_EXT is equal to 1.0,
     the GL uses an isotropic texture filtering approach as described in
     this section and Section 3.8.6.  However, when the texture's value
     of TEXTURE_MAX_ANISOTROPY_EXT is greater than 1.0, the GL implementation
     should use a texture filtering scheme that accounts for a degree
     of anisotropy up to the smaller of the texture's value of
     TEXTURE_MAX_ANISTROPY_EXT or the implementation-defined value of
     MAX_TEXTURE_MAX_ANISTROPY_EXT.
So value of 1x means no anisotropic filtering, more than that means anisotropic filtering on, and less than 1.0 is undefined. Just something that should be later noted in the wiki when the function is documented. So 0x is not anisotropic filtering off, but 1x is. So to make it work properly in the demo it should reset to 1 and then not add 2, but multiply by 2 every time its increased. But I guess any number is valid.
Logged
Offline (Male) Goombert
Reply #12 Posted on: March 25, 2013, 06:01:17 PM

Developer
Location: Cappuccino, CA
Joined: Jan 2013
Posts: 3151

View Profile
Where in the devil did I link that at I do not remember ever even being on that site?

Anyway ok I see then, but I don't know I notice a difference just going to 1x o_O

But hey, me and polygonz have started the DX 9 graphics port, he want's to know if you'd be interested in helping us with it?
Logged
I think it was Leonardo da Vinci who once said something along the lines of "If you build the robots, they will make games." or something to that effect.

Offline (Unknown gender) TheExDeus
Reply #13 Posted on: March 25, 2013, 06:10:38 PM

Developer
Joined: Apr 2008
Posts: 1886

View Profile
Quote
The aniso thing sound's wierd, I think it might be your graphic's card...
http://www.tweakguides.com/images/Anisotropic.gif <- heres a gif animation of anisofiltering.

 (Y)
I think you just took the first link from google image search.

I guess on your hardware/drivers 1x is the same as 0x. For my hardware/drivers 0x is the same as 16x. So all in all 1x should be the default one (off) and less than 1.0 is undefined.
And I am on Win7, so I can test DX, but I haven't ever programmed it. I only know OpenGL now (as well as GLES, WebGL etc.).
Logged
Offline (Male) Goombert
Reply #14 Posted on: March 25, 2013, 06:28:38 PM

Developer
Location: Cappuccino, CA
Joined: Jan 2013
Posts: 3151

View Profile
Ohhh  :D ya I did take that from google, just because it's animated it does a good job representing it, I've shared that link before, idk y u can't see it tho.

I'll be sure to fix that though, but ya we could use help in developing the port. It don't matter I now have more experience with OGL and I am going to writing parts of it running under WINE, the code don't even have to be as stable as the OGL port it just needs to work, then the Window's people who want to use it can maintain it until we have the proper resources to do so. But we would love it if you would help irregardless!  :)
Logged
I think it was Leonardo da Vinci who once said something along the lines of "If you build the robots, they will make games." or something to that effect.

Pages: [1]
  Print