material shader: Phong, fake reflect, bloom
-
- Posts: 27
- Joined: Thu Oct 22, 2015 10:42 am
material shader: Phong, fake reflect, bloom
I taken a long time to find good material shaders on the internet, with effects like phong diffuse and specular, fake reflect, ... But I never found anything that was really good. Most of the some things I found were not working well, or had very bad optimization.
So I finally did theses shaders myself and I publish they here.
The archive with my shaders and the .cpp codes to use it (unix makefile, for windows, lets see the tutorial):
google drive
All this code is free, do what you want with it (but maybe the 3d model is'nt).
The result is:
Only basic Phong shader:
Same with diffuse, specular, normal and emission textures:
Support for multiple light (max number fixed by user or automatically detected)
cubemap added to make a fake reflect:
With a bloom (light glow) effect:
These shader have very hight performaces ! I tested it, and it works with around 60 FPS on a small laptop (AMD A1 and graphic chipset)
Principe of Phong shader is explained here:
lighting with glsl
phong model
Rotation matriix:
rotation matrix, transformations
Edit: Render issue for bloom sample size over 256 px FIXED ! (see this post
So I finally did theses shaders myself and I publish they here.
The archive with my shaders and the .cpp codes to use it (unix makefile, for windows, lets see the tutorial):
google drive
All this code is free, do what you want with it (but maybe the 3d model is'nt).
The result is:
Only basic Phong shader:
Same with diffuse, specular, normal and emission textures:
Support for multiple light (max number fixed by user or automatically detected)
cubemap added to make a fake reflect:
With a bloom (light glow) effect:
These shader have very hight performaces ! I tested it, and it works with around 60 FPS on a small laptop (AMD A1 and graphic chipset)
Principe of Phong shader is explained here:
lighting with glsl
phong model
Rotation matriix:
rotation matrix, transformations
Edit: Render issue for bloom sample size over 256 px FIXED ! (see this post
Last edited by jimy-byerley on Sat Jan 21, 2017 7:21 pm, edited 6 times in total.
Re: material shader: Phong, fake reflect, bloom
I think you need to add bump-mapping to make it useful. You should post the images again, too.
-
- Posts: 27
- Joined: Thu Oct 22, 2015 10:42 am
Re: material shader: Phong, fake reflect, bloom
there is already normalmapping, no bumpmapping because it's GPU consumpting, but it can be added easily ...
-
- Posts: 27
- Joined: Thu Oct 22, 2015 10:42 am
Re: material shader: Phong, fake reflect, bloom
I finally added a bumpmap support, let's see the code in cycle/exemple-bumpmap.frag
I used the specular map as entry for bumpmap, and the render look actually as with a normalmap.
I used the specular map as entry for bumpmap, and the render look actually as with a normalmap.
Re: material shader: Phong, fake reflect, bloom
Thanks, nice stuff.
Edit: figured out how to download - stupid adblock blocked the download button in google-drive *sigh*. Somehow adblock plus got really bad in blocking too much stuff lately.
Edit: figured out how to download - stupid adblock blocked the download button in google-drive *sigh*. Somehow adblock plus got really bad in blocking too much stuff lately.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Re: material shader: Phong, fake reflect, bloom
@ jimy-byerley..
Very Cool!
I don't know if you are aware of this but when Irrlicht sees "map_Bump" in your material file i.e. "*.mtl"
it attempts to render the bump map in its own way overriding all your effort with the Normal mapping.
Try disabling the mention of the bump map in the file by commenting it out using "#"
like..
# map_Bump /home/jimy/tron-reboot/repo/textures/light-vehicles/MG_MovieCycle_Body_NORM.tga
map_Kd /home/jimy/tron-reboot/repo/textures/light-vehicles/MG_MovieCycle_Body_DIFF.tga
map_Ke /home/jimy/tron-reboot/repo/textures/light-vehicles/MG_MovieCycle_Body_EMSS.tga
map_Ks /home/jimy/tron-reboot/repo/textures/light-vehicles/MG_MovieCycle_Body_SPEC.tga
I Haven't tested your code yet but I'm sure there will be an improvement.
I like your "Bloom" effect and will surely try it out.
Good job!
Very Cool!
I don't know if you are aware of this but when Irrlicht sees "map_Bump" in your material file i.e. "*.mtl"
it attempts to render the bump map in its own way overriding all your effort with the Normal mapping.
Try disabling the mention of the bump map in the file by commenting it out using "#"
like..
# map_Bump /home/jimy/tron-reboot/repo/textures/light-vehicles/MG_MovieCycle_Body_NORM.tga
map_Kd /home/jimy/tron-reboot/repo/textures/light-vehicles/MG_MovieCycle_Body_DIFF.tga
map_Ke /home/jimy/tron-reboot/repo/textures/light-vehicles/MG_MovieCycle_Body_EMSS.tga
map_Ks /home/jimy/tron-reboot/repo/textures/light-vehicles/MG_MovieCycle_Body_SPEC.tga
I Haven't tested your code yet but I'm sure there will be an improvement.
I like your "Bloom" effect and will surely try it out.
Good job!
Re: material shader: Phong, fake reflect, bloom
Oh! The way you handled the "Skymap" is pure genius!
I think that this might be the solution I'm looking for!
I think that this might be the solution I'm looking for!
-
- Posts: 27
- Joined: Thu Oct 22, 2015 10:42 am
Re: material shader: Phong, fake reflect, bloom
@Vectortek
Thanks! I added some additionnal comments in the skymap calculation for the reflect, it was a bit poor.
I removed texture parameters from light-cycle.mtl but it doesn't change anything, the normalmap were active yet.
The current problem is to use more than the fourths textures imposed by irrlicht. I think the developpers would change it ...
Thanks! I added some additionnal comments in the skymap calculation for the reflect, it was a bit poor.
I removed texture parameters from light-cycle.mtl but it doesn't change anything, the normalmap were active yet.
The current problem is to use more than the fourths textures imposed by irrlicht. I think the developpers would change it ...
Re: material shader: Phong, fake reflect, bloom
If an engine recompile with an altered "IrrCompileConfig.h" don't work then it is probably a hardware thing..
Last edited by Vectrotek on Wed Oct 28, 2015 4:20 pm, edited 2 times in total.
Re: material shader: Phong, fake reflect, bloom
Yeah, 4 texture limit is annoying. Reason that number is hardcoded is probably to avoid any dynamic memory allocation inside materials. Reason it's just 4 instead of 8 is maybe that having more textures will cost some speed even when those textures are not used and most projects don't need more. And a tiny bit more memory (unlikely to matter). Will have to profile that, maybe increasing to 8 makes no noticable difference. Otherwise maybe there is some way to make this value a template parameter (probably ugly, would have to be passed through a lot of classes). I'll put it on my todo to check this - people run into that already a few times.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Re: material shader: Phong, fake reflect, bloom
That, and a lot of recent Geforces still only supporting 4.
http://feedback.wildfiregames.com/repor ... RE_UNITS#4
http://feedback.wildfiregames.com/repor ... RE_UNITS#4
Re: material shader: Phong, fake reflect, bloom
Wait - my card only supports 4??? Damn, it...
Well, but I suppose we still should allow more. Maybe add some warning in comments that it will not work on many systems then.
Well, but I suppose we still should allow more. Maybe add some warning in comments that it will not work on many systems then.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Re: material shader: Phong, fake reflect, bloom
Mmm.. When I run 3D Labs's "Shadergen" it informs me that my card only supports 4 textures, but when I do an engine
recompile I definitely have access to EIGHT textures?
recompile I definitely have access to EIGHT textures?
-
- Posts: 27
- Joined: Thu Oct 22, 2015 10:42 am
Re: material shader: Phong, fake reflect, bloom
I think too there should be only warnings in case of using more than 4 but not limit as short as that.
When hendu said many geforces support only 4, it means that in blender we can have only 4 textures for an object ? or blender is using an other render pipeline ?
When hendu said many geforces support only 4, it means that in blender we can have only 4 textures for an object ? or blender is using an other render pipeline ?
Re: material shader: Phong, fake reflect, bloom
All recent geforces support 16 to 32 textures, and post-fermi support as many as you like with bindless textures
Our version of irrlicht with just minor modifications supports 8 textures in all shaders and materials.
Irrlicht should be able to support 16 textures in shaders, but when I tried I couldn't get it to work straight off the bat.
The "Shadergen" queries the wrong (obsolete) OpenGL implementation constant and that is why you're getting the number 4.
Our version of irrlicht with just minor modifications supports 8 textures in all shaders and materials.
Irrlicht should be able to support 16 textures in shaders, but when I tried I couldn't get it to work straight off the bat.
The "Shadergen" queries the wrong (obsolete) OpenGL implementation constant and that is why you're getting the number 4.