Page 1 of 2
Upcoming new shaders

Posted:
Mon Jul 29, 2013 16:54
by RealBadAngel
Here are the results of my work with shaders so far, please do compare screenshots.
Visible wall texture is 512px, bilinear filtering and mipmapping is on.
Without shaders:

Iterative Parallax Mapping:

Iterative Parallax Mapping + Normal Bumpmapping:


Posted:
Mon Jul 29, 2013 16:57
by PilzAdam
Fake.

Posted:
Mon Jul 29, 2013 17:08
by Inocudom
This is impressive work, RealBadAngel. I know how pretty this effect is, because I saw it in action in Xonotic. This alone adds a new level of detail and beauty to Minetest.
Would you and VanessaE be willing to try this with her HDX texture pack (from 64px onwards?) I am anxious to see the results. I can get this effect to work in Xonotic, so I should be able to get it to work in Minetest as well (both games use OpenGL.)
Edit by sfan5: Don't quote the whole post goddamnit!

Posted:
Mon Jul 29, 2013 17:10
by Dan Duncombe
I saw no difference between them at all.

Posted:
Mon Jul 29, 2013 17:14
by Inocudom
Dan Duncombe wrote:I saw no difference between them at all.
The first one is flat looking, the second one looks a little more 3D, and the third one really looks 3D. If you were looking at the effect in-game, you would notice the difference. That I can most certainly promise you, because I have played (and still do play) Xonotic, and it has the same effect for textures in it.

Posted:
Mon Jul 29, 2013 17:28
by RealBadAngel
PilzAdam wrote:Fake.
Sure:


Posted:
Mon Jul 29, 2013 17:31
by PilzAdam
RealBadAngel wrote:PilzAdam wrote:Fake.
Sure:

Source or it didnt happen.

Posted:
Mon Jul 29, 2013 17:41
by Inocudom
PilzAdam wrote:RealBadAngel wrote:PilzAdam wrote:Fake.
Sure:

Source or it didnt happen.
It looks like PilzAdam will be hard to convince. You might have to show him your branch of Minetest, RealBadAngel.

Posted:
Mon Jul 29, 2013 17:42
by RealBadAngel
PilzAdam wrote:RealBadAngel wrote:PilzAdam wrote:Fake.
Sure:

Source or it didnt happen.
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
uniform sampler2D myTexture;
uniform sampler2D normalTexture;
uniform vec4 skyBgColor;
uniform float fogDistance;
uniform float scale;
varying vec2 texCoord;
varying vec3 vPosition;
varying vec3 viewVec;
varying vec3 eyeVec;
varying vec4 vertexViewPos;
varying vec4 vertexProjPos;
varying vec3 tsPosition;
varying vec3 tsCameraPosition;
varying vec3 tsLightSource;
void main (void)
{
float bumpScale = 0.15;
float shininess = 1.0;
vec4 normalMap;
vec2 offset = gl_TexCoord[0].st;
vec3 tsE = normalize(tsCameraPosition-tsPosition);
vec2 viewTS = vec2(-tsE.x, -tsE.y);// (tsE.z);
viewTS = normalize(viewTS);
for(int i = 0; i < 3; i++) {
normalMap = texture2D(normalTexture, offset);
float height = normalMap.a * 0.05 - 0.025;
offset += height * normalMap.z * viewTS * bumpScale ;
}
float alpha texture2D(myTexture, offset).a;
vec3 base = texture2D(myTexture, offset).xyz;
vec3 normal = texture2D(normalTexture, offset).xyz;
vec3 vVec = normalize(viewVec);
vec3 bump = normalize(normal * 2.0 - 1.0);
vec3 R = reflect(-viewVec, bump);
vec3 lVec = normalize(vec3(0.0, -0.4, 0.5));
float diffuse = max(dot(lVec, bump), 0.0);
float specular = pow(clamp(dot(R, lVec), 0.0, 1.0),1.0);
vec3 color = diffuse * base + 0.4 * diffuse * specular;
vec4 col = vec4(color.r, color.g, color.b, alpha);
col *= gl_Color;
col = col * col; // SRGB -> Linear
col *= 1.8;
col.r = 1.0 - exp(1.0 - col.r) / exp(1.0);
col.g = 1.0 - exp(1.0 - col.g) / exp(1.0);
col.b = 1.0 - exp(1.0 - col.b) / exp(1.0);
col = sqrt(col); // Linear -> SRGB
if(fogDistance != 0.0){
float d = max(0.0, min(vPosition.z / fogDistance * 1.5 - 0.6, 1.0));
alpha = mix(alpha, 0.0, d);
}
gl_FragColor = vec4(col.r, col.g, col.b, alpha);
}
Btw, closer look at bricks...


Posted:
Mon Jul 29, 2013 17:44
by PilzAdam
RealBadAngel wrote:PilzAdam wrote:RealBadAngel wrote:Sure:

Source or it didnt happen.
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
uniform sampler2D myTexture;
uniform sampler2D normalTexture;
uniform vec4 skyBgColor;
uniform float fogDistance;
uniform float scale;
varying vec2 texCoord;
varying vec3 vPosition;
varying vec3 viewVec;
varying vec3 eyeVec;
varying vec4 vertexViewPos;
varying vec4 vertexProjPos;
varying vec3 tsPosition;
varying vec3 tsCameraPosition;
varying vec3 tsLightSource;
void main (void)
{
float bumpScale = 0.15;
float shininess = 1.0;
vec4 normalMap;
vec2 offset = gl_TexCoord[0].st;
vec3 tsE = normalize(tsCameraPosition-tsPosition);
vec2 viewTS = vec2(-tsE.x, -tsE.y);// (tsE.z);
viewTS = normalize(viewTS);
for(int i = 0; i < 3; i++) {
normalMap = texture2D(normalTexture, offset);
float height = normalMap.a * 0.05 - 0.025;
offset += height * normalMap.z * viewTS * bumpScale ;
}
float alpha texture2D(myTexture, offset).a;
vec3 base = texture2D(myTexture, offset).xyz;
vec3 normal = texture2D(normalTexture, offset).xyz;
vec3 vVec = normalize(viewVec);
vec3 bump = normalize(normal * 2.0 - 1.0);
vec3 R = reflect(-viewVec, bump);
vec3 lVec = normalize(vec3(0.0, -0.4, 0.5));
float diffuse = max(dot(lVec, bump), 0.0);
float specular = pow(clamp(dot(R, lVec), 0.0, 1.0),1.0);
vec3 color = diffuse * base + 0.4 * diffuse * specular;
vec4 col = vec4(color.r, color.g, color.b, alpha);
col *= gl_Color;
col = col * col; // SRGB -> Linear
col *= 1.8;
col.r = 1.0 - exp(1.0 - col.r) / exp(1.0);
col.g = 1.0 - exp(1.0 - col.g) / exp(1.0);
col.b = 1.0 - exp(1.0 - col.b) / exp(1.0);
col = sqrt(col); // Linear -> SRGB
if(fogDistance != 0.0){
float d = max(0.0, min(vPosition.z / fogDistance * 1.5 - 0.6, 1.0));
alpha = mix(alpha, 0.0, d);
}
gl_FragColor = vec4(col.r, col.g, col.b, alpha);
}
You should hardcode the result of exp(1.0), Exio said it gives a nice FPS boost.

Posted:
Mon Jul 29, 2013 17:51
by RealBadAngel
PilzAdam wrote:You should hardcode the result of exp(1.0), Exio said it gives a nice FPS boost.
Good idea

Posted:
Mon Jul 29, 2013 17:52
by Inocudom
PilzAdam wrote:You should hardcode the result of exp(1.0), Exio said it gives a nice FPS boost.
What is exp(1.0) supposed to be, and how would it be able to speed up Minetest's FPS? If it can speed up Minetest's FPS, then it is a worthwhile effort, though it might be easier to do if more than one person works on it. Besides RealBadAngel, is there anyone else that is skilled in such an area?

Posted:
Mon Jul 29, 2013 17:58
by RealBadAngel
Inocudom wrote:PilzAdam wrote:You should hardcode the result of exp(1.0), Exio said it gives a nice FPS boost.
What is exp(1.0) supposed to be, and how would it be able to speed up Minetest's FPS? If it can speed up Minetest's FPS, then it is a worthwhile effort, though it might be easier to do if more than one person works on it. Besides RealBadAngel, is there anyone else that is skilled in such an area?
exp(1,0) equals 2.71828182846, constant called e
about shaders only person i know of who played a bit with them is Jeija
He made one geometry shader, waving water.

Posted:
Mon Jul 29, 2013 18:00
by PilzAdam
RealBadAngel wrote:about shaders only person i know of who played a bit with them is Jeija
kahrl wrote the whole shader support in Minetest, celeron55 rebased it and Exio found that exp(1.0) hardcoding thing out; so there are a few people who know whats going on.

Posted:
Mon Jul 29, 2013 18:09
by RealBadAngel
PilzAdam wrote:RealBadAngel wrote:about shaders only person i know of who played a bit with them is Jeija
kahrl wrote the whole shader support in Minetest, celeron55 rebased it and Exio found that exp(1.0) hardcoding thing out; so there are a few people who know whats going on.
Youre right.
As soon as i clean all the mess in shaders rewrite i will make the repo public.
Ive made changes not only to shaders themselves but to c++ code as well.

Posted:
Wed Aug 07, 2013 03:33
by Inocudom
If any of you have ever played Xonotic, then you know how parallax mapping can really make textures come to life. It is a wonderful feature that I hope will find much use.

Posted:
Mon Aug 19, 2013 16:46
by Inocudom
RealBadAngel might be on vacation right now, so it is best to wait until autumn for this (just like with many other things concerning Minetest.)

Posted:
Mon Aug 19, 2013 21:21
by Mito551
PilzAdam wrote:Fake.
and gay.

Posted:
Mon Aug 19, 2013 22:54
by Inocudom
Mito551 wrote:PilzAdam wrote:Fake.
and gay.
What is wrong with parallax mapping? It makes textures look more real. Check out Xonotic if you don't believe me.
It is starting to sound as if only me, VanessaE, and RealBadAngel himself will use this. I hope I can be proved wrong to that end.

Posted:
Tue Aug 20, 2013 02:22
by Chinchow
Inocudom wrote:Mito551 wrote:PilzAdam wrote:Fake.
and gay.
What is wrong with parallax mapping? It makes textures look more real. Check out Xonotic if you don't believe me.
It is starting to sound as if only me, VanessaE, and RealBadAngel himself will use this. I hope I can be proved wrong to that end.
IIf normal sharers cause redness everywhere then what effect will this have if my graphics card isn't good enough?

Posted:
Tue Aug 20, 2013 05:45
by VanessaE
The red comes from the shaders being written in a language (GLSL) that your video driver mode (probably DirectX) doesn't understand. You either have to switch to OpenGL mode, or you won't be able to use shaders at all.

Posted:
Tue Aug 20, 2013 09:53
by Dan Duncombe
Hybrid Dog wrote:VanessaE wrote:The red comes from the shaders being written in a language (GLSL) that your video driver mode (probably DirectX) doesn't understand. You either have to switch to OpenGL mode, or you won't be able to use shaders at all.
Since there's an ability to use bumpmapping my shaders doesn't work. Everything is red. But before it worked.
Could we have an option for bumpmapping without shaders? That would be nice.

Posted:
Tue Aug 20, 2013 16:08
by Inocudom
Dan Duncombe wrote:Hybrid Dog wrote:VanessaE wrote:The red comes from the shaders being written in a language (GLSL) that your video driver mode (probably DirectX) doesn't understand. You either have to switch to OpenGL mode, or you won't be able to use shaders at all.
Since there's an ability to use bumpmapping my shaders doesn't work. Everything is red. But before it worked.
Could we have an option for bumpmapping without shaders? That would be nice.
According to the page beyond the link below, it might be possible:
http://irrlicht.sourceforge.net/forum/viewtopic.php?p=169729Concerning shaders for DirectX, the post beyond the link below shows how likely such a thing is:
https://forum.minetest.net/viewtopic.php?pid=103046#p103046

Posted:
Wed Aug 21, 2013 06:39
by Mito551
RBA, any chance you could demonstrate how that looks with 16/32px textures?

Posted:
Wed Aug 21, 2013 14:18
by Inocudom
Mito551 wrote:RBA, any chance you could demonstrate how that looks with 16/32px textures?
It might not look good with those, but 64px and above should look fine.

Posted:
Wed Aug 21, 2013 15:54
by Mito551
Inocudom wrote:Mito551 wrote:RBA, any chance you could demonstrate how that looks with 16/32px textures?
It might not look good with those, but 64px and above should look fine.
i suspect. that's why i ask.

Posted:
Wed Aug 21, 2013 22:26
by philipbenr
RealBadAngel wrote:Btw, closer look at bricks...

They look a bit glassy to me, but this is so COOL I would love to try this.

Posted:
Thu Aug 22, 2013 03:47
by wburton72
Thank you for your hard work!!

Posted:
Thu Aug 22, 2013 16:04
by Mito551
Mito551 wrote:RBA, any chance you could demonstrate how that looks with 16/32px textures?
so?

Posted:
Thu Aug 22, 2013 18:42
by Inocudom
Mito551 wrote:Mito551 wrote:RBA, any chance you could demonstrate how that looks with 16/32px textures?
so?
RealBadAngel seems to be on vacation right now, as I have not seen him in the irc chat rooms lately. Wait until autumn.