GLSL Shaders

Jordach
Member
Posts: 4534
Joined: Mon Oct 03, 2011 17:58
GitHub: Jordach
IRC: Jordach
In-game: Jordach
Location: Blender Scene

by Jordach » Post

hoodedice wrote: intel GMA
You will not be able to run shaders whatsoever.

Sorry bud.

User avatar
VanessaE
Moderator
Posts: 4655
Joined: Sun Apr 01, 2012 12:38
GitHub: VanessaE
IRC: VanessaE
In-game: VanessaE
Location: Western NC
Contact:

by VanessaE » Post

the shaders only work on systems that are running opengl (though for me the water shader does not work at all).
You might like some of my stuff: Plantlife ~ More Trees ~ Home Decor ~ Pipeworks ~ HDX Textures (64-512px)

tinoesroho
Member
Posts: 570
Joined: Fri Feb 17, 2012 21:55
Location: Canada

by tinoesroho » Post

... DirectX is on, innit?
We are what we create.

I tinker and occasionally make (lousy) mods. Currently building an MMO subgame and updating mods. Pirate Party of Canada member. Sporadic author. 21 years old.

My github:
https://github.com/tinoesroho/

User avatar
Inocudom
Member
Posts: 3121
Joined: Sat Sep 29, 2012 01:14
IRC: Inocudom
In-game: Inocudom

by Inocudom » Post

tinoesroho wrote:... DirectX is on, innit?
There aren't any Direct X shaders currently.

User avatar
RealBadAngel
Member
Posts: 557
Joined: Wed Jul 18, 2012 16:30

by RealBadAngel » Post

Inocudom wrote:
tinoesroho wrote:... DirectX is on, innit?
There aren't any Direct X shaders currently.
First lets have OpenGL up n runnin.

Vanessa's issue with water is definitely caused by Irrlicht 1.8
Current tree (i made many updates yesterday) is working under 1.7.3

sfan5
Moderator
Posts: 4095
Joined: Wed Aug 24, 2011 09:44
GitHub: sfan5
IRC: sfan5
Location: Germany

by sfan5 » Post

hoodedice wrote:For me, I get it all red. (Using sfan's build posted above.) Windows x86 XP with intel GMA
Don't use DirectX
Mods: Mesecons | WorldEdit | Nuke & Minetest builds for Windows (32-bit & 64-bit)

User avatar
PilzAdam
Member
Posts: 4026
Joined: Fri Jul 20, 2012 16:19
GitHub: PilzAdam
IRC: PilzAdam
Location: Germany

by PilzAdam » Post

RealBadAngel wrote:Vanessa's issue with water is definitely caused by Irrlicht 1.8
Current tree (i made many updates yesterday) is working under 1.7.3
Actually thats wrong, I use Irrlicht 1.7.3 and all water is grey. It also says something about "reflection.png missing" (or similiar).

User avatar
Inocudom
Member
Posts: 3121
Joined: Sat Sep 29, 2012 01:14
IRC: Inocudom
In-game: Inocudom

by Inocudom » Post

RealBadAngel wrote:
Inocudom wrote:
tinoesroho wrote:... DirectX is on, innit?
There aren't any Direct X shaders currently.
First lets have OpenGL up n runnin.

Vanessa's issue with water is definitely caused by Irrlicht 1.8
Current tree (i made many updates yesterday) is working under 1.7.3
I heard that there are ways that OpenGL shaders can be converted to Direct X shaders. As you said, of course, the OpenGL shaders do have to be stable first.

One issue is that Direct X 9 is the highest version Irrlicht can use for the time being.

User avatar
RealBadAngel
Member
Posts: 557
Joined: Wed Jul 18, 2012 16:30

by RealBadAngel » Post

PilzAdam wrote:
RealBadAngel wrote:Vanessa's issue with water is definitely caused by Irrlicht 1.8
Current tree (i made many updates yesterday) is working under 1.7.3
Actually thats wrong, I use Irrlicht 1.7.3 and all water is grey. It also says something about "reflection.png missing" (or similiar).
Please do build it again and see first post about settings.

User avatar
PilzAdam
Member
Posts: 4026
Joined: Fri Jul 20, 2012 16:19
GitHub: PilzAdam
IRC: PilzAdam
Location: Germany

by PilzAdam » Post

RealBadAngel wrote:
PilzAdam wrote:
RealBadAngel wrote:Vanessa's issue with water is definitely caused by Irrlicht 1.8
Current tree (i made many updates yesterday) is working under 1.7.3
Actually thats wrong, I use Irrlicht 1.7.3 and all water is grey. It also says something about "reflection.png missing" (or similiar).
Please do build it again and see first post about settings.
I guess you mean pull and rebuild?

Code: Select all

/home/adam/Minetest/minetest_rba_shaders/src/mapblock_mesh.cpp:1204:95: error: no matching function for call to 'ITextureSource::getTexture(<unresolved overloaded function type>)'
Fix:

Code: Select all

diff --git a/src/mapblock_mesh.cpp b/src/mapblock_mesh.cpp
index f56a986..b907b64 100644
--- a/src/mapblock_mesh.cpp
+++ b/src/mapblock_mesh.cpp
@@ -1201,7 +1201,7 @@ MapBlockMesh::MapBlockMesh(MeshMakeData *data):
                if (enable_shaders) {
                        ITextureSource *tsrc = data->m_gamedef->tsrc();
                        material.setTexture(2, tsrc->getTexture("disable_img.png"));
-                       material.setTexture(3, tsrc->getTexture(getTexturePath("water_surface_normalmap.png").c_str));
+                       material.setTexture(3, tsrc->getTexture(getTexturePath("water_surface_normalmap.png").c_str()));
                        if (enable_bumpmapping) {
                                std::string fname_base = tsrc->getTextureName(p.tile.texture_id);
                                std::string normal_ext = "_normal.png";
EDIT: That fix doesnt work, here is the correct one:

Code: Select all

diff --git a/src/mapblock_mesh.cpp b/src/mapblock_mesh.cpp
index f56a986..b907b64 100644
--- a/src/mapblock_mesh.cpp
+++ b/src/mapblock_mesh.cpp
@@ -1201,7 +1201,7 @@ MapBlockMesh::MapBlockMesh(MeshMakeData *data):
                if (enable_shaders) {
                        ITextureSource *tsrc = data->m_gamedef->tsrc();
                        material.setTexture(2, tsrc->getTexture("disable_img.png"));
-                       material.setTexture(3, tsrc->getTexture(getTexturePath("water_surface_normalmap.png").c_str));
+                       material.setTexture(3, tsrc->getTexture("water_surface_normalmap.png"));
                        if (enable_bumpmapping) {
                                std::string fname_base = tsrc->getTextureName(p.tile.texture_id);
                                std::string normal_ext = "_normal.png";
Last edited by PilzAdam on Sun Nov 03, 2013 13:43, edited 1 time in total.

User avatar
PilzAdam
Member
Posts: 4026
Joined: Fri Jul 20, 2012 16:19
GitHub: PilzAdam
IRC: PilzAdam
Location: Germany

by PilzAdam » Post

Here are some screenshots:
Default Texture Pack:
Image
Haven Texture Pack:
Image
Last edited by PilzAdam on Sun Nov 03, 2013 13:48, edited 1 time in total.

User avatar
PilzAdam
Member
Posts: 4026
Joined: Fri Jul 20, 2012 16:19
GitHub: PilzAdam
IRC: PilzAdam
Location: Germany

by PilzAdam » Post

Here is another patch that adds Jeijas waves to it (it contains the previous fixes so it should work if you apply it to 1c03fb5efb5095f177c27497200db27694baeea1):

Code: Select all

diff --git a/client/shaders/liquids_shader/opengl_vertex.glsl b/client/shaders/liquids_shader/opengl_vertex.glsl
index 08c98cf..9ad16c8 100644
--- a/client/shaders/liquids_shader/opengl_vertex.glsl
+++ b/client/shaders/liquids_shader/opengl_vertex.glsl
@@ -4,6 +4,7 @@ uniform mat4 mInvWorld;
 uniform mat4 mTransWorld;
 uniform float dayNightRatio;
 uniform vec3 eyePosition;
+uniform float time;^M
 
 varying vec3 vPosition;
 varying vec3 viewVec;
@@ -14,9 +15,24 @@ varying vec3 viewPos;
 varying vec3 cameraPos;
 varying vec2 uv;
 
+float rand(vec2 co)^M
+{^M
+       return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);^M
+}^M
+^M
 void main(void)
 {
-       gl_Position = mWorldViewProj * gl_Vertex;
+       int wavelength = 20;^M
+       float waveheight = 1.7;^M
+       int wavespeed = 100;^M
+       int height_randomness = 1;^M
+       ^M
+       vec4 pos2 = gl_Vertex;^M
+       pos2.y -= 3.0;^M
+       pos2.y -= sin (pos2.z/wavelength + time * wavespeed * wavelength) * waveheight^M
+               + sin ((pos2.z/wavelength + time * wavespeed * wavelength)/7) * waveheight * height_randomness;^M
+       ^M
+       gl_Position = mWorldViewProj * pos2;^M
 
        vPosition = (mWorldViewProj * gl_Vertex).xyz;
        vec3 pos = vec3(gl_Vertex);
diff --git a/src/game.cpp b/src/game.cpp
index 4c5e285..580ba8d 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -839,6 +839,8 @@ public:
                services->setPixelShaderConstant("useNormalmap" , (irr::s32*)&layer2, 1);
                services->setPixelShaderConstant("normalSampler" , (irr::s32*)&layer3, 1);
 #endif
+               float timeofday = m_client->getEnv().getTimeOfDayF();
+               services->setPixelShaderConstant("time", &timeofday, 1);
        }
 };
 
diff --git a/src/mapblock_mesh.cpp b/src/mapblock_mesh.cpp
index f56a986..fa6cf6a 100644
--- a/src/mapblock_mesh.cpp
+++ b/src/mapblock_mesh.cpp
@@ -1201,7 +1201,7 @@ MapBlockMesh::MapBlockMesh(MeshMakeData *data):
                if (enable_shaders) {
                        ITextureSource *tsrc = data->m_gamedef->tsrc();
                        material.setTexture(2, tsrc->getTexture("disable_img.png"));
-                       material.setTexture(3, tsrc->getTexture(getTexturePath("water_surface_normalmap.png").c_str));
+                       material.setTexture(3, tsrc->getTexture("water_surface_normalmap.png"));
                        if (enable_bumpmapping) {
                                std::string fname_base = tsrc->getTextureName(p.tile.texture_id);
                                std::string normal_ext = "_normal.png";

User avatar
Inocudom
Member
Posts: 3121
Joined: Sat Sep 29, 2012 01:14
IRC: Inocudom
In-game: Inocudom

by Inocudom » Post

PilzAdam wrote:Here is another patch that adds Jeijas waves to it (it contains the previous fixes so it should work if you apply it to 1c03fb5efb5095f177c27497200db27694baeea1):

Code: Select all

diff --git a/client/shaders/liquids_shader/opengl_vertex.glsl b/client/shaders/liquids_shader/opengl_vertex.glsl
index 08c98cf..9ad16c8 100644
--- a/client/shaders/liquids_shader/opengl_vertex.glsl
+++ b/client/shaders/liquids_shader/opengl_vertex.glsl
@@ -4,6 +4,7 @@ uniform mat4 mInvWorld;
 uniform mat4 mTransWorld;
 uniform float dayNightRatio;
 uniform vec3 eyePosition;
+uniform float time;^M
 
 varying vec3 vPosition;
 varying vec3 viewVec;
@@ -14,9 +15,24 @@ varying vec3 viewPos;
 varying vec3 cameraPos;
 varying vec2 uv;
 
+float rand(vec2 co)^M
+{^M
+       return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);^M
+}^M
+^M
 void main(void)
 {
-       gl_Position = mWorldViewProj * gl_Vertex;
+       int wavelength = 20;^M
+       float waveheight = 1.7;^M
+       int wavespeed = 100;^M
+       int height_randomness = 1;^M
+       ^M
+       vec4 pos2 = gl_Vertex;^M
+       pos2.y -= 3.0;^M
+       pos2.y -= sin (pos2.z/wavelength + time * wavespeed * wavelength) * waveheight^M
+               + sin ((pos2.z/wavelength + time * wavespeed * wavelength)/7) * waveheight * height_randomness;^M
+       ^M
+       gl_Position = mWorldViewProj * pos2;^M
 
        vPosition = (mWorldViewProj * gl_Vertex).xyz;
        vec3 pos = vec3(gl_Vertex);
diff --git a/src/game.cpp b/src/game.cpp
index 4c5e285..580ba8d 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -839,6 +839,8 @@ public:
                services->setPixelShaderConstant("useNormalmap" , (irr::s32*)&layer2, 1);
                services->setPixelShaderConstant("normalSampler" , (irr::s32*)&layer3, 1);
 #endif
+               float timeofday = m_client->getEnv().getTimeOfDayF();
+               services->setPixelShaderConstant("time", &timeofday, 1);
        }
 };
 
diff --git a/src/mapblock_mesh.cpp b/src/mapblock_mesh.cpp
index f56a986..fa6cf6a 100644
--- a/src/mapblock_mesh.cpp
+++ b/src/mapblock_mesh.cpp
@@ -1201,7 +1201,7 @@ MapBlockMesh::MapBlockMesh(MeshMakeData *data):
                if (enable_shaders) {
                        ITextureSource *tsrc = data->m_gamedef->tsrc();
                        material.setTexture(2, tsrc->getTexture("disable_img.png"));
-                       material.setTexture(3, tsrc->getTexture(getTexturePath("water_surface_normalmap.png").c_str));
+                       material.setTexture(3, tsrc->getTexture("water_surface_normalmap.png"));
                        if (enable_bumpmapping) {
                                std::string fname_base = tsrc->getTextureName(p.tile.texture_id);
                                std::string normal_ext = "_normal.png";
It pleases me greatly to see you supporting RealBadAngel's shaders, PilzAdam.

The new water shaders are very impressive, but may still be a little glitchy. Water that is in caves still has grayish coloration from time to time. Another thing I noticed is that lava also gets the water shaders, but ends up looking like water in the process.

The parallax mapping is working now, but the effect doesn't appear to be 3D from some viewing angles. Xonotic, Red Eclipse, and Sauerbraten have parallax mapping in them, so they can provide inspiration if it is needed. Calinou is involved in the communities of those games, so he might be of assistance.

I can tell that good progress is being made with the shaders. I know that the end result will be impressive.
Last edited by Inocudom on Sun Nov 03, 2013 16:49, edited 1 time in total.

User avatar
RealBadAngel
Member
Posts: 557
Joined: Wed Jul 18, 2012 16:30

by RealBadAngel » Post

I have updated first post with all the aviable config settings.

Issue with parallax not working perfectly is that we dont have properly calculated tangent.
I do have the code to calculate it in the engine, but theres no way to pass it to shaders.
Theres no way in irrlicht to use GLSL shaders attribute or to pass uniform sampler buffers.

User avatar
Inocudom
Member
Posts: 3121
Joined: Sat Sep 29, 2012 01:14
IRC: Inocudom
In-game: Inocudom

by Inocudom » Post

RealBadAngel wrote:I have updated first post with all the aviable config settings.

Issue with parallax not working perfectly is that we dont have properly calculated tangent.
I do have the code to calculate it in the engine, but theres no way to pass it to shaders.
Theres no way in irrlicht to use GLSL shaders attribute or to pass uniform sampler buffers.
That does not sound good. Why would Irrlicht not have such a feature?

User avatar
tkerwel
Member
Posts: 213
Joined: Fri Jan 13, 2012 07:35

by tkerwel » Post

i use minetest-0.4.7-54c8bdb-shaders-win32 and always get the error:


10:46:56: ERROR[main]: generate_shader(): failed to generate "liquids_shader", addHighLevelShaderMaterial failed.

can still play but the water looks strange. its like looking thru dark glass dosent matter if i play this on my laptop or my highend gaming pc.

settings are:

enable_water_wave = true
water_wave_height = 0.4
water_wave_speed = 50
water_wave_length = 20
enable_bumpmapping = true
parallax_mapping_mode = 2
parallax_mapping_scale = 0.08
parallax_mapping_bias = 0.04
++++ Kung walang tiyaga, walang nilaga. ++++

User avatar
RealBadAngel
Member
Posts: 557
Joined: Wed Jul 18, 2012 16:30

by RealBadAngel » Post

tkerwel wrote:i use minetest-0.4.7-54c8bdb-shaders-win32 and always get the error:


10:46:56: ERROR[main]: generate_shader(): failed to generate "liquids_shader", addHighLevelShaderMaterial failed.

can still play but the water looks strange. its like looking thru dark glass dosent matter if i play this on my laptop or my highend gaming pc.

settings are:

enable_water_wave = true
water_wave_height = 0.4
water_wave_speed = 50
water_wave_length = 20
enable_bumpmapping = true
parallax_mapping_mode = 2
parallax_mapping_scale = 0.08
parallax_mapping_bias = 0.04
Please add a few more lines around that error message, i need more details.

sfan5
Moderator
Posts: 4095
Joined: Wed Aug 24, 2011 09:44
GitHub: sfan5
IRC: sfan5
Location: Germany

by sfan5 » Post

It would be nice if you could fix these errors:
http://pastebin.com/WE4H6FGi
Mods: Mesecons | WorldEdit | Nuke & Minetest builds for Windows (32-bit & 64-bit)

User avatar
RealBadAngel
Member
Posts: 557
Joined: Wed Jul 18, 2012 16:30

by RealBadAngel » Post

sfan5 wrote:It would be nice if you could fix these errors:
http://pastebin.com/WE4H6FGi
Those are not errors but your OpenGL, I guess youre using open drivers.
Im not sure if i can make all the code run with it but i will try.
Whats your OpenGL version?
Last edited by RealBadAngel on Mon Nov 04, 2013 18:01, edited 1 time in total.

sfan5
Moderator
Posts: 4095
Joined: Wed Aug 24, 2011 09:44
GitHub: sfan5
IRC: sfan5
Location: Germany

by sfan5 » Post

RealBadAngel wrote:Those are not errors but your OpenGL
I'm pretty sure that are errors..
RealBadAngel wrote:Whats your OpenGL version?

Code: Select all

$ glxinfo | grep version
server glx version string: 1.4
client glx version string: 1.4
GLX version: 1.4
OpenGL core profile version string: 3.1 (Core Profile) Mesa 9.2.1
OpenGL core profile shading language version string: 1.40
OpenGL version string: 3.0 Mesa 9.2.1
OpenGL shading language version string: 1.30
Mods: Mesecons | WorldEdit | Nuke & Minetest builds for Windows (32-bit & 64-bit)

User avatar
hoodedice
Member
Posts: 1374
Joined: Sat Jul 06, 2013 06:33
GitHub: hoodedice
IRC: hoodedice
In-game: hoodedice
Location: world
Contact:

by hoodedice » Post

Jordach wrote:
hoodedice wrote: intel GMA
You will not be able to run shaders whatsoever.

Sorry bud.
They run in FlightGear, but they cause tons of lag. I was just gonna check out what they looked like.
sfan5 wrote:
hoodedice wrote:For me, I get it all red. (Using sfan's build posted above.) Windows x86 XP with intel GMA
Don't use DirectX
I'm not using it (I guess). Well, minetest reports that my OpenGL version is 2.0 so maybe I'm running OpenGL. Again, I don't think sfan made a build with DirectX.
7:42 PM - Bauglio: I think if you go to staples you could steal firmware from a fax machine that would run better than win10 does on any platform
7:42 PM - Bauglio: so fudge the stable build
7:43 PM - Bauglio: get the staple build

User avatar
Inocudom
Member
Posts: 3121
Joined: Sat Sep 29, 2012 01:14
IRC: Inocudom
In-game: Inocudom

by Inocudom » Post

With PilzAdam's latest build of RealBadAngel's shaders branch, I was able to record a video of the shaders. The video is of somewhat low quality, but the shaders are visible.
Attachments

[The extension avi has been deactivated and can no longer be displayed.]


u34

by u34 » Post

are there any shaders planed for AMD video cards?

Code: Select all

Irrlicht Engine version 1.8.0
Microsoft Windows 7 Home Premium Edition Service Pack 1 (Build 7601)
Using renderer: OpenGL 4.2.11631
AMD Radeon HD 6500M/5600/5700 Series: ATI Technologies Inc.
OpenGL driver version is 1.2 or better.
GLSL version: 4.2

User avatar
VanessaE
Moderator
Posts: 4655
Joined: Sun Apr 01, 2012 12:38
GitHub: VanessaE
IRC: VanessaE
In-game: VanessaE
Location: Western NC
Contact:

by VanessaE » Post

In theory they should work with any video card, but they don't work for me. I assumed it was an incompatibility with my OpenGL version (4.3.12614), as RBA develops on an older OpenGL (2.2 or something) and AMD video.
You might like some of my stuff: Plantlife ~ More Trees ~ Home Decor ~ Pipeworks ~ HDX Textures (64-512px)

User avatar
tkerwel
Member
Posts: 213
Joined: Fri Jan 13, 2012 07:35

by tkerwel » Post

RealBadAngel wrote:
tkerwel wrote:i use minetest-0.4.7-54c8bdb-shaders-win32 and always get the error:


10:46:56: ERROR[main]: generate_shader(): failed to generate "liquids_shader", addHighLevelShaderMaterial failed.

can still play but the water looks strange. its like looking thru dark glass dosent matter if i play this on my laptop or my highend gaming pc.

settings are:

enable_water_wave = true
water_wave_height = 0.4
water_wave_speed = 50
water_wave_length = 20
enable_bumpmapping = true
parallax_mapping_mode = 2
parallax_mapping_scale = 0.08
parallax_mapping_bias = 0.04
Please add a few more lines around that error message, i need more details.
okay after i read your message i was looking whats the difference between the two computers. after a update for the newest OpenGL on the big one, i dont get this error anymore. so looks like this is something with the OpenGL drivers which cause the problem.
++++ Kung walang tiyaga, walang nilaga. ++++

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests