Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How do I get the shaders to work
#1
I just downloaded the newest Colobot: Gold Edition Alpha, and I don't know how to get the newly added shaders to work.

Is it because of my graphics card? I have an Intel HD Graphics driver on my laptop.
#KillQueenNowReplaceLater
[Image: 30848703772_6068ae12f5_n.jpg]
#2
Shaders are available for new graphic engines. You need to enable one of them, by running the game with an argument '-graphics gl21', or '-graphics gl33'.
edit: Sorry, I've made a mistake. It's '-graphics glxx' instead of '-opengl xx'
Spoiler :
[Image: unknown.png]
#3
(06-27-2015, 11:52 AM)tomangelo Wrote: Shaders are available for new graphic engines. You need to enable one of them, by running the game with an argument '-graphics gl21', or '-graphics gl33'.
edit: Sorry, I've made a mistake. It's '-graphics glxx' instead of '-opengl xx'

I'll try that soon. Thanks for the suggestion.
#KillQueenNowReplaceLater
[Image: 30848703772_6068ae12f5_n.jpg]
#4
(06-27-2015, 11:52 AM)tomangelo Wrote: Shaders are available for new graphic engines. You need to enable one of them, by running the game with an argument '-graphics gl21', or '-graphics gl33'.
edit: Sorry, I've made a mistake. It's '-graphics glxx' instead of '-opengl xx'

I can't do it. I always get an error message when I put the command line in.
#KillQueenNowReplaceLater
[Image: 30848703772_6068ae12f5_n.jpg]
#5
What is this error?
Spoiler :
[Image: unknown.png]
#6
(06-28-2015, 11:30 PM)tomangelo Wrote: What is this error?

could not read from data directory:
'./data'
#KillQueenNowReplaceLater
[Image: 30848703772_6068ae12f5_n.jpg]
#7
Looks like the working directory is wrong. If you are running the game from the command line, do 'cd "colobot-installation directory"' first
#8
(06-29-2015, 07:00 AM)krzys_h Wrote: Looks like the working directory is wrong. If you are running the game from the command line, do 'cd "colobot-installation directory"' first

didn't work. i'm gonna need a more detailed guide on how i can get these shaders up & running.
#KillQueenNowReplaceLater
[Image: 30848703772_6068ae12f5_n.jpg]
#9
Directory structure should be as follows:

Code:
Your-colobot-directory
 - colobot.exe
 - data
   - ai
   - fonts
   - help
   ...
   - shaders
     - shaders go here

And you run Colobot using switch:

Code:
colobot.exe -graphics ###

Where ### is one of available graphics engines:

opengl -- OpenGL 1.4 engine (default)
gl21 -- OpenGL 2.1 engine
gl33 -- OpenGL 3.3 engine
auto -- automatically determines best available engine (added in dev branch)
"After three days without programming, life becomes meaningless."
~The Tao of Programming
#10
(06-29-2015, 02:07 PM)tomaszkax86 Wrote: Directory structure should be as follows:


Code:
Your-colobot-directory
 - colobot.exe
 - data
   - ai
   - fonts
   - help
   ...
   - shaders
     - shaders go here

And you run Colobot using switch:


Code:
colobot.exe -graphics ###

Where ### is one of available graphics engines:

opengl -- OpenGL 1.4 engine (default)
gl21 -- OpenGL 2.1 engine
gl33 -- OpenGL 3.3 engine
auto -- automatically determines best available engine (added in dev branch)
OK. I've finally got it.
#KillQueenNowReplaceLater
[Image: 30848703772_6068ae12f5_n.jpg]
#11
although i did manage to get colobot running through the command line, i still need to find out how i can get the shaders to work. how do i enable them?
#KillQueenNowReplaceLater
[Image: 30848703772_6068ae12f5_n.jpg]
#12
You enable shaders by using ether OpenGL 2.1 or OpenGL 3.3 engine.
"After three days without programming, life becomes meaningless."
~The Tao of Programming
#13
(07-28-2015, 10:00 AM)tomaszkax86 Wrote: You enable shaders by using ether OpenGL 2.1 or OpenGL 3.3 engine.

I put in the code in command prompt, but the shaders still won't function.
#KillQueenNowReplaceLater
[Image: 30848703772_6068ae12f5_n.jpg]
#14
What kind of error do you have this time? If game runs fine on gl21 or gl33 graphics engine, then shaders are working.
"After three days without programming, life becomes meaningless."
~The Tao of Programming
#15
(08-07-2015, 12:37 PM)tomaszkax86 Wrote: What kind of error do you have this time? If game runs fine on gl21 or gl33 graphics engine, then shaders are working.

There is no error displayed. I run the game with the command line and it works like normal but the shaders aren't working.
#KillQueenNowReplaceLater
[Image: 30848703772_6068ae12f5_n.jpg]
#16
(08-13-2015, 10:25 AM)PracticeBot13 Wrote:
(08-07-2015, 12:37 PM)tomaszkax86 Wrote: What kind of error do you have this time? If game runs fine on gl21 or gl33 graphics engine, then shaders are working.

There is no error displayed. I run the game with the command line and it works like normal but the shaders aren't working.

Check the logs, if you use -graphics gl21 you should see a line:

Code:
[INFO]: Creating CDevice - OpenGL 2.1
[INFO]: OpenGL #

With -graphics gl33 you should see a line:

Code:
[INFO]: Creating CDevice - OpenGL 3.3
[INFO]: OpenGL #.#

If they are initialized properly and no errors occur, then shaders are working. These engines use shaders for all rendering so there's no way shaders are not working when you see UI and everything. I honestly don't know what you're expecting.
"After three days without programming, life becomes meaningless."
~The Tao of Programming
#17
(08-13-2015, 11:53 AM)tomaszkax86 Wrote: I honestly don't know what you're expecting.
Special effects and such xD

When I was first getting into modern opengl I was disappointed how mundane the shaders are. I used to think it's all about post processing(night vision, static noise etc), now I know shaders are used for such boring things as positioning entities Tongue The occasional post-process effect is the cream at the top of the whole pipeline.
#18
(08-13-2015, 02:01 PM)CHmSID Wrote:
(08-13-2015, 11:53 AM)tomaszkax86 Wrote: I honestly don't know what you're expecting.
Special effects and such xD

When I was first getting into modern opengl I was disappointed how mundane the shaders are. I used to think it's all about post processing(night vision, static noise etc), now I know shaders are used for such boring things as positioning entities Tongue The occasional post-process effect is the cream at the top of the whole pipeline.

Colobot doesn't have any post-processing effects and for now doesn't need any. I added mipmapped texturing, anisotropic filtering, MSAA and dynamic shadows to the game and it feels rather heavy. Rendering needs to be optimized in the future.

Shaders are more than just boring positioning of entities. But it's unlikely you can find interesting examples on the Internet. People post rather mundane stuff. So here's something I was doing in OpenGL 3.3: stereoscopic rendering using geometry shaders and array textures. Rather than rendering entire world twice, you setup array textures to store 2 screens. Geometry shader duplicates geometry, one part uses left camera, other part uses right camera. Fragments are output to their own layers within array textures and that gives you 2 rendered scenes from two different cameras.

Code:
// VERTEX SHADER

#version 330

uniform mat4 uni_ModelMatrix;

layout(location = 0) in vec4 in_VertexCoord;
layout(location = 1) in vec4 in_Color;

out VertexData
{
    vec4 Color;
} data;

void main()
{
    gl_Position = uni_ModelMatrix * in_VertexCoord;
    
    data.Color = in_Color;
}


// GEOMETRY SHADER

#version 330

layout(triangles) in;
layout(triangle_strip, max_vertices = 6) out;

uniform mat4 uni_ProjectionMatrix;
uniform mat4 uni_LeftCameraMatrix;
uniform mat4 uni_RightCameraMatrix;

in VertexData
{
    vec4 Color;
} dataIn[];

out VertexData
{
    vec4 Color;
} dataOut;

void main()
{
    for(int i=0; i<3; i++)
    {
        gl_Position = uni_ProjectionMatrix * uni_LeftCameraMatrix * gl_in[i].gl_Position;
        gl_Layer = 0;
        dataOut.Color = dataIn[i].Color;
        
        EmitVertex();
    }
    
    EndPrimitive();
    
    for(int i=0; i<3; i++)
    {
        gl_Position = uni_ProjectionMatrix * uni_RightCameraMatrix * gl_in[i].gl_Position;
        gl_Layer = 1;
        dataOut.Color = dataIn[i].Color;
        
        EmitVertex();
    }
    
    EndPrimitive();
}


// FRAGMENT SHADER

#version 330

in VertexData
{
    vec4 Color;
} data;

out vec4 out_FragColor;

void main()
{
    out_FragColor = data.Color;
}

After that you can do whatever you want with the result. Below is the code that creates red-cyan anaglyph for use with simple 3D glasses.

Code:
// VERTEX SHADER

#version 330

layout(location = 0) in vec4 in_VertexCoord;
layout(location = 1) in vec2 in_TexCoord;

out VertexData
{
    vec2 TexCoord;
} data;

void main()
{
    gl_Position = in_VertexCoord;
    
    data.TexCoord = in_TexCoord;
}


// FRAGMENT SHADER

#version 330

uniform sampler2DArray uni_Texture;

const vec4 const_Red = vec4(1.0f, 0.0f, 0.0f, 1.0f);
const vec4 const_Cyan = vec4(0.0f, 1.0f, 1.0f, 1.0f);

in VertexData
{
    vec2 TexCoord;
} data;

out vec4 out_FragColor;

void main()
{
    out_FragColor = const_Red * texture(uni_Texture, vec3(data.TexCoord, 0.0f))
            + const_Cyan * texture(uni_Texture, vec3(data.TexCoord, 1.0f));
}

This can be easily combined with deferred rendering and make it even better.

PS. We can implement red-cyan anaglyph rendering in Colobot. It doesn't require too much work, although it wouldn't be as optimized as in my example.
"After three days without programming, life becomes meaningless."
~The Tao of Programming
#19
(08-13-2015, 05:05 PM)tomaszkax86 Wrote: PS. We can implement red-cyan anaglyph rendering in Colobot. It doesn't require too much work, although it wouldn't be as optimized as in my example.
I agree and want Smile . I hope this will work with minimum OpenGL 1.4.

Why OpenGL 2.1 is so slow and unstable? Is that because of amount of the lights in the scene?
#20
I never played with extensions, but shaders are only natively available in Opengl 2.1+

So if there are no such extensions, implementing this in pure VBOs could prove to be too slow(It's definitely doable though). On the other hand the worst case scenario for this effect would be that the screen is drawn twice. Which could not be a big deal for low graphics Colobot.


Forum Jump:


Users browsing this thread: 1 Guest(s)