texture coordinate flipping operation

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
ClownieTheMalicious
Posts: 28
Joined: Sun Sep 17, 2006 3:59 pm
Location: iraq

texture coordinate flipping operation

Post by ClownieTheMalicious »

hey, for the opengl driver the texture coordinates on the Render to texture target are upside down.
Now, I know i can edit the texture coordinates through the lock and unlock methods, but i only see operations for working on pixel data-
does that mean to flip these textures im going to have to change the texture matrix manually pixel by pixel?
I read all of these posts on the texture operations:
http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=18017
http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=21668
http://irrlicht.sourceforge.net/phpBB2/ ... ht=#114676
http://irrlicht.sourceforge.net/phpBB2/ ... +text+axis
http://irrlicht.sourceforge.net/phpBB2/ ... tate++text
(and many others involving RTT +the OGL/D3D texture issue).

Yet they all offer vague descriptions not really relating to my issue.
I also read the documentation on the RTT issue. AND I know I can get the texture matrix data through the material system, the problem is I don't know what to do with that information...
I guess what I'm looking for is what others have done to solve this issue-
I understand I need to flip the texture coordinates, but I don't understand the operation involved to flip them. What would the algo to flip these textures look like? Would it be a simple matter of redefining matrix values or do I have to apply the changes pixel by pixel in my code (seems inefficient to do manually)?
Or perhaps a simple buildTextureTransform()?

Thanks in advance for any advice. I know I'm asking for alot of retarded explanation, and I apologize for that, but I've been stuck here mentally and I don't know how to progress.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Try to use the following matrix as texture matrix:

Code: Select all

1  0 0 0
0 -1 0 0
0  0 1 0
0  0 0 1
'This should invert the V part of the texture coords.
Last edited by hybrid on Thu Jul 12, 2007 1:42 pm, edited 1 time in total.
omaremad
Competition winner
Posts: 1027
Joined: Fri Jul 15, 2005 11:30 pm
Location: Cairo,Egypt

Post by omaremad »

you mean y?
"Irrlicht is obese"

If you want modern rendering techniques learn how to make them or go to the engine next door =p
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

No, I meant V as in UVW. Or call it t as in s,t,r,q. Simply the 'height' coordinate which is in 2d systems often referred to as y.
ClownieTheMalicious
Posts: 28
Joined: Sun Sep 17, 2006 3:59 pm
Location: iraq

Post by ClownieTheMalicious »

so, hybrid, what you're saying is that I would multiply that matrix that you gave me by the texture matrix that i obtain from SMaterial?

so the solution would be something like


4x4matrix texmat = rendertarget->getTextureMatrix();
newTexMat = textmat * yourVtransformMat;
rendetarget->setTextureMatrix(1 or 0 or 2 or 3,newTexMat);

Is that the right idea? Or am I way off?

Am i performing the correct matrix operation, or are you saying that I merely need to set the matrix you gave me (yourVtransformMat) to the rendertarget right away:

renderTarget->setTextureMatrix(0,yourVtransformMat);


thanks for the help.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Since you have the identity matrix as default it's usually safe to assign the new matrix directly, but multiplying would be correct even for changed matrices.
ClownieTheMalicious
Posts: 28
Joined: Sun Sep 17, 2006 3:59 pm
Location: iraq

Post by ClownieTheMalicious »

hey hybrid, thanks for your help, worked like a charm.
Post Reply