Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411488 Posts in 69377 Topics- by 58433 Members - Latest Member: Bohdan_Zoshchenko

April 29, 2024, 04:14:01 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsCommunityTownhallForum IssuesArchived subforums (read only)CreativeRaytracing + sprites + normal mapping, proof of concept and request for ideas
Pages: [1]
Print
Author Topic: Raytracing + sprites + normal mapping, proof of concept and request for ideas  (Read 5330 times)
snellface
Level 0
**


View Profile
« on: March 29, 2012, 10:26:47 AM »

New video (2012-04-23):


project as .rar file: www.derpface.se/dump/2DNormalCalculator.rar (by request, not well commented, will make a clean version when i got the time)

Short less-early demo (new):


Now hardware accelerated! Wink

Short early demo (old): http://www.youtube.com/watch?v=YxmoqDCPZ6k

Last night i began coding on something i have been wanting to do for a long time, a combination of sprites + normal mapping + dynamic lights. I still have a few things to optimize (e.g. move rendering from software to hardware) and some more features to add (currently: shadow casting from a modified bump-mapping technique).



I love pixel art but being a programmer my skills in drawing are rather limited, so i figured id use some computing to compensate for it. The result is actually better then i had hoped for with the small amount of code i have written. Computing light rather then having an artist his judgement does take away some of the charm of pixel art, but i think its a fair trade-off.

Are there more people interested in this kind of technique / does anyone want source-codes / the application used to draw and render these normal maps (the actual sprite have to made elsewhere for now i'm afraid), the application is a .net windows form which (since i was lazy and did not make my own vertice representation) need xna 3.0.0.0 to run.

And is there anyone interested in making sprites using this? I want to see what people who actually know what they are doing can produce Smiley

If anyone is interested (and have a windows installation Durr...?) and wanna try, gimme a shout and i will make the latest stable .exe (and source if you are baws nerd) and some instructions for how to use the program available for download.
« Last Edit: April 23, 2012, 07:14:16 AM by snellface » Logged
Moczan
Guest
« Reply #1 on: March 29, 2012, 11:34:08 PM »

I think it's great, with clever editor I see people doing awesome in-game visuals with this kind of technique.
Logged
snellface
Level 0
**


View Profile
« Reply #2 on: March 30, 2012, 08:02:22 AM »

The editors design might not be -the- best right now, i will ask people who are better at layout design for help later on, so for now bare with me Tongue (hard at work with adding shadows, will post a download link to the editor when it's closer to being finished)
Logged
dek
Level 1
*



View Profile
« Reply #3 on: March 30, 2012, 02:00:27 PM »

I have always been thinking about this.. nice to see that someone did it! Did you draw the normal map or has it been baked?

Gonna be following this.
Logged

Schrompf
Level 9
****

C++ professional, game dev sparetime


View Profile WWW
« Reply #4 on: March 31, 2012, 07:11:48 AM »

I'm doing this in my game (Splatter). It actually works really nice, but you need to pay attention to some details. From the top of my head:

- what you're doing there is essentially a Deferred Renderer. Most of what's written in the internet about DRs also applies to this topic.

- Graphics can be both drawn and rendered. I drew quite some graphics, and for me it works best to start with the height map (I use this for shadow casting), then calculate a normal map from it, then paint a diffuse map by selecting different regions based on height and change their colours.

- When rendering graphics, watch out for background colors and semi-transparent pixels. All 3D modelling packages I know, especially 3DSMax, do render out correct alpha channels, but still blend the color with the background color. I actually built an import step to remove these blendings and I suggest you doing the same or else your graphics will end up with white/black/whatever borders

- Also watch out for mip maps - fill all transparent pixels with an appropriate color to prevent color bleeding.

- If you draw rotated sprites, use a special shader to rotate the normals when rendering normal maps.
- If you adhered to all transparent pixel suggestions above, scaling and rotating looks fabulous. Use it.
- Renormalize the normals before using it in your light calculations. It helps with interpolated normals and mipmapping.
- You can get nice special effects by restricting rendering to certain map types. For example, a blood or water splash looks cool if you just render out diffuse and specular, this the splash will use the ground's normal and height. Or the other way around: only paint the diffuse map and you'll get a nice 'predator' effect.

Good luck!
Logged

Snake World, multiplayer worm eats stuff and grows DevLog
PompiPompi
Level 10
*****



View Profile WWW
« Reply #5 on: April 01, 2012, 12:38:04 PM »

Yea, I also had this idea to make a diablo game with deferred shading. I am not sure this kind of graphics is usefull for hand drawen pixel art. It's probably more useful for pre-rendered CG(like in diablo). Then you also get the normal\height maps for free.
Logged

Master of all trades.
snellface
Level 0
**


View Profile
« Reply #6 on: April 02, 2012, 04:15:13 AM »

Thanks for the feedback

Right now this is not a deferred renderer, but i think that i will split the lumination and coloring for when i do the shadow calcultions (mainly because i think it will be easier to debug it that way, and the fact that it might be easier to write a gpu shader who do it step by step instead of doing it all in one go)

I was thinking about only making a height map and calculate normals from it, but then i decided to go with normals + height. The height map im making is a bit special Tongue.. ill post a screenshot when its done and you will see why

Been away over the weekend and now i cant wait to get home to do some more coding T_T (its been a long time since i had this urge Shocked)
Logged
snellface
Level 0
**


View Profile
« Reply #7 on: April 06, 2012, 04:30:51 AM »

New version, this one run a few hlsl shaders (directX) to increase the the FPS from 0.6 FPS (for 2 lights), to well over 60 for 100+ lights.

Both the c# and shader code is very un-optimized right now so it can be improved even more if needed/wanted. The editor is still sub-par but workable, I'll add a link to it in in the main post along with a new video posted on youtube if anyone is interested (it looks pritty much like the firest video, but with shadows and way better frame rate Smiley

The only problem right now is that you have to run a gfx card which have vertex/pixel shader 3.0 because of the way i do some calculations on the card (Could probably be improved to run on even older shader versions, but im no shader expert so this is good enough for now)
Logged
Bishop
Level 2
**


View Profile
« Reply #8 on: April 17, 2012, 11:37:00 AM »

If anyone is interested (and have a windows installation Durr...?) and wanna try, gimme a shout and i will make the latest stable .exe (and source if you are baws nerd) and some instructions for how to use the program available for download.

Sounds really interesting, I love shaders.
Logged
snellface
Level 0
**


View Profile
« Reply #9 on: April 23, 2012, 07:11:40 AM »

New video:





Project .rar:
www.derpface.se/dump/2DNormalCalculator.rar (Visual C# 2008 express)
(2DNormalCalculator\2DNormalCalculator\bin\x86\Debug\ contains .exe files aswell as all the shaders used by both this project and the game, they are highly un-optimized, badly commented and very ugly, enjoy <3) The shaders need to be compiled using fxc.exe if you change them, this is because the built in effect compiler in my xna is to old to understand the [loop] directive, and i could not get it use a newer version by itself T_T..


Pastebin url to per-light shader:
http://pastebin.com/QbRab2fE
(this shader uses only 1 height data-map, this version used in the editor and not in the game, later they will use the same)


Pastebin of the shader, its not very pretty and not very optimized, it also give shadows cast far away from an object very jagged edges (the problem is that im using a Bresenham line to get which pixels to test for light obscuration, the fix is to test each pixels "bound volum" with a real line-box intersection instead, and this would make much smoother per pixel shadow instead of the jagged stuff im getting now. I have not yet decided how to pass this data to the shader, but i guess i will be forced to generate a texture from all the objects rendered to the scene and the pass that along for the final rendering. I think i can use this data when i render the color map to check if the current pixel should overwrite the data already there, or if the current sprite is under the whatever is already there)


tl;dr:
Pastebin with the shader and a link to a full .rar with project+source for the editor. The editor (not the game thingie posted in the video), functional but is in no way finished, and some of the controls might be hard to guess. Basically most surfaces can do stuff with left/right/middle mouse button. Later versions will have better controls, aswell as tool-tips on what button does what -_-..

There are currently no undo/redo implemented

If you don't get it to work post whatever error you get and i'll see if i can make a quick fix for you until i have enough time to finalize this project.


If anyone finds anything which improves whatever, please post it here and i'll add it to the linked rar file
Logged
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic