Upcoming new shaders

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

Upcoming new shaders

by RealBadAngel » Mon Jul 29, 2013 16:54

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:
Image

Iterative Parallax Mapping:
Image

Iterative Parallax Mapping + Normal Bumpmapping:
Image
 

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

by PilzAdam » Mon Jul 29, 2013 16:57

Fake.
 

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

by Inocudom » Mon Jul 29, 2013 17:08

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!
Last edited by sfan5 on Wed Aug 07, 2013 07:10, edited 1 time in total.
 

User avatar
Dan Duncombe
Member
 
Posts: 904
Joined: Thu May 09, 2013 21:11

by Dan Duncombe » Mon Jul 29, 2013 17:10

I saw no difference between them at all.
Some Mods: Castles Prefab Camouflage
My Games: Nostalgia Realtest Revamped
Servers: See above games.
 

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

by Inocudom » Mon Jul 29, 2013 17:14

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.
 

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

by RealBadAngel » Mon Jul 29, 2013 17:28

PilzAdam wrote:Fake.


Sure:
Image
 

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

by PilzAdam » Mon Jul 29, 2013 17:31

RealBadAngel wrote:
PilzAdam wrote:Fake.


Sure:
Image

Source or it didnt happen.
 

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

by Inocudom » Mon Jul 29, 2013 17:41

PilzAdam wrote:
RealBadAngel wrote:
PilzAdam wrote:Fake.


Sure:
Image

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.
 

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

by RealBadAngel » Mon Jul 29, 2013 17:42

PilzAdam wrote:
RealBadAngel wrote:
PilzAdam wrote:Fake.


Sure:
Image

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...
Image
Last edited by RealBadAngel on Mon Jul 29, 2013 17:46, edited 1 time in total.
 

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

by PilzAdam » Mon Jul 29, 2013 17:44

RealBadAngel wrote:
PilzAdam wrote:
RealBadAngel wrote:
Sure:
Image

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.
 

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

by RealBadAngel » Mon Jul 29, 2013 17:51

PilzAdam wrote:You should hardcode the result of exp(1.0), Exio said it gives a nice FPS boost.


Good idea
 

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

by Inocudom » Mon Jul 29, 2013 17:52

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?
 

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

by RealBadAngel » Mon Jul 29, 2013 17:58

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.
Last edited by RealBadAngel on Mon Jul 29, 2013 17:59, edited 1 time in total.
 

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

by PilzAdam » Mon Jul 29, 2013 18:00

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.
 

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

by RealBadAngel » Mon Jul 29, 2013 18:09

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.
 

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

by Inocudom » Wed Aug 07, 2013 03:33

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.
 

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

by Inocudom » Mon Aug 19, 2013 16:46

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.)
 

User avatar
Mito551
Member
 
Posts: 1271
Joined: Sat Jun 16, 2012 15:03

by Mito551 » Mon Aug 19, 2013 21:21

PilzAdam wrote:Fake.


and gay.
 

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

by Inocudom » Mon Aug 19, 2013 22:54

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.
Last edited by Inocudom on Mon Aug 19, 2013 22:55, edited 1 time in total.
 

User avatar
Chinchow
Member
 
Posts: 683
Joined: Tue Sep 18, 2012 21:37

by Chinchow » Tue Aug 20, 2013 02:22

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?
Sometimes, it's harder to think up a mod than it is to create it.
Mods: Orichalcum Stonebricks Extra Chests
 

User avatar
VanessaE
Member
 
Posts: 3894
Joined: Sun Apr 01, 2012 12:38
GitHub: VanessaE
IRC: VanessaE
In-game: VanessaEzekowitz

by VanessaE » Tue Aug 20, 2013 05:45

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.
You might like some of my stuff:
Plantlife ~ More Trees ~ Home Decor ~ Pipeworks ~ HDX Textures (16-512px)
Tips (BTC): 13LdcdUFcNCFAm7HfvAXh5GHTjCnnQj6KE
 

User avatar
Dan Duncombe
Member
 
Posts: 904
Joined: Thu May 09, 2013 21:11

by Dan Duncombe » Tue Aug 20, 2013 09:53

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.
Some Mods: Castles Prefab Camouflage
My Games: Nostalgia Realtest Revamped
Servers: See above games.
 

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

by Inocudom » Tue Aug 20, 2013 16:08

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=169729

Concerning 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
 

User avatar
Mito551
Member
 
Posts: 1271
Joined: Sat Jun 16, 2012 15:03

by Mito551 » Wed Aug 21, 2013 06:39

RBA, any chance you could demonstrate how that looks with 16/32px textures?
 

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

by Inocudom » Wed Aug 21, 2013 14:18

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.
 

User avatar
Mito551
Member
 
Posts: 1271
Joined: Sat Jun 16, 2012 15:03

by Mito551 » Wed Aug 21, 2013 15:54

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.
 

User avatar
philipbenr
Member
 
Posts: 1665
Joined: Fri Jun 14, 2013 01:56
GitHub: philipbenr
IRC: philipbenr
In-game: WisdomFire or philipbenr

by philipbenr » Wed Aug 21, 2013 22:26

RealBadAngel wrote:Btw, closer look at bricks...
Image


They look a bit glassy to me, but this is so COOL I would love to try this.
Last edited by philipbenr on Wed Aug 21, 2013 22:27, edited 1 time in total.
"The Foot is down!"
 

wburton72
New member
 
Posts: 4
Joined: Thu Jul 18, 2013 23:23

by wburton72 » Thu Aug 22, 2013 03:47

Thank you for your hard work!!
 

User avatar
Mito551
Member
 
Posts: 1271
Joined: Sat Jun 16, 2012 15:03

by Mito551 » Thu Aug 22, 2013 16:04

Mito551 wrote:RBA, any chance you could demonstrate how that looks with 16/32px textures?


so?
 

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

by Inocudom » Thu Aug 22, 2013 18:42

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.
 

Next

Return to Minetest Features

Who is online

Users browsing this forum: No registered users and 19 guests

cron