I made somefink!

From: Mikee15 Nov 2012 19:21
To: ALL11 of 48
http://www.mikeefranklin.co.uk/3d/bishop.html

Maybe that'll work slightly better for people - although this one takes FOREVER to load, although I added a counter so you can see how long..

I guess it's time to optimize it all ;-)
From: af (CAER)15 Nov 2012 19:56
To: Mikee 12 of 48
Yeah it could probably do with some optimisation - even in Chrome on my Windows PC (which is quite a bit faster than my Mac) it still gets the CPU fan going and slows the entire browser down while it loads (which takes ages).

(and then once it's actually loaded it runs perfectly smooth at 60fps)
EDITED: 15 Nov 2012 19:57 by CAER
From: Mikee15 Nov 2012 20:42
To: af (CAER) 13 of 48
Refresh now and it should be very quick in comparison.

This is a slightly dumber version, though. For each face in the mesh it's just picking the center pixel and matching the colour of that against minecraft textures. Not ideal, but much faster. Probably good enough  for what I need.

Next I think I should make a painting tool for it, but make it so you can very very quickly just brush over big sections to change their texture, instead of having to slowly click individual blocks.
From: Drew (X3N0PH0N)15 Nov 2012 20:56
To: ALL14 of 48
(just testing)
From: Mikee15 Nov 2012 21:05
To: Drew (X3N0PH0N) 15 of 48
Colours are pretty poop..

I need to find a better way to do this.

Currently:

For every cube:

1) Get the face it represents from the original model

2) get the middle pixel of that triangle

3) change it like this:

3.1) convert to hsv
3.2) color.v += 2;
3.3) color.v = (color.v - 50) * 1.1 + 50; // make the light colours lighter, the dark colours darker
3.4) color.v = Math.max(0, Math.min(color.v, 100)); // make sure we're still in range
3.5) color.s = Math.sin(1-(Math.abs(color.s-50)/50)) * 120; // increase the saturation of colours that are 'average saturation'
3.6) color.s = Math.min(100, color.s); // put saturation back in range

4) Match the new colour against a colour from a minecraft block

5) Map the new texture onto the cube
 
From: Mikee15 Nov 2012 21:07
To: Mikee 16 of 48
I guess I need to write some kind of algorithm to 'expand' colours.

For example:

For any block, if there's no block around it with the same material being used, change the texture to the most common material of each of its neighbours.

I need to make sure I can smooth them out using tricks like that
From: koswix15 Nov 2012 21:08
To: Mikee 17 of 48

Doesn't work. How dare you not support my 7 year old laptop? :C

From: af (CAER)15 Nov 2012 21:20
To: Mikee 18 of 48
Have you timed which parts are especially slow?

(and do you know about console.time() and console.timeEnd() for sub-millisecond timing accuracy?)
From: Mikee15 Nov 2012 21:48
To: af (CAER) 19 of 48
Yeah I've used it a bit - I'll do some proper profiling soon.

I've made a few tweaks to the colour matching. The results are far better, but I've had to sacrifice a little bit of speed.

It's certainly looking better. I could still do with a bit more smoothing on the colours, but far better than it was before...

voxel2.jpg
From: af (CAER)15 Nov 2012 21:49
To: Mikee 20 of 48
You might be able to judge colour matching better if you toned that background down a bit. To medium grey, for instance.
From: Mikee15 Nov 2012 21:52
To: Mikee 21 of 48
Hmm - 45 seconds to make that, on my laptop.

This model is 180 blocks high, though, which is far bigger than you'd normally build in minecraft.

15 seconds to produce this:

voxel3.jpg
From: Mikee15 Nov 2012 21:53
To: af (CAER) 22 of 48
Good point! :)
From: Mikee15 Nov 2012 21:57
To: ALL23 of 48
Awesome!! This came out much better than I was expecting...


voxel4.jpg
From: af (CAER)15 Nov 2012 21:58
To: Mikee 24 of 48
Something like that would be absolutely gigantic in Minecraft :S
From: Mikee15 Nov 2012 21:59
To: af (CAER) 25 of 48
Haha yeah :)

You could set up a base inside it!

http://www.mikeefranklin.co.uk/3d/harpoon.html
From: Mikee15 Nov 2012 22:01
To: Mikee 26 of 48
Mind you - with the half-blocks you can get in tekkit/red power, you could have it at the same quality but far smaller
From: Mikee16 Nov 2012 10:07
To: ALL27 of 48
Made some pretty huge changes to the way it works..


http://www.mikeefranklin.co.uk/3d/bishop.html

It should now be REALLY fast in comparison - about 10 seconds

Edit: It seems to depend on how much memory you have available. On lower specs it seems to stop at ~80% and start crawling. If you have enough memory it does it all verrry fast.
EDITED: 16 Nov 2012 10:26 by MIKEE
From: Mikee16 Nov 2012 11:14
To: Mikee 28 of 48
http://www.mikeefranklin.co.uk/3d/goblin.html

:D


Gotta find some new models now..

I realised that my thing only works with a single texture at the moment, too. I need to change it to support multiple textures.. :)
From: Mikee16 Nov 2012 15:54
To: ALL29 of 48
Now improved so it still works if you have multiple textures on a model...

http://www.mikeefranklin.co.uk/3d/dragon.html

(the Dungeon Defenders ancient dragon has a texture on his head and a texture on his body)
From: Drew (X3N0PH0N)16 Nov 2012 16:00
To: Mikee 30 of 48
Works like a charm here now.