Save shelter (old school fps) #CoronaDefoldJam

I am trying to make 3d game like wolfenstein 3d. Now i am making prototype and have some problems. never working with 3d before, so some question can be stupid :slight_smile:

1)I spawn a lot of models(wall) and get:

Model could not be created since the buffer is full (128)

Can i change model buffer size?

2)Is it bad for perfomance to spawn all models for level? I have raycasting and can spawn only visible models, but it need additional work.

3)I am using 3d camera. What is camera width and camera height? Is it 1x1?

4)I have some artifact with wall. See video and screenshot. What is it and how it can be fixed?

3 Likes

In game.project you can add some of these lines to increase desired limits:

[factory]
max_count = 256

[collectionfactory]
max_count = 256

[model]
max_count = 1024

[rig]
max_instance_count = 1024

Is artifact wall is a real wall that becomes visible behind the front one?
Do you constantly changing walls position/orientation on camera movement?

4 Likes

thx, add lines to game.project, all work :slight_smile:

Look like that. I add lines to render script and now it working.

render.enable_state(render.STATE_DEPTH_TEST)
render.set_depth_mask(true)

No i only move camera.

2 Likes

One more stupid question :slight_smile:
The world is in 3d.
I am trying to add ‘sprites’ to world. That is not real sprite it game object with model and script.
script rotate go:

function update(self, dt)
	go.set(".","euler.y",player.rot * 57.2958)
end

model contains texture with alpha.

All work correct but sometimes alpha on model is broken.Why this can happened?


Doesn’t look like alpha issue, but buffer maybe. Can you set a texture or a pattern on the ground?

Also I find euler rotations to be buggy, use quaternions. That alone might work.

2 Likes

Test wrapping rotation between 180 and -180 to see if it solves euler angle problems? If you put this project on github I’ll tinker and maybe contribute some improvements.

-- Wrap an angle between -180 and +180
function wrap_angle(angle)
	if angle > 180 then
		angle = M.wrap_angle(angle - 360)
	elseif angle < -180 then
		angle = M.wrap_angle(angle + 360)
	end
	return angle
end
1 Like

Not help.

I don’t understand what is it,look too complicated but i read and try them later :slight_smile:

Video with pattern on ground.


I will think about that :slight_smile:

What’s the material of the Defold icon sprite set to?

1 Like

Standart model with few changes

I guess that’s z-buffer or stencil buffer random glitch. Maybe if you tinker around your render script you can find the problem. That’s definitely not texture being black instead of transparent. That’s the ground not being rendered behind the sprite.

1 Like

Also take a look at my TankVsMeteors example, maybe you can find something useful.

1 Like

Thx, i look on it, render looks the same.

No idea. All looks correct.I will look on it tomorrow.

function update(self)
    render.set_depth_mask(true)
    render.set_stencil_mask(0xff)
    render.clear({[render.BUFFER_COLOR_BIT] = self.clear_color, [render.BUFFER_DEPTH_BIT] = 1, [render.BUFFER_STENCIL_BIT] = 0})
    
    render.enable_state(render.STATE_BLEND)
    render.set_blend_func(render.BLEND_SRC_ALPHA, render.BLEND_ONE_MINUS_SRC_ALPHA)
    
	--draw 3d walls
    render.enable_state(render.STATE_CULL_FACE)
    render.enable_state(render.STATE_DEPTH_TEST)
    
    render.set_depth_mask(true)
    render.set_view(self.view)
    render.set_projection(self.projection)
    render.draw(self.wall_pred)
    render.disable_state(render.STATE_CULL_FACE)  
    render.disable_state(render.STATE_DEPTH_TEST)
    render.set_depth_mask(false)
    
    --draw sprites without camera
    render.set_projection(vmath.matrix4_orthographic(0, render.get_width(), 0, render.get_height(), -1, 1))
    render.set_view(vmath.matrix4())
    render.draw(self.tile_pred)
    render.draw(self.particle_pred)
    render.draw_debug3d()
    render.draw_debug2d()
	

    render.set_view(vmath.matrix4())
    render.set_projection(vmath.matrix4_orthographic(0, render.get_window_width(), 0, render.get_window_height(), -1, 1))
	
	
    render.enable_state(render.STATE_STENCIL_TEST)
    render.draw(self.gui_pred)
    render.draw(self.text_pred)
    render.disable_state(render.STATE_STENCIL_TEST)

    render.set_depth_mask(false)
    render.draw_debug2d()
end

So walls are wall_pred and the sprite is tile_pred?

2 Likes

Thx, you realy help. I was using same material for sprite and for wall. Now i use separate materials and tags. And it work

	render.draw(self.wall_pred)
	render.draw(self.sprite_pred)
1 Like

Check that sprite can be hid by a corner of a wall. That is it’s not just drawn over the walls all the time.
If I was making it, I’d really make walls and the sprites the same objects, and just call them model_pred.

2 Likes

The prototype of game was done. You can move in 3d world, and shoot defold logo. :grinning:
The next week i will be focused on game concept.
I want make o rogue like game in space setting with guns,robots, and psionic. Something like one more dungeon but in space.
html demo

9 Likes

This is nice! I’m looking forward to following the progress of this game.

You can use the Pointer Lock API to lock the cursor to the canvas. HTML5 Native Extensions should make it possible.

This game was made with ImpactJS, and may have some good ideas to learn from http://phoboslab.org/xibalba/ http://phoboslab.org/log/2014/07/xibalba-a-webgl-first-person-shooter

3 Likes

I do not approve of this.

Jokes aside, what you have so far looks very cool! Really looking forward to following this game :slight_smile:

4 Likes