RUS New site

Advanced search

[ New messages · Forum rules · Members ]
Page 1 of 6123456»
Forum » SpaceEngine » Mods and Addons » Shader programming (Questions and answers about shader programming)
Shader programming
JackDoleDate: Wednesday, 04.11.2015, 15:08 | Message # 1
Star Engineer
Group: Local Moderators
Germany
Messages: 1737
Status: Offline
I do not know if there is great interest in shader programming. I myself can not make contributions so far, since I do not understand much of it.

But who has any questions, can ask here. Maybe they will be answered by people who know something about it.

And who has already programmed some shaders and will not make a separate thread for it; can publish them here.

And maybe I'm learning something, what's the point of it all. biggrin





Don't forget to look here.

 
HarbingerDawnDate: Wednesday, 04.11.2015, 15:52 | Message # 2
Cosmic Curator
Group: Administrators
United States
Messages: 8714
Status: Offline
The one thing I'm trying to do regarding shaders is try to make a chemical rocket engine shader. This requires two things: making the shape of the effect grow as it gets farther from the source, which I have done; and making it get less bright as it gets farther from the source, which I cannot figure out. My math skills are not good enough for this :)

The top image is what I have currently, the bottom image is a very approximate representation of what I want:

And this is my current shader code (from ship_engines.glsl):

Code
#ifdef TYPE_CHEMICAL // WIP
float   exhaustDensity(vec3 pos)
{
    // Cylindric coordinates of the point
    float r2 = dot(pos.xy, pos.xy);
    float r = sqrt(r2);
    float l = 0.5 - 0.5 * pos.z;

    // Noise to modulate exhaust core
    float Noise = 2.0;
    if (l > 0.25) // condition may speedup execution on some hardware
    {
        vec3 npos = pos;
        npos.xy *= 6.7;
        npos.z += EyePosTime.w;
        Noise -= noise(npos) * sqrt(max(l - 0.25, 0.0) * 1.333);
    }

    // Exhaust intensity
    float core = exp(-4.0 * r2) * exp(4.0 * l) * smoothstep(1.0, 0.9, + l);

    return 0.01 * core * Noise;
}
#endif

You will have to change CHEMICAL to ION, AEROSPIKE, or FUSION to get it to work in SE.

Any help would be appreciated (and quite possibly would be integrated into SE as a new default shader).





All forum users, please read this!
My SE mods and addons
Phenom II X6 1090T 3.2 GHz, 16 GB DDR3 RAM, GTX 970 3584 MB VRAM
 
JackDoleDate: Wednesday, 04.11.2015, 20:10 | Message # 3
Star Engineer
Group: Local Moderators
Germany
Messages: 1737
Status: Offline
HarbingerDawn,

I played around a bit with it, but all I've got so far is this:



A splitting of the beam. But no decrease in brightness. sad

Attachments: 0115535.jpg(164Kb)





Don't forget to look here.

 
DoctorOfSpaceDate: Wednesday, 04.11.2015, 20:29 | Message # 4
Galaxy Architect
Group: Global Moderators
Pirate
Messages: 3600
Status: Offline
Old shader I did for White holes updated for use in 0.9.7.4 patch 7


Might be of some use for custom addons if combined with JackDole's modified black hole shader.

Attachments: blackhole_warp.glsl(1Kb)





Intel Core i7-5820K 4.2GHz 6-Core Processor
G.Skill Ripjaws V Series 32GB (4 x 8GB) DDR4-2400 Memory
EVGA GTX 980 Ti SC 6GB
 
JackDoleDate: Thursday, 05.11.2015, 22:42 | Message # 5
Star Engineer
Group: Local Moderators
Germany
Messages: 1737
Status: Offline
What debugger can I use to debug 'SpaceEngines' GLSL shader scripts?




Don't forget to look here.

 
DoctorOfSpaceDate: Thursday, 05.11.2015, 22:52 | Message # 6
Galaxy Architect
Group: Global Moderators
Pirate
Messages: 3600
Status: Offline
Quote JackDole ()
What debugger can I use to debug 'SpaceEngines' GLSL shader scripts?


Debug mode in the program. Open the game, go to the object you are editing, press * on the numpad, and then F5 to reload as you make changes.





Intel Core i7-5820K 4.2GHz 6-Core Processor
G.Skill Ripjaws V Series 32GB (4 x 8GB) DDR4-2400 Memory
EVGA GTX 980 Ti SC 6GB
 
JackDoleDate: Friday, 06.11.2015, 00:39 | Message # 7
Star Engineer
Group: Local Moderators
Germany
Messages: 1737
Status: Offline
Quote DoctorOfSpace ()
Debug mode in the program

There are missing a few lines, my screen is not high enough. And there are no contents of shader variables displayed.





Don't forget to look here.

 
HarbingerDawnDate: Friday, 06.11.2015, 01:03 | Message # 8
Cosmic Curator
Group: Administrators
United States
Messages: 8714
Status: Offline
Quote JackDole ()
And there are no contents of shader variables displayed.

Doc was talking about how to reload the shaders without reloading the program. As far as I know there isn't any specific information available to debugging shader code.





All forum users, please read this!
My SE mods and addons
Phenom II X6 1090T 3.2 GHz, 16 GB DDR3 RAM, GTX 970 3584 MB VRAM
 
JackDoleDate: Friday, 06.11.2015, 10:10 | Message # 9
Star Engineer
Group: Local Moderators
Germany
Messages: 1737
Status: Offline
Quote HarbingerDawn ()
Doc was talking about how to reload the shaders without reloading the program.

Yes, but what I need is a real debugger that can me display the contents of variables at runtime. There are plenty of such debugger, but I'd like to know if anyone can recommend a debugger, which is especially suitable for SpaceEngine.





Don't forget to look here.

 
JackDoleDate: Tuesday, 17.11.2015, 13:57 | Message # 10
Star Engineer
Group: Local Moderators
Germany
Messages: 1737
Status: Offline
Quote HarbingerDawn ()
chemical rocket engine shader

I keep trying. But, I think, still not what you want. sad




Attachments: 2159480.jpg(164Kb) · 4241639.jpg(75Kb)





Don't forget to look here.

 
HarbingerDawnDate: Tuesday, 17.11.2015, 14:14 | Message # 11
Cosmic Curator
Group: Administrators
United States
Messages: 8714
Status: Offline
I don't want it hollow, I just want it to get dimmer farther from the source, like a real rocket plume. As I said, my graphic showing what I want was very approximate.

Something like this:





All forum users, please read this!
My SE mods and addons
Phenom II X6 1090T 3.2 GHz, 16 GB DDR3 RAM, GTX 970 3584 MB VRAM


Edited by HarbingerDawn - Tuesday, 17.11.2015, 14:16
 
JackDoleDate: Tuesday, 17.11.2015, 14:32 | Message # 12
Star Engineer
Group: Local Moderators
Germany
Messages: 1737
Status: Offline
I know, but I'm afraid; the shader needs to be completely rewritten. This function returns only one value to the calling function: 'intensity'. This value determines the shape and color. I think there ought to be two values, one for the form and one for the color. But that exceeds currently still my skills with shaders.

But I'll keep trying.


Yellow beam:


Attachments: 5343992.jpg(164Kb)





Don't forget to look here.



Edited by JackDole - Tuesday, 17.11.2015, 14:36
 
HarbingerDawnDate: Tuesday, 17.11.2015, 16:35 | Message # 13
Cosmic Curator
Group: Administrators
United States
Messages: 8714
Status: Offline
I think you're right about the shader needing to be rewritten, unfortunately.




All forum users, please read this!
My SE mods and addons
Phenom II X6 1090T 3.2 GHz, 16 GB DDR3 RAM, GTX 970 3584 MB VRAM
 
JackDoleDate: Wednesday, 18.11.2015, 13:08 | Message # 14
Star Engineer
Group: Local Moderators
Germany
Messages: 1737
Status: Offline
Quote JackDole ()
I think by the way, it might be possible to write your own shaders scripts - for example, a function for an Einstein-Rosen Bridge - and with #Include to bind into the system. Then you can call these functions via an IF query.
Moreover, I think, a separate thread for shader programming would make sense. wink

There I have speculated, it would be possible to write your own shaders and integrate them with #include "filename.glsl".

It is possible.

With Klud's astereroid and selena shaders I've tried it.

I have written a custom script for Klud's function 'float iqTurbulence (vec3 point, int octaves, float lacunarity, float gain)'
From 'tg_common.glsl' needs to be removed this function, of course!

'kl_iqTurbulence.glsl'
Code

#include "tg_common.glsl"

#ifdef _FRAGMENT_

// "iqTurbulence" function by Inigo Quilez
// http://www.iquilezles.org , http://www.decarpentier.nl/scape-procedural-basics

float iqTurbulence(vec3 point, int octaves, float lacunarity, float gain)
{
    float summ = 0.5;
    float freq = 1.0, amp = 1.0;
    vec2 dsum = vec2(0.0, 0.0);
    for (int i=0; i < octaves; i++)
    {
        vec4 n = NoiseDeriv(point * freq);
        dsum += n.yz;
        summ += amp * n.x / (1 + dot(dsum, dsum));
        freq *= lacunarity;
        amp *= gain;
    }
    return summ;
}

#endif


The line #include "tg_common.glsl" in Klud's scripts 'tg_asteroid_height.glsl' and 'tg_selena_height.glsl' must then be replaced by #include "kl_iqTurbulence.glsl".

And it works!

These are not the same images, which I have already published in Kluds thread, they are only of the same position.



Attempt this only if you know what you're doing! wink

Attachments: 4892074.jpg(270Kb) · 0562694.jpg(187Kb) · 9978443.jpg(174Kb) · 7558195.jpg(169Kb)





Don't forget to look here.

 
KludDate: Wednesday, 25.11.2015, 15:56 | Message # 15
Astronaut
Group: Users
Russian Federation
Messages: 72
Status: Offline
We can get it:



If do so:

Code
float   exhaustDensity(vec3 pos)
{
    // Cylindric coordinates of the point

    float r2 = 1.0 / dot(pos.xy, pos.xy);
    float l = 0.5 - 0.5 * pos.z;

    // Exhaust intensity

    float core =  0.1 * smoothstep(0.5, 3.0, r2 * l) * pow(mix(2.0, 0.0, l), 3.0);

    return core;
}

Attachments: 9769887.jpg(385Kb)
 
Forum » SpaceEngine » Mods and Addons » Shader programming (Questions and answers about shader programming)
Page 1 of 6123456»
Search: