Page 1 of 1

[WIP] Skybox Solution

Posted: Sun Dec 23, 2012 4:09 am
by pferguso
I thought I would share a video of a skybox solution I came up with. It's not perfect, and there are a few bugs that I will need to look at, but preliminary tests show promise.

So basically, this is handled by creating two skybox assets. One skybox will be a decoration, and the other a projectile. They may or may not share the same model, but its easier if you use two, because the projectile skybox will have to ride above the ground slightly during player movement.

So the idea is that you spawn the skybox decoration right on the party. The skybox model itself is a huge piece that spans across several squares. When the party moves, you kill that skybox, and launch a skybox projectile starting on the tile the party is on, and have it travel in the direction that the party moves. After the time it takes the party to move to the next square, you kill the projectile and spawn the decoration where the party is standing again.

There are several problems I am currently facing here. One is that the projectile has to travel at the exact same speed as the party, and sometimes the party members are encumbered, making them travel slower. So logic must be put in place to compensate for that.

Another issue is that there is a maximum view distance, and then the skybox will get clipped by the renderer. So you must limit your skybox size to go like 10 squares or so at maximum.

Lastly, there must be some logic that prevents the projectile skybox from launching if the player hits a wall, blockage, altar, or monster. I currently have it only checking for walls.

Anyhow, I hope this gets some other people thinking about improving this implementation.

if I could appeal to Petri's good graces, what would be useful is some sort of event I can get when the player arrives on the tile he is moving to. (where he actually comes to a stop) because working with timers is an imperfect solution, and depending on what is going on in the game, you could get mixed results. Actually what would be even better is a way to retrieve the party's tile offset, and a way to change a decoration's tile offset. Then I could make the decoration match the party's exact position at all times, and not have to use projectiles.

Screenshot 1:
http://cloud-2.steampowered.com/ugc/596 ... 21F908729/

Video:
http://youtu.be/518q4QTzRUE

Re: [WIP] Skybox Solution

Posted: Sun Dec 23, 2012 5:13 am
by Komag
That looks very cool! Maybe the orange sunlight on the mountain seems off with it snowing though, but that's just a detail

Re: [WIP] Skybox Solution

Posted: Sun Dec 23, 2012 9:47 am
by Arkos
The video is awesome! We need this in the open community project - Legend of Grimrock World viewtopic.php?f=14&t=4553 Perfect for when you are in the Dearthfang Ridges, making your way to Grimrock mountain and other remote dungeons in this mountain range! I’ve been following your work; very impressive!

Re: [WIP] Skybox Solution

Posted: Sun Dec 23, 2012 10:54 am
by Diarmuid
I have a getCollisionAhead function in the new version of exsp I've just released. Here's the code (that includes some exsp specific calls, modify if you wish to use it), check the reference guide for details:
SpoilerShow

Code: Select all

function getCollisionAhead(arg1, arg2, arg3, arg4)
	

	local sId, level, x, y, facing
	if type(arg1) == "string" then
		sId, facing = arg1, arg2
		if findEntity(sId) == nil then
			level, x, y = sd[sId].level, sd[sId].x, sd[sId].y
		else
			level, x, y = getPosition(sId)
		end
	else
		level, x, y, facing = arg1, arg2, arg3, arg4
	end

	if facing == nil then
		facing = sd[sId].facing
	end
	local dx, dy = getForward(facing)
	local monsters = {}
	
	-- Check for entities on current tile
	
	for i in entitiesAt(level, x, y) do
		if grimq.isDoor(i) and i:isClosed() and i.facing == facing then
			return 'door', nil, i
		end
		if (i.class == 'Alcove' or i.class == 'Button' or i.class == 'Decoration' 
			or i.class == 'Lever' or i.class == 'Lock' or i.class == 'Receptor' 
			or i.class == 'TorchHolder') and i.facing == facing then
			return 'wall', i.class, i
		end
		if i.class == 'Monster' then
			table.insert(monsters, i)
		end
	end
	
	-- Check for entities on next tile
	
	for i in entitiesAt(level, x+dx, y+dy) do
		if grimq.isDoor(i) and i:isClosed() and (i.facing+2)%4 == facing then
			return 'door', nil, i
		end
		if i.class == 'MonsterGroup' then
			-- return 'monsterGroup', 'Group', i
		end
		if i.class == 'Monster' then
			table.insert(monsters, i)
		end
		if i.class == 'Party' then
			return 'party', nil, i
		end
		if i.class == 'Blockage' or i.class == 'Crystal' then
			return 'object', i.class, i
		end
	end
	if isWall(level, x+dx, y+dy) then
		return 'wall', nil, nil
	end
	if #monsters > 0 then
		return 'monster', nil, monsters
	else
		return false, nil, nil
	end

end

Re: [WIP] Skybox Solution

Posted: Sun Dec 23, 2012 3:45 pm
by Leki
I have this solution more that 2 months but you can use it only for night, because there is not "stable" lightsouce in the game (or I dont know solution for that yet). If you have blue sky and sunlight - you can see noising of lightsource - it's shame:

Code: Select all

cloneObject{
	name = "party",
	baseObject = "party",
	onMove = function(self, dir)
				outdoor = true
				
				local dx, dy = getForward(dir)
				local skybox_x, skybox_y = self.x + dx, self.y + dy
				local party_x, party_y = self.x + dx, self.y + dy
				
				--print("party location: ", "X=", party_x, "Y=", party_y, "MoveDir=", dir)				
				--print("skybox location: ", "X=", skybox_x, "Y=", skybox_y)
				
				if outdoor == true then
					-- destroy old skybox
					skybox_sky:destroy()
					--skybox_sun:destroy()
					-- create new skybox
					spawn("skybox_sky", self.level, skybox_x, skybox_y, 1, "skybox_sky")
				--  spawn("skybox_sun", self.level, skybox_x, skybox_y, 1, "skybox_sun")
				end
			end,	
}

you can download model for skybox here:
http://www.ulozto.net/xKayazG/leki-vill ... here-model
its a special "pseudo-sphere", designed for maximum distance and visibility -7 to +7 sqares and visible
for blue sky you have to use bluesky textures with opacity from 25% to 100% - it's for smooth cuting of distant objects.

- we can improve this solution with smooth movement of skybox model - like "spell of telekinessis" is moving items.
- there is not solution for collision and skybox will move one step far in the way of the move.
- I designed my medieval city streets in special way to remove negative aspects of this solution and it works good. I will public some video (medievall city wallset is not finished yet)
- you have to use "more sunlights - code included sun object, but ingame it does not look good - moving of shadows etc. Sou you have to place sun objects "smartly" in the scene

Re: [WIP] Skybox Solution

Posted: Sun Dec 23, 2012 7:08 pm
by pferguso
Hi Leki, I am already using a sphere for my sky domes, I should have mentioned. Also, Petri recently added a new property to the Lightsource, called "flicker" which can be set to false. This should fix your sunlight problem.

I tried the telekenesis trick, but I didn't get the result I wanted because the skybox as an item would appear in weird offsets for me, and I only had control of it within a given square. Keeping it an Item, but moving it using shootProjectile allowed me to have control over its offsets and a party hook onProjectile hit prevents it from overshooting the party during movement.

I really appreciate the help, and I'll have a look at your model. Mine is already the maximum size for distance though.

Thanks to everyone else for the comments. The skydome shown in the video was a quick and dirty one, and I intend to make some better ones.