gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS development > HDR rendering - is it possible

#78193 - omaremad - Wed Apr 05, 2006 9:50 pm

Ok ok... you may think im mad trying to run HDr on a ds but it wont be real hdr(one that calculates luminisoty and such from any scene using logs, Just tone mapping, bloom)

i have coded Hdr in glsl and it seems quite easy to do on a ds in frame buffer mode

i was wondering if the following can be done

render 3d scene to a rambank

take that image captured convert to an array of pixels that can be manipulated

redump manipulated data to final screen

please share ideas

this may end up as a proof of concept ala bumpmapping gba demos

#78206 - tepples - Wed Apr 05, 2006 10:51 pm

Rendering 3D to a RAM bank will require a ridiculous amount of texture memory for frame buffering, and the DS has about two-thirds of 1 MB. How much VRAM did the video card that you used to code "Hdr in glsl" have?
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#78208 - DekuTree64 - Wed Apr 05, 2006 11:02 pm

Yeah, basically you'll lose 2 128KB banks for double buffering (display one while you capture and edit the other), and doing operations on every pixel will eat up a huge amount of CPU time.

A guy made a bloom effect demo a while back that managed to run at 60fps, although his technique required 3 VRAM banks (so only 128KB left for textures). Not too practical for any in-game use, but cool for a little demo effect.
_________________
___________
The best optimization is to do nothing at all.
Therefore a fully optimized program doesn't exist.
-Deku

#78269 - bluescrn - Thu Apr 06, 2006 8:39 am

omaremad wrote:

i was wondering if the following can be done

render 3d scene to a rambank

take that image captured convert to an array of pixels that can be manipulated

redump manipulated data to final screen

please share ideas

this may end up as a proof of concept ala bumpmapping gba demos


Something like this?:

http://forum.gbadev.org/viewtopic.php?t=7983&highlight=bloom

:)

#78282 - omaremad - Thu Apr 06, 2006 12:45 pm

Thanks guys for the help

(btw that hdr i wrote was for pc on a 128mb gfx card)

There is one problem though in my understanding of the vram juggling


ok
Vram a is used for ship texture ( wiki says it has max of 128kb)
vram b is used for layering the bg (unmodified)
vram c
vram d

bothe are blended with vram b i think?
i plan on using this in my game since 128kb is more than enough for my textures, however would i have 256 of memory for the other screen?

some places they say that vram a has 128kb while others say 256kb

im really confused bteween bank a and core a vram

#78303 - omaremad - Thu Apr 06, 2006 4:32 pm

ok i sniffed around the forums and found an explaination to the diffrent size reports, it seems that 2d modes merge 2 rambanks to form 256kb for each screen

what would i have to do so i can have this hdr running with 256 kb for the 2d core.

would dropping the fps to 30 free up more memory?

another solution is to use frambuffer mode for the other screen (for 2d graphics) yet i dont know which rambanks this requires


i would be quite happy with 30 fps i just dont understand how the vram is dealt with in this demo.

There isnt an clear cut info on the vram...
1-how much does a simple frambuffer(bitmap) mode fullscreen would take from the vram?
2-are textures only allowed in vram a
3-i dont understand the need of frambuffer c and d in the bloom demo, why not use one and blend with the realtime 3d rather than filling a whole bank wit "unmodified data"

i would be very grateful for answers

#107224 - Payk - Fri Oct 27, 2006 8:20 pm

You dont need to do that for a bumpmapping...
Whatch this one:
[Images not permitted - Click here to view it]

#107227 - dovoto - Fri Oct 27, 2006 9:16 pm

Looking good payk

Here is a memory map and description that may make things clearer:
[url]
http://www.dev-scene.com/NDS/Tutorials_Day_2#Memory_Layout[/url]
_________________
www.drunkencoders.com

#107366 - omaremad - Sun Oct 29, 2006 1:05 am

lol payk i was talking about high dynamic range rendering (fake though).

Nice pic, did you do something like the following to make it work?

To locate the world coords of the texel being lit you use the coords of the vertices that make the polygon that the texture is mapped on and the ratio describing the location of the pixel in 2D space.

Like this:
Height ratio=pixelY \ TexturesizeY
Width Ratio=pixelX \ TexturesizeX

mult the above ratios by the repeat value of the texture on that face (uv coords per face) then mult again by the vector connecting the vertices(vertical edges by the y ratio and vice versa) to get the 3d location of the pixel on the plane that is vertical facing the camera
pixel.

Of course this above algo is the linear algebra equivilent of multiplying by the tangent space matrix for every face.

Then the normal map can be used to provide the extra normal data(rgb,xyz repectively) the normals would have to be transofmed by multiplying the normal pixels with the face normal.

the rest is just intensity = dot product of the lighting vectors.

To improve that picture you could do parallax mapping by:
calculate the heightmap of the texture by adding the RGB of the pixel being processed,
new texcoord=heightVector * eyeVector + oldTexCoord
the new texcoord could be used to shift the pixels before being sent to the vram and thus you would get an illusion of depth in the same way 2d parallax works.

Bumpmapping is irrelevant in this thread just start a new one to show it, you just keep talking about your lighting techniques werever im around (this happened in an other forum).

And yes i know about shaders and lighting, infact i know HLSL,GlSL and cg and the assembley for dx and ogl gpu programs and i m currently wrtting a document about my shading techniques, which may interest you.(work in progress)

omaremad.gdlib.net/doc.pdf

Its nothing personal but i just got annoyed by the irrelevancy of the post.

#107416 - Darkflame - Sun Oct 29, 2006 2:27 pm

Irrelevant maybe, but still very impressive, if its real.
Its like bump-mapped runescape :p
_________________
Darkflames Reviews --
Make your own at;
Rateoholic:Reviews for anything, by anyone.

#107419 - kusma - Sun Oct 29, 2006 3:44 pm

In our latest gba-demo, "Who's Your Favorite Clown", we did some kind of HDR-rendering on the gba. What we did was storing all palettes in 16bit per component, and then we could do just the tone-mapping on that. To find the exposure of the scene, we did some jittered samples around in the framebuffer, and low-pass filtering the result. Finally, a bloom effect was drawn on top of the frame-buffer using multiplexed sprites with additive blending.

#107440 - Payk - Sun Oct 29, 2006 6:59 pm

Quote:
this may end up as a proof of concept ala bumpmapping gba demos

^^just wanted to say that this could be wrong way to bumpmapping :D
Just wanted to show that you should wonder for what effects u would need hdr, and if there would be a much easier way to do that effect...

Regulary u can forget all bumpmapping on nds...there could be some techdemos done...i am pretty sure it wont be usefull for a game...
what i hv done is much simpler...but u will need to code dynamic lights and and a way to use more texturelayers to get such a result...i dont use hardware lights...othervice i would have to rotate normals in dirrection of lights and could use 4 lights max...no dotlights at all....

Well that thing is a mix between a simple bumpmapping and a specualr map...it doesnt care perspective or viewport... Different texturelayers get different lights...thats all :D

Sorry for anyoung you, but maybe u didnt get to which part of the post i answered...that happens often if topics are gettling long...Sorry maybe it would have been better if i would had quotet that first...

Quote:
Irrelevant maybe, but still very impressive, if its real.
Its like bump-mapped runescape :p
My engine/game often was compared to runescape...I dunno if thats good or not ;P
If you arent sure if its real you can watch it running on nds at youtube:
http://youtube.com/watch?v=YJaKQ8lKpR8
A downloadable versions isnt aviable yet, since i need to bumpspec other things, too

#107467 - omaremad - Sun Oct 29, 2006 10:34 pm

Wow the video is impressive indeed.

Sorry about my agressiveness but i usually get provoked by the 3 dots lol
Quote:

PostPosted: Fri Oct 27, 2006 7:20 pm Post subject: Bumpmapping
You dont need to do that for a bumpmapping...


It just seemed weird to have an answer about bumpmapping when the thread is about HDR and the 3 dots made it seem that the whole discussion was useless.

#107504 - Payk - Mon Oct 30, 2006 9:20 am

Ahh sorry for that.
I think i use that dots to often :D
No it wasnt meaned like that.
Its an interesting topic, and i hv no experiance with hdr at all.
it was interesting to read for me. Its just to bad that we cant acces the 3d output image directly.it costs to much vram for my favor.
Anyway its possible to map the 3d-pal somehere else. Maybe it would then just cost a main vrambank to capture .you would be able to set some other banks together in order to hide current scene. I think webez made somehing like that already.

#107518 - M3d10n - Mon Oct 30, 2006 2:00 pm

There might be a way to do it without eating so much VRAM. Splinter Cell DS did some intensive screen buffer manipulation for the night vision and heat vision while using a fair number of textures on screen at once. The framerate was nasty, though.

#107519 - Darkflame - Mon Oct 30, 2006 2:30 pm

True HDR on the GP2X
http://www.apex-designs.net/payback_gp2x_report.html


Obviously, they got quite a bit more power to play with ;)
_________________
Darkflames Reviews --
Make your own at;
Rateoholic:Reviews for anything, by anyone.

#107536 - omaremad - Mon Oct 30, 2006 5:17 pm

Viewtiful joe ds used 2 screen rendering and non repeating textures (allot) which always amazes me, maybe they used compressed textures?

#107545 - silent_code - Mon Oct 30, 2006 7:18 pm

this is a bit off topic, i know, but guys, if you capture video with a camera, !!!PLEASE!!! use the makroscope mode! otherwise the whole thing will be blurred (like payk's very nice demo video)!

#107551 - tepples - Mon Oct 30, 2006 8:34 pm

Tell me when it's available in North America.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#107562 - Payk - Mon Oct 30, 2006 10:23 pm

I know paykback from gba...it was impressive (for a gba ;) )
but this one is fantastic...
And yes, i know my movie is blured...its a bad digicam. I just can focus manualy when using it in picture mode :( sorry

And yeah, i guess splintercell did something like that.
Maybe framerate was bad because it was a bad port from n-gage.
But that nightvision-mode was amazing

#107564 - omaremad - Mon Oct 30, 2006 10:43 pm

well to implement night vision you would have to have the normal vertex to be involved like so:

Take the normal of the vertex in question (the transformed normals so we have to repeat some T&L stuff on the cpu :( )

draw a ray from the vertex to the camera, dot product that ray with the normal then adjust the vertex colour so that a the RGB values are proportional to the dot product in deiffrent ways: if red is directly proportional the blue is inversely.

Its gonna be slow but quake and doom had software lighting so its possible.

#107581 - Payk - Tue Oct 31, 2006 2:36 am

Wow^^Whata genius...Yeah that makes sence :)
Cool i will store that in my deepest mind for later...
Hehe Thanx :D

#107583 - omaremad - Tue Oct 31, 2006 3:40 am

Heheh thanks, whats it is doing is seeing which faces point away from the viewer these faces are more likely to be on the edges of the heated body if you are rendering closed and hollow meshes.

I guess you can figure out the manual transform calculations since you programmed for the psp.

vertex colour (dot,dot/0.5,1/dot)


yet again my method is awfully slow, why not try smoothed toon shading(smoothed + toon table with heat vision colours) with the a light pointing at the object being rendered (light is at cam pos)

This way there are no dot products or cpu transoforms needed.

Remember to keep us updated with demo's. :)

#107610 - Payk - Tue Oct 31, 2006 1:49 pm

I coded for psp? or did u meaned somebody else?
Anyway...You may know the indexed normals of md2.
162 normalized vectors in a lut.
Seems to be enough...well if u crate a function which seraches that lut for most matching withh given one i would have an idea...
U can create a lut which includes dotproduct of these normals...
162*162*8bit(result)...about 25KB for results...
So lets say u throw a ray to char...u would normalize and search in anormtable for best matching normal...with that number u can then look in the 25KB-LUT instead of doing a dot product....
I am not sure about precision...but i am sure about performance :)
Best would be if you would find a way to trow a normal instead a ray...normalizing needs performance, too (i guess ;P )...

#107639 - M3d10n - Tue Oct 31, 2006 7:46 pm

I'm aware Splinter Cell DS probably used a gradient texture mapped using TEXGEN_NORMAL or something similar for models in heat vision, but the most impressive is the full scren blur effect which goes along it:

http://media.ds.ign.com/media/729/729102/img_2847740.html

Night vision also uses blur:
http://media.ds.ign.com/media/729/729102/img_2847735.html