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

Author Topic: Re:creation - a top down action adventure about undeads [hiatus]  (Read 440116 times)

0 Members and 2 Guests are viewing this topic.

Elias Daler

  • Hero Member
  • *****
  • Posts: 599
    • View Profile
    • Blog
    • Email
Re:creation - a top down action rpg about undeads
« Reply #315 on: October 12, 2015, 06:38:27 pm »
Your fog (/water/snow) effect looks pretty cool!

I noticed that they're all at the same height (from the ground) though. Is it possible in your system to adjust this height as required or is it hard-coded at that height?
Thanks!
It's possible to adjust the height, but it's not currently possible to adjust height for individual clouds because the code becomes very complicated. But it's possible that I'll create "layers" of fog at different heights which may make the effect even cooler! :D
Tomb Painter, Re:creation dev (abandoned, doing other things) | edw.is | @EliasDaler

Hapax

  • Hero Member
  • *****
  • Posts: 3346
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re:creation - a top down action rpg about undeads
« Reply #316 on: October 12, 2015, 06:41:46 pm »
It's possible to adjust the height, but it's not currently possible to adjust height for individual clouds because the code becomes very complicated. But it's possible that I'll create "layers" of fog at different heights which may make the effect even cooler! :D
Sounds cool  :)

Can the height be dynamically altered, like a water level rising/falling, for example?  ;)
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

Elias Daler

  • Hero Member
  • *****
  • Posts: 599
    • View Profile
    • Blog
    • Email
Re:creation - a top down action rpg about undeads
« Reply #317 on: October 12, 2015, 07:38:51 pm »
Can the height be dynamically altered, like a water level rising/falling, for example?  ;)
Yeah, the height is just a variable which can be easily changed. :)
Tomb Painter, Re:creation dev (abandoned, doing other things) | edw.is | @EliasDaler

Mario

  • SFML Team
  • Hero Member
  • *****
  • Posts: 879
    • View Profile
Re:creation - a top down action rpg about undeads
« Reply #318 on: October 13, 2015, 11:14:54 am »
Not sure, but from your explanation the fog drawing sounds more complicated, especially if there are multiple things around close by.

Could think of two alternative approaches:
  • Sort fog layers by height.
  • Iterate over all fog layers:
    • Iterate over all sprites, drawing parts below the current fog layer (but above previous height, if any).
    • Draw the current fog layer.
    Draw remaining parts of objects.

Or even easier when using a shader:
  • Determine depth in the fog.
  • Mix textures depending on the depth.

Of course the latter gets more complicated with multiple layers.

Elias Daler

  • Hero Member
  • *****
  • Posts: 599
    • View Profile
    • Blog
    • Email
Re:creation - a top down action rpg about undeads
« Reply #319 on: October 14, 2015, 06:46:29 am »
Mario, thanks for your suggestions. At first I thought I'd say "the first approach is cool, but I want it to be like this:

std::vector<sf::Sprite*> renderList;
... // form it from all entities on the screen
applyFog(renderList);
... // do other stuff
for(auto sPtr : renderList) {
    ... // render
}
"

But then I 've realized that this is possible to do with the first method, I just need to divide sprites in parts and then put sprite parts under the first layer of fog in the renderList, then add fog sprite of the first level, then add all sprite parts under the second layer of fog, etc.
So, I'll need to create sf::Sprite for parts of all entities in the fog, but I think it's okay and won't be a problem!

I can't really understand the second approach, though. Can you explain it more, please?
Tomb Painter, Re:creation dev (abandoned, doing other things) | edw.is | @EliasDaler

Glocke

  • Sr. Member
  • ****
  • Posts: 289
  • Hobby Dev/GameDev
    • View Profile
Re:creation - a top down action rpg about undeads
« Reply #320 on: October 14, 2015, 08:28:37 am »
Or even easier when using a shader:
  • Determine depth in the fog.
  • Mix textures depending on the depth.
I can't really understand the second approach, though. Can you explain it more, please?
Maybe:
  • Draw bottom tiles
  • Apply fog (to make the ground "foggy")
  • For each "higher" tiles and objects (in suitable rendering order):
    • Draw sprite with a shader (*)
(*) And let the shader manipulate all pixels that should be affected by the fog. So if your sprite has a height of 64px and the fog should have a height of 24px, the shader will leave all pixels with height 0-39 as they are, but change the pixels with height 40-63 to be "fogged". I could imagine of using a gradient here, too!

At least that's what I understood :D
« Last Edit: October 14, 2015, 08:32:05 am by Glocke »
Current project: Racod's Lair - Rogue-inspired Coop Action RPG

Elias Daler

  • Hero Member
  • *****
  • Posts: 599
    • View Profile
    • Blog
    • Email
Re:creation - a top down action rpg about undeads
« Reply #321 on: October 14, 2015, 08:59:54 pm »
Glocke, yep shaders might do the trick. But I've never worked with shaders before, so this may be quite a challenge for me... Which I'll try to beat a bit later. :D

Right now I'm working on refactoring and making the game more playable. There were some game breaking bugs which I was okay with. Not anymore. As I work toward playable build, I have to reduce the number of bugs. Hopefully, this won't take long as the game is mostly (sometimes surprisingly) stable.
Tomb Painter, Re:creation dev (abandoned, doing other things) | edw.is | @EliasDaler

argh

  • Newbie
  • *
  • Posts: 16
    • View Profile
    • my blog
    • Email
Re:creation - a top down action rpg about undeads
« Reply #322 on: October 14, 2015, 09:33:31 pm »
Right now I'm working on refactoring and making the game more playable. There were some game breaking bugs which I was okay with. Not anymore. As I work toward playable build, I have to reduce the number of bugs. Hopefully, this won't take long as the game is mostly (sometimes surprisingly) stable.

Can't wait  8)

Elias Daler

  • Hero Member
  • *****
  • Posts: 599
    • View Profile
    • Blog
    • Email
Re:creation - a top down action rpg about undeads
« Reply #323 on: October 14, 2015, 11:57:29 pm »
Can't wait  8)
I can't really promise a lot. If I'm able to finish it this year, this is going to be a miracle, ha-ha.
There's just lots of content I have to make. I want to make a good first impression, so I want a polished and awesome demo.
Hobby game dev is a long process.  :-[
(Any tips on speeding it up everyone? :D)
« Last Edit: October 15, 2015, 12:37:56 am by Elias Daler »
Tomb Painter, Re:creation dev (abandoned, doing other things) | edw.is | @EliasDaler

shadowmouse

  • Sr. Member
  • ****
  • Posts: 302
    • View Profile
Re:creation - a top down action rpg about undeads
« Reply #324 on: October 15, 2015, 08:16:09 am »
What sped up the development of my current project the most, was moving to using bitbucket and source tree. Once I got it I immediately stopped putting off doing big things in case they broke it, because I would be working on a different branch and could always switch back again, but it also seemed to increase my coding speed once I was confident that whatever I did, it wouldn't be irreversible.

Elias Daler

  • Hero Member
  • *****
  • Posts: 599
    • View Profile
    • Blog
    • Email
Re:creation - a top down action rpg about undeads
« Reply #325 on: October 15, 2015, 10:24:53 am »
What sped up the development of my current project the most, was moving to using bitbucket and source tree. Once I got it I immediately stopped putting off doing big things in case they broke it, because I would be working on a different branch and could always switch back again, but it also seemed to increase my coding speed once I was confident that whatever I did, it wouldn't be irreversible.
Currently using it! Can't really get into branching yet, because I can't work on the one independent part of the code. Most of the code I write affects other stuff, so I can't be sure that if I return there'll be no collisions. But this is just for now, because I work on the engine and fix lots of stuff. Separating systems by using events will help a lot too. :D
And when most of my job will be done by writing scripts... that's where real fun begins and stuff will go pretty fast! :D
Tomb Painter, Re:creation dev (abandoned, doing other things) | edw.is | @EliasDaler

Elias Daler

  • Hero Member
  • *****
  • Posts: 599
    • View Profile
    • Blog
    • Email
Re:creation - a top down action rpg about undeads
« Reply #326 on: October 15, 2015, 11:51:14 pm »
Here's a summary of what I've made during the last five months.
https://eliasdaler.wordpress.com/2015/10/15/recreation-dev-log-june-october-2015-theres-a-lot-of-stuff-made/
It's so good to look back and see how much of the stuff changed and improved.
Tomb Painter, Re:creation dev (abandoned, doing other things) | edw.is | @EliasDaler

Glocke

  • Sr. Member
  • ****
  • Posts: 289
  • Hobby Dev/GameDev
    • View Profile
Re:creation - a top down action rpg about undeads
« Reply #327 on: October 16, 2015, 09:02:54 am »
Glocke, yep shaders might do the trick. But I've never worked with shaders before, so this may be quite a challenge for me... Which I'll try to beat a bit later. :D

Don't hesitate to work with shaders :) Once you're in, there are lots of possibilities. As an example: When I started working on my game's lighting implementation, I had never worked with shaders before. But the result is quite great!
(example image inside spoiler, because it's offtopic somehow ^^)
(click to show/hide)
Current project: Racod's Lair - Rogue-inspired Coop Action RPG

Elias Daler

  • Hero Member
  • *****
  • Posts: 599
    • View Profile
    • Blog
    • Email
Re:creation - a top down action rpg about undeads
« Reply #328 on: October 16, 2015, 09:14:36 am »
Don't hesitate to work with shaders :) Once you're in, there are lots of possibilities. As an example: When I started working on my game's lighting implementation, I had never worked with shaders before. But the result is quite great!
(example image inside spoiler, because it's offtopic somehow ^^)
(click to show/hide)
Okay, I'll try something out. Do you know any great tutorials on GLSL? :)
Tomb Painter, Re:creation dev (abandoned, doing other things) | edw.is | @EliasDaler

Glocke

  • Sr. Member
  • ****
  • Posts: 289
  • Hobby Dev/GameDev
    • View Profile
Re:creation - a top down action rpg about undeads
« Reply #329 on: October 18, 2015, 09:44:16 am »
Okay, I'll try something out. Do you know any great tutorials on GLSL? :)
Sorry, I don't :D

But here are my shaders for rendering a sprite with some brightness and saturation (I use it for blinking animations)
sprite_shader.loadFromMemory(
        "uniform float brightness, min_saturation, max_saturation;" \
        "uniform sampler2D texture;" \
        "void main() {" \
        "       vec4 pixel = gl_Color * texture2D(texture, gl_TexCoord[0].xy);" \
        "       pixel = vec4(clamp(pixel.rgb, min_saturation, max_saturation), pixel.a);" \
        "       gl_FragColor = vec4(pixel.rgb * brightness, pixel.a);" \
        "}",
        sf::Shader::Fragment
);
and for rendering a lighttexture (which is a major part of my lighting implementation).
light_shader.loadFromMemory(
        "uniform vec2 center;" \
        "uniform float radius;" \
        "uniform float intensity;" \
        "void main() {" \
        "       float dist = distance(gl_TexCoord[0].xy, center);" \
        "       float color = exp(-9.0*dist/radius);" \
        "       gl_FragColor = vec4(gl_Color.xyz * color, 1.0);" \
        "}",
        sf::Shader::Fragment
);
Setting up the sprite_shader before rendering looks like this:
sprite_shader.setParameter("brightness", brightness);
sprite_shader.setParameter("min_saturation", min_saturation);
sprite_shader.setParameter("max_saturation", max_saturation);
sprite_shader.setParameter("texture", sf::Shader::CurrentTexture);
Prerendering a light texture is shown here:
sf::RenderTexture buffer;
buffer.create(size, size);

// prepare shadeable object
sf::VertexArray array{sf::Quads, 4u};
array[0].position = {0.f, 0.f};
array[1].position = {size, 0.f};
array[2].position = {size, size};
array[3].position = {0.f, size};
for (std::size_t i = 0u; i < 4u; ++i) {
        array[i].texCoords = array[i].position;
        array[i].color = sf::Color::White;
}

// render lightmap
buffer.clear(sf::Color::Black);
light_shader.setParameter("radius", radius);
light_shader.setParameter("center", {size / 2.f, size / 2.f});
buffer.draw(array, &light_shader);
buffer.display();
Later the resulting texture is applied to the scene using a suitable blend mode. The lighting texture is attached (so you can see the result).

Maybe those shaders can help to when experimenting.
« Last Edit: October 18, 2015, 09:52:54 am by Glocke »
Current project: Racod's Lair - Rogue-inspired Coop Action RPG

 

anything