# Noname 2.5 Shooter (Open source)

**URL:** <https://forum.defold.com/t/noname-2-5-shooter-open-source/57417>\
**Category:** Dev diaries\
**Created:** [July 12, 2019, 10:45pm UTC](https://forum.defold.com/t/noname-2-5-shooter-open-source/57417 "2019-07-12T22:45:21Z")\
**Posts on this page:** 20\
**Page:** 3

<div class="post-metadata">

**Author:** ![d954mas](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/d954mas/32/5401_2.png) [@d954mas](https://forum.defold.com/u/d954mas)\
**Post date:** [May 27, 2020, 9:52pm UTC](https://forum.defold.com/t/noname-2-5-shooter-open-source/57417/41 "2020-05-27T21:52:19Z")

</div>

> [@Pkeod](#):
>
> You could move the particles to a single render predicate / render target, which is then drawn last.

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

 ![2020-05-28_00-44-31](https://forum-defold-uploads.b-cdn.net/original/3X/d/3/d364bec070866621e3c52adfe7466709bd6b8fe0.png)

---

<div class="post-metadata">

**Author:** ![Pkeod](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/pkeod/32/606_2.png) [@Pkeod](https://forum.defold.com/u/Pkeod)\
**Post date:** [May 27, 2020, 9:57pm UTC](https://forum.defold.com/t/noname-2-5-shooter-open-source/57417/42 "2020-05-27T21:57:48Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![d954mas](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/d954mas/32/5401_2.png) [@d954mas](https://forum.defold.com/u/d954mas)\
**Post date:** [May 27, 2020, 10:03pm UTC](https://forum.defold.com/t/noname-2-5-shooter-open-source/57417/43 "2020-05-27T22:03:40Z")

</div>

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.

```lua
 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 =)

---

<div class="post-metadata">

**Author:** ![roccosaienz](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/roccosaienz/32/19991_2.png) [@roccosaienz](https://forum.defold.com/u/roccosaienz)\
**Post date:** [May 27, 2020, 10:43pm UTC](https://forum.defold.com/t/noname-2-5-shooter-open-source/57417/44 "2020-05-27T22:43:21Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Pkeod](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/pkeod/32/606_2.png) [@Pkeod](https://forum.defold.com/u/Pkeod)\
**Post date:** [May 27, 2020, 10:50pm UTC](https://forum.defold.com/t/noname-2-5-shooter-open-source/57417/45 "2020-05-27T22:50:50Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![d954mas](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/d954mas/32/5401_2.png) [@d954mas](https://forum.defold.com/u/d954mas)\
**Post date:** [May 27, 2020, 10:51pm UTC](https://forum.defold.com/t/noname-2-5-shooter-open-source/57417/46 "2020-05-27T22:51:45Z")

</div>

Thanks. Yes.  
1)Particles not blend with each other. Looks like they rendered in bad order.(video [Noname 2.5 Shooter (Open source) - #36 by d954mas](https://forum.defold.com/t/noname-2-5-shooter-open-source/57417/36))  
2)In that case, alpha of other object, break particle render.(screenshot [Noname 2.5 Shooter (Open source) - #41 by d954mas](https://forum.defold.com/t/noname-2-5-shooter-open-source/57417/41))

---

<div class="post-metadata">

**Author:** ![roccosaienz](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/roccosaienz/32/19991_2.png) [@roccosaienz](https://forum.defold.com/u/roccosaienz)\
**Post date:** [May 27, 2020, 11:04pm UTC](https://forum.defold.com/t/noname-2-5-shooter-open-source/57417/47 "2020-05-27T23:04:42Z")

</div>

@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?

---

<div class="post-metadata">

**Author:** ![d954mas](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/d954mas/32/5401_2.png) [@d954mas](https://forum.defold.com/u/d954mas)\
**Post date:** [May 27, 2020, 11:12pm UTC](https://forum.defold.com/t/noname-2-5-shooter-open-source/57417/48 "2020-05-27T23:12:22Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![roccosaienz](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/roccosaienz/32/19991_2.png) [@roccosaienz](https://forum.defold.com/u/roccosaienz)\
**Post date:** [May 27, 2020, 11:15pm UTC](https://forum.defold.com/t/noname-2-5-shooter-open-source/57417/49 "2020-05-27T23:15:57Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![d954mas](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/d954mas/32/5401_2.png) [@d954mas](https://forum.defold.com/u/d954mas)\
**Post date:** [May 27, 2020, 11:28pm UTC](https://forum.defold.com/t/noname-2-5-shooter-open-source/57417/50 "2020-05-27T23:28:04Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![d954mas](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/d954mas/32/5401_2.png) [@d954mas](https://forum.defold.com/u/d954mas)\
**Post date:** [June 6, 2020, 11:56am UTC](https://forum.defold.com/t/noname-2-5-shooter-open-source/57417/51 "2020-06-06T11:56:12Z")

</div>

Update html build on [itch](https://d954mas.itch.io/noname-25d-shooter).  
So everyone can play last version=)

1)Continue working on weapon.  
All 4 weapons, have a shoot animations and sounds(temp assets)  
First weapon(uzi).Have projectiles.

2)Added tint for weapon.(thx @jhonny.goransson for advice=))  
It used light color, from near cells of player. Color mixed with weights depends on distance to player.

```lua
	if (not self.camera) then
		self.camera = native_raycasting.camera_new()
		self.camera:set_rays(16)
		self.camera:set_fov(math.pi * 2)
		self.camera:set_max_dist(1)
	end
	--use 9 near cells to count weapon color
	--if use only current, weapon blink when change cell
	self.camera:set_pos(self.world.game.player.position.x, self.world.game.player.position.y)
	local neigbours = native_raycasting.camera_cast_rays(self.camera, true)
	local colors = {}
	local total_weight = 0
	for _, neigbour in ipairs(neigbours) do
		if (not neigbour:get_blocked()) then
			local r, g, b = native_raycasting.color_rgbi_to_rgb(neigbour:get_color())
			local dist = vmath.length(vmath.vector3(neigbour:get_x() + 0.5, neigbour:get_y() + 0.5, 0) - vmath.vector3(self.world.game.player.position.x, self.world.game.player.position.y, 0))
			local weight = 1 / dist
			total_weight = total_weight + weight
			table.insert(colors, { r = r, g = g, b = b, weight = weight })
		end
	end
	local r, g, b = 0, 0, 0
	for _, color in ipairs(colors) do
		local mul = color.weight / total_weight
		if(color.weight == math.huge) then mul = 1 end
		r = r + color.r * mul
		g = g + color.g * mul
		b = b + color.b * mul
	end
	local color = vmath.vector4(count(0.4, r), count(0.4, g), count(0.4, b), 1)
	sprite.set_constant(WEAPON_URL, "tint", color)

```

[https://forum-defold-uploads.b-cdn.net/original/3X/f/8/f875f73d99ceba5ee08b55ac70899153737d4997.mp4](https://forum-defold-uploads.b-cdn.net/original/3X/f/8/f875f73d99ceba5ee08b55ac70899153737d4997.mp4)

Changes:  
1)Added particles in 3d. They worked ok, but have some limitations.  
2)Added tint for weapon.  
3)Added temp assets for weapons(shoot animation and sounds)  
4)Added bullet entity  
5)Hide debug light object by default(it can be enabled from debug panel)

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [June 6, 2020, 12:32pm UTC](https://forum.defold.com/t/noname-2-5-shooter-open-source/57417/52 "2020-06-06T12:32:17Z")

</div>

> [@d954mas](#):
>
> Update html build on [itch](https://d954mas.itch.io/noname-25d-shooter).

Unable to test it right now ☹ (I believe itch is suffering from the super mega 1000+ games bundle they launched in support of the BLM movement.)

---

<div class="post-metadata">

**Author:** ![d954mas](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/d954mas/32/5401_2.png) [@d954mas](https://forum.defold.com/u/d954mas)\
**Post date:** [June 6, 2020, 12:38pm UTC](https://forum.defold.com/t/noname-2-5-shooter-open-source/57417/53 "2020-06-06T12:38:27Z")

</div>

Worked 30 minutes ago=)  
For me itch also not worked

---

<div class="post-metadata">

**Author:** ![Pkeod](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/pkeod/32/606_2.png) [@Pkeod](https://forum.defold.com/u/Pkeod)\
**Post date:** [March 9, 2021, 10:22am UTC](https://forum.defold.com/t/noname-2-5-shooter-open-source/57417/54 "2021-03-09T10:22:48Z")

</div>

Looks like you have the debug version uploaded and not the release version?

---

<div class="post-metadata">

**Author:** ![d954mas](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/d954mas/32/5401_2.png) [@d954mas](https://forum.defold.com/u/d954mas)\
**Post date:** [March 9, 2021, 10:58am UTC](https://forum.defold.com/t/noname-2-5-shooter-open-source/57417/55 "2021-03-09T10:58:14Z")

</div>

It should be debug. With disabled gl checks.

Frezze in Chrome?

---

<div class="post-metadata">

**Author:** ![Pkeod](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/pkeod/32/606_2.png) [@Pkeod](https://forum.defold.com/u/Pkeod)\
**Post date:** [March 9, 2021, 11:02am UTC](https://forum.defold.com/t/noname-2-5-shooter-open-source/57417/56 "2021-03-09T11:02:11Z")

</div>

Yes, very slow in Chrome. Why have Debug version live?

 ![5d%20shooter%20by%20d954mas](https://forum-defold-uploads.b-cdn.net/original/3X/5/b/5b087c8c7fbb7c09bd87b01e174bfad214152225.png)

---

<div class="post-metadata">

**Author:** ![d954mas](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/d954mas/32/5401_2.png) [@d954mas](https://forum.defold.com/u/d954mas)\
**Post date:** [March 9, 2021, 12:32pm UTC](https://forum.defold.com/t/noname-2-5-shooter-open-source/57417/57 "2021-03-09T12:32:04Z")

</div>

In debug, i can see logs)

---

<div class="post-metadata">

**Author:** ![d954mas](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/d954mas/32/5401_2.png) [@d954mas](https://forum.defold.com/u/d954mas)\
**Post date:** [March 9, 2021, 12:32pm UTC](https://forum.defold.com/t/noname-2-5-shooter-open-source/57417/58 "2021-03-09T12:32:49Z")

</div>

I will look.

---

<div class="post-metadata">

**Author:** ![Pkeod](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/pkeod/32/606_2.png) [@Pkeod](https://forum.defold.com/u/Pkeod)\
**Post date:** [March 9, 2021, 12:51pm UTC](https://forum.defold.com/t/noname-2-5-shooter-open-source/57417/59 "2021-03-09T12:51:50Z")

</div>

Try a release build and see how it changes performance?

---

<div class="post-metadata">

**Author:** ![d954mas](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/d954mas/32/5401_2.png) [@d954mas](https://forum.defold.com/u/d954mas)\
**Post date:** [March 9, 2021, 12:58pm UTC](https://forum.defold.com/t/noname-2-5-shooter-open-source/57417/60 "2021-03-09T12:58:47Z")

</div>

Nope.i will check that verifygl is disabled. And Also check Chrome)

[Previous page](https://forum.defold.com/t/noname-2-5-shooter-open-source/57417.md?page=2)

[Next page](https://forum.defold.com/t/noname-2-5-shooter-open-source/57417.md?page=4)
