Horde3D

Next-Generation Graphics Engine
It is currently 21.11.2024, 23:59

All times are UTC + 1 hour




Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: 23.06.2010, 00:06 
Offline

Joined: 22.06.2010, 19:21
Posts: 26
I want to create this effect with dynamically loaded sprites:
Image

What would be the most efficient way to achieve this in Horde3D? I want to have dozens of those objects on screen, with full lighting and casting correct shadows. Could this be achieved with just the 2D texture of the sprite on a single quad and some fancy displacement/geometry shader? Or is it not that simple?

I have never worked with Horde3D/shaders before and am unsure how to start here. ;)

The worst case would obviously be to do it by hand and create individual cubes for every pixel. :/


Top
 Profile  
Reply with quote  
PostPosted: 24.06.2010, 04:41 
Offline

Joined: 15.02.2009, 02:13
Posts: 161
Location: Sydney Australia
Hi johannes,

Looking at what you would want to achieve, it might be best to just add code to extrude mesh so you'd need to edit horde3d internals, or add the enhancement as an extension would probably be the best solution. You could do it on the cpu as well, so the geometry shader wouldn't be mandatory (horde doesn't support geometry shaders at this time).

Another idea, you might be able to get a similar effect by just playing around with the parallax shader and just make a quad which is bigger than the sprite so the silhouette doesn't get cut off. Real-time shadows wouldn't work properly however, but this might be the easiest solution I'd say because you would only edit shader code (for tweaking the effect).

A brute-force technique could be that you just have an array of cubes and use a texture look-up in the vertex shader to displace those cubes, a bit like how the terrain extension works. Way too expensive I'd say.

Cheap n' nasty: Could you just have like a crapload of quads overlapping each other out like some hacky parallax effect? That could work depending on camera angles + shadows might work.

_________________
-Alex
Website


Top
 Profile  
Reply with quote  
PostPosted: 24.06.2010, 11:54 
Offline

Joined: 22.06.2010, 19:21
Posts: 26
Thanks for the reply, MistaED. :)

MistaED wrote:
Looking at what you would want to achieve, it might be best to just add code to extrude mesh so you'd need to edit horde3d internals, or add the enhancement as an extension would probably be the best solution. You could do it on the cpu as well, so the geometry shader wouldn't be mandatory (horde doesn't support geometry shaders at this time).

I did this on Irrlicht. I would just load the texture with a quad for every pixel, delete all transparent pixels and make cubes out of the remaining ones. After that I could use some math trickery to join cubes that touch to lower the polycount. This created mesh could then be instanced.
The thing is though, this is rather brute force and is only a small step away from just creating individual pixel cubes.
I somehow had hoped that Horde3D had some fancy feature for stuff like this. :? Geometry shaders are OpenGL3.0 exclusive, so they are out. Or are they? Did anything ever happen to this?

MistaED wrote:
Another idea, you might be able to get a similar effect by just playing around with the parallax shader and just make a quad which is bigger than the sprite so the silhouette doesn't get cut off. Real-time shadows wouldn't work properly however, but this might be the easiest solution I'd say because you would only edit shader code (for tweaking the effect).

Nice idea! :) I wouldn't mind the shadow only being from the 2D texture.
But since I have a rotating camera, the sprites would be invisible to the player from the side. Unless I billboard them. But then the shader wouldn't work, I guess. :(


Top
 Profile  
Reply with quote  
PostPosted: 24.06.2010, 13:06 
Offline

Joined: 22.11.2007, 17:05
Posts: 707
Location: Boston, MA
Another approach would be to render it as a volume sprite, treating the current sprite as a 3D texture of depth 1. Details on the technique here: http://www.antisphere.com/Research/VolumetricBillboards.php

_________________
Tristam MacDonald - [swiftcoding]


Top
 Profile  
Reply with quote  
PostPosted: 24.06.2010, 15:27 
Offline

Joined: 22.06.2010, 19:21
Posts: 26
swiftcoder wrote:
Another approach would be to render it as a volume sprite, treating the current sprite as a 3D texture of depth 1. Details on the technique here: http://www.antisphere.com/Research/VolumetricBillboards.php

That is a great technique, but I am not sure how it can be applied here. :oops: Isn't that technique used to render 3D objects with sprites? I on the other hand have a sprite and want to turn it into a super simple 3D object by adding a 3D border around it and giving it depth.


Top
 Profile  
Reply with quote  
PostPosted: 25.06.2010, 01:43 
Offline

Joined: 08.11.2006, 03:10
Posts: 384
Location: Australia
I would probably do this with a tool that takes sprites and produces models (i.e. do it when building your game, not at runtime).

Do you need to be able to do it at run time, e.g. the players can import their own sprites?


Top
 Profile  
Reply with quote  
PostPosted: 25.06.2010, 02:14 
Offline

Joined: 22.11.2007, 17:05
Posts: 707
Location: Boston, MA
johannes wrote:
swiftcoder wrote:
Another approach would be to render it as a volume sprite, treating the current sprite as a 3D texture of depth 1. Details on the technique here: http://www.antisphere.com/Research/VolumetricBillboards.php

That is a great technique, but I am not sure how it can be applied here. :oops: Isn't that technique used to render 3D objects with sprites? I on the other hand have a sprite and want to turn it into a super simple 3D object by adding a 3D border around it and giving it depth.
It is a way to render 3D objects contained in a sprite. In their case, a 3D sprite, but you can treat a 2D sprite as extruded in the z-axis, and thus reach the exact result you demonstrated at the beginning of the thread.

DarkAngel wrote:
I would probably do this with a tool that takes sprites and produces models (i.e. do it when building your game, not at runtime).
I would be a little concerned about the number of polygons in a geometry-based approach. You are looking at ~25,000 triangles for a 128x128 sprite - certainly not insurmountable, but might be an issue if you plan to have many sprites onscreen at one.

_________________
Tristam MacDonald - [swiftcoding]


Top
 Profile  
Reply with quote  
PostPosted: 25.06.2010, 15:35 
Offline

Joined: 22.06.2010, 19:21
Posts: 26
Thanks for the input guys! :)

I decided to go the parallax shader route for now and later I will replace it with this:
Create a single quad for the front and a mirrored one for the back, texturize it. Then go over the borders of the sprite and manually lay a black mesh around every pixel which is then extruded. It is not what I originally wanted, but it is <500 triangles and I hope it will turn out okay anyways. ;)

DarkAngel wrote:
Do you need to be able to do it at run time, e.g. the players can import their own sprites?

Yes. Otherwise I would just go with proper models. :)

swiftcoder wrote:
It is a way to render 3D objects contained in a sprite. In their case, a 3D sprite, but you can treat a 2D sprite as extruded in the z-axis, and thus reach the exact result you demonstrated at the beginning of the thread.

Gotcha. :) I will use this as a fallback, if the black border thing does not turn out so well.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group