how to get Pixel wold position back?

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
vectorcorpse
Posts: 86
Joined: Thu Feb 14, 2008 7:30 pm
Location: Portugal

how to get Pixel wold position back?

Post by vectorcorpse »

Hi, lets say we i have a pixel in fragment shader not necessarily a depth one and i want to recover that pixel position in world space back in the irrlicht to be processed on the CPU, but the only thing that gets out from there are images therefore clamped to the color range...
Mel
Competition winner
Posts: 2292
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Re: how to get Pixel wold position back?

Post by Mel »

You need to read the depth buffer, and transform the screen coordinates+depth back to world space via the inverse of the view*projection matrix. But, in general, try to avoid bringing things back from a shader to system memory, that is very slow.
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
vectorcorpse
Posts: 86
Joined: Thu Feb 14, 2008 7:30 pm
Location: Portugal

Re: how to get Pixel wold position back?

Post by vectorcorpse »

yes, i know how to work with the depth buffer and matrix transformation (it is the same has working with shadow mapping), i also know it is really slow to bring things from a shader to system memory, but since i don't have access to geometry shader (old graphics card) i don't have another choice, in any case i only need a really small sample of pixels, not the entire frame buffer, and my question remains, how to restore the full range of the pixel coordinates, in world space back to system memory?
Vectrotek
Competition winner
Posts: 1087
Joined: Sat May 02, 2015 5:05 pm

Re: how to get Pixel wold position back?

Post by Vectrotek »

Any "example code" on this?
vectorcorpse
Posts: 86
Joined: Thu Feb 14, 2008 7:30 pm
Location: Portugal

Re: how to get Pixel wold position back?

Post by vectorcorpse »

The only similar thing on the subject i managed to found here in the forums is this:
http://irrlicht.sourceforge.net/forum/v ... =4&t=33984
but it only mentions the shader side and not the irrlicht side on how to extract pixel world coordinates
maybe devsh can shed some light :D
Vectrotek
Competition winner
Posts: 1087
Joined: Sat May 02, 2015 5:05 pm

Re: how to get Pixel wold position back?

Post by Vectrotek »

Thanks! Il have a look!
vectorcorpse
Posts: 86
Joined: Thu Feb 14, 2008 7:30 pm
Location: Portugal

Re: how to get Pixel wold position back?

Post by vectorcorpse »

Any news/ideas?
Vectrotek
Competition winner
Posts: 1087
Joined: Sat May 02, 2015 5:05 pm

Re: how to get Pixel wold position back?

Post by Vectrotek »

Post Reply