Help with texture size of rendered video texture?
Blitz3D Forums/Blitz3D Programming/Help with texture size of rendered video texture?
| ||
Hi all. I'm currently working on my game again & would like to know how to make the size of all 3 of these render textures the "same size" as the meshes they are on in ALL resolutions. Here's the code so far: Thank You & have a great day! ~GF |
| ||
I can't execute the example but I would guess checking the CreateTexture flags. 16 is Clamp U only, either use 16+32 for U+V or dismiss 16, try this: tex1 = CreateTexture(w,h,1) tex2 = CreateTexture(w,h,1) tex3 = CreateTexture(w,h,1) |
| ||
Tried just now, but unfortunately the scale of the texture is not the same size as the "cube plane" it's textured on. It must remain the same size as the "cube plane" on ALL resolutions. Here's what I have so far: Thanks alot, Krischan! =) |
| ||
I think your percentage calculation is wrong as it produces results > 1 and you use ScaleTexture. What is this code for? |
| ||
It's a video to texture code. However, I need the ability to take a simple plane-shaped cube, and resize the texture to fit that "screen" perfectly in all resolutions. |
| ||
Hmm I would resize the mesh to fullscreen instead and don't care about texture coordinates. Here is a quick fullscreen sprite example, you can change the resolution and it will be always fullscreen (don't caring about aspect ratio in this example): Edit: if you use Graphics3D 800,600,32,3 you can resize the window to see the effect in realtime. |
| ||
Thanks, @Krischan. Is there a way I can texture that texture to a "cube plane"? (A cube resized to 1, 1, 0.001). EDIT: Here's what I have so far: |
| ||
With Blitz3D you can do everything :-) But a cube resized to 1,1,0.001 is much like a quad and a quad is like a sprite. So why do you want to use a cube? It's easy to convert the code to use a cube instead, but I don't understand what you want to achieve finally? |
| ||
Thanks alot, Krischan! =) You're a great mentor! I'm basically trying to achieve the goal of stretching the texture according to what size the 3D cube-plane is. So if I change it to ScaleEntity 10, 10, 10, the texture size would also be 10, 10, no matter WHAT screen resolution basically. |
| ||
Perhaps a picture would help.![]() |
| ||
Do you see the black area due to the texture's size being too small? THAT'S what I'm trying to fix in all resolutions. |
| ||
What size/resolution are the source videos? Always the same? |
| ||
Uh, 512x512 I think. But I want it no matter what resolution, to span the entire mesh cube-plane. that's pretty much it. Thanks again, Krischan! =) |
| ||
A texture should be 2^n x 2^n size. If not it becomes stretched to the next 2^n size in video memory on loading as far as i remember. So a weird 345x487 image should become a 256x512 or 512x512 texture in video memory that the GPU can handle it. When I load such an image as a texture and put it straight on a simple cube it stretches seamless to all UV edges - distorted but without empty areas. It gets autostretched as long as you don't use the ScaleTexture command. What do you mean with "to span the entire mesh cube-plane"?!? Sorry, but I don't understand your problem even after 8 posts... ![]() |
| ||
Uh, 512x512 I think. You need solid information, not guesses. If you watch the video in a movie player is it square? If it really is square then it already fits a cube exactly without any scaling of anything. This is unrelated to screen dimensions. If the video is not square then it can't possibly fit a square ( the side of a cube ) without distortion or cropping. Are you sure that black bar isn't built into the video after it is rendered to the texture? If the texture is square and the video has, say, 4:3 aspect ratio then bars at the top and bottom are what you expect. You could check this by running your program until the movie is playing and is being, somehow, applied to the texture. Then view the texture as an image, so you know what's really in there. Something like this: ClsColor 60,60,0 Cls img = CreateImage( TextureWidth(tex), TextureHeight(tex) ) CopyRect 0,0, TextureWidth(tex),TextureHeight(tex), 0,0, TextureBuffer(tex),ImageBuffer(img) DrawBlock img, 50,50 Flip WaitKey Once you know what is happening with the video and texture you can worry about scaling. |
| ||
It's approximately 512x342. And yes. I am sure there is no black bar in the video itself. I just checked. |
| ||
Where did you check? If the video is about 3:2 aspect ratio and it goes onto a 512x512 texture then there is some distortion/cropping or there are black bars. I mean in the texture, not the original video. That's why I suggest looking at the texture as an image. Find out what it really looks like. |
| ||
I checked in windows media player. And it's 512x342, not 512x512. my bad, lol :P |
| ||
That probably means the texture is 512x512. So the next step is see how the video gets put into the texture. That's what my code snippet does. |
| ||
testing your code snippet now. |
| ||
See, the thing is. I'm using the SE_Blitzmovie to allow for the texture to be a movie as opposed to a regular texture. Using this code, how would I use your code snippet correctly? EDIT: Link to SE_BlitzMovie: http://blitzbasic.com/Community/posts.php?topic=100408 |
| ||
Try adding this to the main loop. If KeyHit(57) ; spacebar ClsColor 60,60,0 Cls img = CreateImage( TextureWidth(tex1), TextureHeight(tex1) ) CopyRect 0,0, TextureWidth(tex1),TextureHeight(tex1), 0,0, TextureBuffer(tex1),ImageBuffer(img) DrawBlock img, 50,50 Flip Repeat Until KeyHit(57) ClsColor 0,0,0 Cls FreeImage img EndIf Then tapping the spacebar will pause the program and let you look at the texture. Tapping spacebar again will resume. It is untested since I'm not running your code. |
| ||
Ok, here's what happened when I pressed space: ![]() |
| ||
That's not anything I would have guessed. So what is it, two video frames on a texture with room for six? And why is each frame about three times wide as high? I would have expected it to be half that wide, or twice as high. Unfortunately I know nothing about how SE_Blitzmovie works. |
| ||
Well, if you try it above, it has everything ready to go. Just drag & drop the DECLs into the userlibs folder. |
| ||
Okay, here's a cut down example. The idea is the movie is about 1.5 times as wide as it is high. So the texture is scaled to be 1.5 times as high. Now visual width and height are equal and it fills a square. Of course the image is distorted from its original shape. The cube is scaled vertically by 1/1.5 putting it visually back the way it was. I included untested code for the case of video width less than height, although I've never seen such a thing. |
| ||
Floyd, it's BEAUTIFUL! With just a little tweaking, I was able to accomplish thanks to you, what I have been trying to do for the past week & and a half! Thank you SO MUCH, Floyd! :) For those of you who wish to install the DECLs into the userlibs folder and try this demo, here it is! Thanks once again, Floyd & Krischan, and enjoy the demo! ~GF |