Noname 2.5 Shooter (Open source)

It looks really cool! Good job!

3 Likes

that is right. it is cool :sunglasses:

3 Likes

It looks awesome! How is the lighting calculated? It would be really cool to add a normal map to the weapon and do the same evaluation there, so it blends a bit better with the game. Anyway, good job!

4 Likes

Thanks.
Good idea.:+1:
It looks better with tinted weapon.
I use current tile color for that tint.
But when i move it change colors, to fast and blink.
I will try add some interpolation or add near cell colors, to tint calculation.

Light calculation is simple.
It is a tile based light.

Color consist of two parts, static and dynamic.
Tile always have a static base color from level editor.
Also tile have a array with dynamic lights from light sources.


(Here you can see static colors)
Light sources use rays to find tile, that needs color.
Also the light brightness depends on distance to tile.

To get tile result color, all colors is mixed with additive blend.
Then i draw that lights colors, to texture.
And in shader mixed sprite color with that light color

This map have a very dark static color.
There is a light map texture, on the left
Also light map texture, updated only for visible cell.

7 Likes

I started looking through the source to see what you did with rendercam, and wow, it looks like you’ve done a ton of work on this to bypass Defold’s built-in systems, controlling your own update order…a different physics engine via Native Extension, etc…pretty cool. ‘go.get_position()’ is only used three times in the whole project :smile: (twice in rendercam & 1 other time). I never would have considered doing all this. It seems like your own engine built on top of Defold.

7 Likes

Trying to add particles in 3d.

But particles can’t blend with each other.(depth test problem)
If i disabled depth test for particles. It blend with each other ok. But
have problems with other objects.
Any ideas, how to fix?
render script

function Render:render_3d()
	if (not self.targets.light_map) then return end
	local camera = CAMERAS.current

	render.set_viewport(camera.viewport.x, camera.viewport.y, camera.viewport.width, camera.viewport.height)
	render.set_view(camera:get_view())
	render.set_projection(camera:get_proj())

	render.enable_state(render.STATE_DEPTH_TEST)
	render.set_depth_func(render.COMPARE_FUNC_LEQUAL)

	render.enable_texture(1, self.targets.light_map, render.BUFFER_COLOR_BIT)

	render.set_depth_mask(true)
        --no transparent
	render.draw(self.predicates.wall, self.constants_buffers.light_map)

	render.enable_state(render.STATE_BLEND)
	render.set_blend_func(render.BLEND_SRC_ALPHA, render.BLEND_ONE_MINUS_SRC_ALPHA)

	render.disable_state(render.STATE_CULL_FACE)
        --all objects with transparent. Walls,enemies,objects, particles.
	render.draw(self.predicates.transparent3d, self.constants_buffers.light_map)

	if CONSTANTS.DEBUG.draw_physics then render.draw(self.predicates.debug_physics) end
	render.draw_debug3d()

	render.disable_state(render.STATE_DEPTH_TEST)
	render.enable_state(render.STATE_CULL_FACE)
	render.set_depth_mask(false)
	render.disable_texture(1)
end
5 Likes

Maybe draw all particles to a render target without depth test, and then depth test with that render target? Or use depth to mask.

1 Like

No. In that case every new particleFX will need new render target.

What is depth to mask?

You could move the particles to a single render predicate / render target, which is then drawn last. I’m not sure on specifics, would need to make a test project, but something like that should be possible.

1 Like

What is your desired effect? You could render them last without depth test to overlay them on top of everything else, but I’m guessing you are looking for something specific?

Thanks. I try that before. In that case, particles draw correct with each other. But not with other objects.

1 Like

We need depth but it’s still not supported. I’m not sure how else to do this other than maybe draw everything’s depth in another pass yourself, but it would double your draw calls.

Edit: I’m not even thinking right, those objects only draw depth for their vertexes but they don’t discard the depth for the transparent pixels. I’m not sure what to do in this situation, it might still be possible as
is composting multiple passes together.

1 Like

The idea was to use particles for blood, fire or sparks.
For now i am testing can i use them or not.

And i see some problems when mix depth and alpha.
Not sure that they can be fixed.

For my cases i can add discard to particle shader.

 if(spriteColor.a < 0.01){discard;}

It add some restricrions to particles visual. But i think it will be enough in my situation.

But if someone have ideas, how to do it better. I will be grateful =)

2 Likes

Maybe I don’t understand the problem… Have you tried the following?

  1. draw all objects with depth test and depth write both enabled

  2. draw all the particles (with add or alpha) with depth test enabled but with depth write disabled.

Probably this is too simple and I have missed something.

1 Like

The problem is that sprites are simple quad faces which write their depth as a quad and not a transparent sprite.

3 Likes

Thanks. Yes.
1)Particles not blend with each other. Looks like they rendered in bad order.(video Noname 2.5 Shooter (Open source))
2)In that case, alpha of other object, break particle render.(screenshot Noname 2.5 Shooter (Open source))

@d954mas: 1. I don’t understand why, they should if you don’t write to depth buffer (and use alpha or add)

@pkeod and @d954mas 2: Can discard be added to sprite if alpha is below some threshold?

1 Like

1)I am also, do not understand)

2)Not sure.I have a idea, for some transparent windows in game, which also will be break particles.

I think it better to use case 1 and add discard for particles in shader.

I don’t understand what is case 1… Let me rephrase my proposal. Here 1 and 2 are steps and not alternatives.

First

  1. draw all sprites with depth test and depth write enabled, use discard if the fragment has very low alpha.

Then
2. draw all particles with depth test enabled and depth write DISABLED.

Hope this is somehow clearer. Or there is something I don’t understand in your reply… sorry, my english is not that good!

EDIT: if particles look non-overlapping then probably there is some issue in the code and you have not disabled depth write. Perhaps Defold re-enables it…

1 Like

Sorry. That cases was in my head))
1)Case 1.
Draw all transparent objects, sprites, particles and etc. With depth read and write.
Add discard in particles shader.

2)Case 2.
That you describe here.
Draw transparent objects, sprites.
Add discard in their shader.
With depth read and write.

Draw particles. With depth read.

In case 1. I can’t use alpha in particles.(alpha that not discard, for example 0.5)

In case 2. Particles worked. But transparent window walls(alpha 0.5) will be break particles render.

For me it better to use case 1)

1 Like