Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Valleriani

Pages: [1]
1
General / Re: Shader Problems.
« on: July 30, 2015, 05:32:53 pm »
Ahh! Yeah, my mistake. Okay, will give that a shot then! Thanks!

2
General / Re: Shader Problems.
« on: July 30, 2015, 02:31:04 pm »
How do you set the blend mode properly to Multiply? When I do it I am doing something like this


   sf::RenderStates state;
   state.shader = &m_planetShadowShader;
   state.blendMode = sf::BlendMultiply;
   state.transform = sf::Transform::Identity;

But it's not working properly. The alpha ends up not being transparent, instead it becomes black.


Here is some other coding as well:

   m_planetshadowsphere.setRadius(275);
   m_planetshadowsphere.setFillColor(sf::Color::Transparent);
   m_planetshadowsphere.setOrigin(m_planetatmosphere.getRadius(), m_planetatmosphere.getRadius());
   m_planetshadowsphere.setPosition((window.getSize().x / 2) - 40.f, (window.getSize().y / 2) - 40.f);

   m_planetShadowShader.loadFromMemory(Vertex, RadialGradient);
   m_planetShadowShader.setParameter("color", 1.f, 0.f, 0.f, 0.2f);
   m_planetShadowShader.setParameter("center", m_planetshadowsphere.getPosition());
   m_planetShadowShader.setParameter("radius", m_planetshadowsphere.getRadius());
   m_planetShadowShader.setParameter("expand", 0.0f);

and being drawn as

   window.draw(m_planetshadowsphere, state);

3
General / Re: Shader Problems.
« on: July 29, 2015, 09:40:12 pm »
Would that involve using two circles with two different shaders? I am not 100% sure I follow on that. I would assume I would set the blend mode then to mix. There might be a way to mix the two as well, I am unsure yet. Will need to do some trial and error.

Updated an example of what I did. I am using one extra circle so far but at the moment you can kind of see the second circle on the right side so I am guessing I am doing something wrong.. Not sure if this is what you meant but there is issues with it blending atm.

4
General / Re: Shader Problems.
« on: July 28, 2015, 10:49:03 pm »
I think I got it, or at least I am pretty happy with it and going to continue with the next thing.

I ended up using a normal map with dark and light areas and pasting that over it. It can be adjusted to adjust where the sun vs where the shade is going to be, and less values typically mean more shadow.

Maybe can upload a video of it, the image doesn't serve justice when it's rotating. I made the bumps a bit more realistic now due to the way the light works on it now.

Thanks much for the help!

5
General / Re: Shader Problems.
« on: July 28, 2015, 08:11:46 pm »
It's so beautiful ;) It works really well!

My final question, is about camera angle and lighting. My goal is to have a dark portion of the planet depending on where the sun is. Is it as simple as for example, having my light in the shader rotate around the planet rather then being right in front

I.E. "vec3 light_pos = normalize(vec3(0.5, 0.2, 1.0));"

I would assume when the light is off to the side or behind the planet, it will give a darkness on a certain amount of the planet. I think the biggest thing is adjusting the camera so its not static and can take some proper x/y values?

I.E. What I mean is shown in the second image.

6
General / Re: Shader Problems.
« on: July 28, 2015, 05:22:13 pm »
Applying a shader to a final render would be a post-processing effect applied to the entire after it has all been drawn.
This is unlikely what you want here. In fact, I've just created a generic radial gradient shader that will do atmosphere job for you. I'm going to add it to the Wiki shortly  :)

Ah okay, so that would be more like if you want glow effects on the entire scene for example. Got it.

Oh neat! I am looking forward to it!

7
General / Re: Shader Problems.
« on: July 28, 2015, 04:41:24 pm »
Thanks both for the advice!

I understand about the quads and how it would work. I was using a couple quads to make some engine thrust (In which it fades out) rather then using a texture like I talked about in another post. It actually came out pretty good, so I understand the concept of that (or using the tri-fan).

The shader idea seems good, but what do you mean by final render? Do you mean the last lines of the actual render? I assume its post-rendering. But I don't fully understand where I would add that if for example, it has to be added afterwards in the coding (A second shader pass?)

Yes, the atmosphere idea actually was due to your bonus, I got the idea from it :P

I will do some research on the fog and hopefully find some sort of solution, otherwise I can most likely do the second sphere in the background relatively easy. I too don't 100% know where to start on that yet.

8
General / Re: Shader Problems.
« on: July 27, 2015, 11:38:34 pm »
So far so good, I attached an image of what I have so far. Pretty much the planet, with a normal map (for those lovely bumps), and also a cloud layer that moves a little faster then the planet. Overall, it looks very cool, the image doesn't show it justice since the rotation makes it look very neat.

However, another question!

I am trying to make a kind of *glow* from the planet, I.E. a atmosphere glow. I am unsure of the best practice of this. People talk about using a 'bloom' effect but I don't think that is what I want, plus I think that takes a good portion of process time.

I was looking or thinking about a rim glow, something simple around the planet. What could be the best idea for this using shaders? Is there a quick way?

Another idea I had was wrapping the planet in a slightly larger circle, and having it wrap an image around the planet. This is something I am not sure to do because it needs to make a 'shield' like effect, rather then using a full image. I.E. See the atmosphere.png image to see the image I would wrap the planet around.


Thanks!

9
General / Re: Shader Problems.
« on: July 26, 2015, 08:27:57 pm »
Ah! Thank you for the help! It is working good now.

10
General / Re: Shader Problems.
« on: July 26, 2015, 03:08:51 pm »
I wasnt able to get it working, I did change what you said but not sure if it is correct. It works without the shader though.

#include <SFML/Graphics.hpp>

const char Vertex[] =
"#version 120\n"

"void main()"
"{"
"gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;"
"gl_TexCoord[0] = gl_MultiTexCoord0;"
"}";

const char Fragment[] =
"#version 120\n"

"uniform sampler2D tex0;"
"uniform vec4 bkg_color;"
"uniform float time;"
"void main(void)"
"{"
"vec2 p = -1.0 + 2.0 * gl_TexCoord[0].xy;"
"float r = sqrt(dot(p, p));"
"if (r < 1.0)"
"{"
"vec2 uv;"
"float f = (1.0 - sqrt(1.0 - r)) / (r);"
"uv.x = p.x*f + time;"
"uv.y = p.y*f + time;"
"gl_FragColor = texture2D(tex0, uv);"
"}"
"else"
"{"
"gl_FragColor = bkg_color;"
"}"
"}";


int main(){
        //create window
        sf::RenderWindow window;
        sf::VideoMode mode;
        mode.height = 600;
        mode.width = 600;
        window.create(mode, "Planet");
        window.setVerticalSyncEnabled(true);
        window.setFramerateLimit(60);

        //create planet
        sf::CircleShape m_planet;
        sf::Texture m_texture;
        sf::Shader m_planetShader;

        m_texture.loadFromFile("assets/textures/environment/earthmap1k.jpg");
        m_texture.setRepeated(true);
        m_planet.setRadius(100);
        m_planet.setOrigin(m_planet.getRadius(), m_planet.getRadius());
        m_planet.setPosition(window.getSize().x / 2, window.getSize().y / 2);
        m_planet.setTexture(&m_texture);

        m_planetShader.loadFromMemory(Vertex, Fragment);
        m_planetShader.setParameter("tex0", sf::Shader::CurrentTexture);
        m_planetShader.setParameter("bkg_color", 0.0f, 0.0f, 0.0f, 1.0f);
        m_planetShader.setParameter("time", 1.0f);

        //main loop
        bool play = true;
        while (play){
                sf::Event event;
                while (window.pollEvent(event)){
                        if (event.type == sf::Event::Closed){
                                play = false;
                        }
                }
                window.clear();

                window.draw(m_planet, &m_planetShader);

                //window.draw(m_planet); //Works
                window.display();
        }

        if (window.isOpen()){
                window.close();
        }
        return 0;
}
 

Use any image to test really, the biggest thing is that the shader would be working rather then what image is used. I know the time should be updated but for now I am just using a static time.

Thanks!

11
General / Shader Problems.
« on: July 25, 2015, 10:18:26 pm »
I am pretty new to using shaders, but I am attempting to use a shader from here:
http://www.geeks3d.com/20130705/shader-library-circle-disc-fake-sphere-in-glsl-opengl-glslhacker/4/

It is a 'fake sphere' shader. I want it to make my planet look rather nice. Right now it rotates

I have declared them as so:

const char Vertex[] =
"#version 120\n"

"void main()"
"{"
        "gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;"
        "gl_TexCoord[0] = gl_MultiTexCoord0;"
"}";

const char Fragment[] =
"#version 120\n"

"uniform sampler2D tex0;"
"uniform vec4 bkg_color;"
"uniform float time;"
"void main(void)"
"{"
        "vec2 p = -1.0 + 2.0 * gl_TexCoord[0].xy;"
        "float r = sqrt(dot(p, p));"
        "if (r < 1.0)"
                "{"
                "vec2 uv;"
                "float f = (1.0 - sqrt(1.0 - r)) / (r);"
                "uv.x = p.x*f + time;"
                "uv.y = p.y*f + time;"
                "gl_FragColor = texture2D(tex0, uv);"
                "}"
        "else"
                "{"
                "gl_FragColor = bkg_color;"
                "}"
"}";

I loading it up like this:

sf::CircleShape planet;
sf::Texture texture;
sf::Shader m_planetShader;

m_planetShader.loadFromMemory(Vertex, Fragment);
texture.loadFromFile("assets/textures/environment/earthmap1k.jpg");
texture.setRepeated(true);

planet.setRadius(100);
planet.setOrigin(planet.getRadius(), planet.getRadius());
planet.setPosition(window.getSize().x / 2, window.getSize().y / 2);
planet.setTexture(&texture); //Is this still needed?

m_planetShader.setParameter("tex0", texture);
m_planetShader.setParameter("bkg_color", 1.0f, 0.0f, 0.0f, 1.0f); //Red as a test
m_planetShader.setParameter("time", 1.0f); //Should be able to update this later on to move the map.
 

and display is using

window.draw(planet, &m_planetShader);

Obviously with window.display() and other general uses. When it is loaded, It uses the bkg_color (red), but not the texture. Am I missing or declaring something wrong?

Thanks!

12
General / Re: Thor & Particle Effects
« on: July 24, 2015, 04:58:57 pm »
Ah okay, so not really a particle system that does what I want. So you think that a sprite (I'm guessing with a shader to give it a nice effect) could do this well then?

13
General / Thor & Particle Effects
« on: July 23, 2015, 09:33:58 pm »
Hello!

I am interested in using particle effects, but have not done so yet before. I have setup SFML and Thor now and it does work fine for basic effects, but I'm trying to aim to make a 'hard thrust' rather then a smoke particle thrust.

The example image (first image) is what I have. It's a basic thrust that fades out largely, when the ship rotates though, it looks more of a smoke trail because it doesn't 'stick' with the ship rotation like a real thrust would. (Check example2 to see what I mean by that.)

What I want is more of a turbine type thrust, like this one here:
http://forum.unity3d.com/attachments/unity-2013-10-16-21-41-01-37-jpg.71190/


Does anyone have any tips or examples on this? Is there a good guide to particle effects and thor or something similar? Thanks!

Pages: [1]