Page 1 of 1

Problems with bitmaps

Posted: Tue Feb 14, 2012 12:52 pm
by Rado1
All issues observed on ZGE 2.0.1b (Feb 13, 2012).

- BitmapBlur and BitmapZoomRotate components have problems with larger bitmaps. Blur has problems if at least one dimension is 1024 or higher, zoom/rotate if one dimension is 512 and higher.

- BitmapDistort produces too "pixelated" results. I compared ZGE distort to tg and werkkzeug3 and they both bring much better results. Currently, instead of BitmapDistort I prefer expressions, but that's sometimes too cumbersome.

- Why tiled textures are too "pixelated" and deformed when applied to large objects (e.g. sprites) and texture scale is very large, e.g. more than 1000? I'm not sure, this is maybe problem of my GPU (ATI Radeon X1400), not ZGE itself. Do you also have the same problem? Currently, in this situations instead of RenderSprite I use RenderNet and decrease texture scaling.

See the attached example project to demonstrate the aforementioned issues.

- Why bitmap editor offers SampleExpression and SampleImport components? They can lead to unpleasant access violation exceptions, such as:
1. Add SampleExpresion to bitmap.
2. Delete it -> several access violation exceptions appear (each click in the Project tree results in an error message).
3. Save the project.
4. Open the saved project -> error.
5. Check Width and Height of bitmap in .zgeproj file - strange numbers.

Posted: Tue Feb 14, 2012 3:12 pm
by Kjell
Hi Rado,
Rado1 wrote:BitmapBlur and BitmapZoomRotate components have problems with larger bitmaps. Blur has problems if at least one dimension is 1024 or higher, zoom/rotate if one dimension is 512 and higher.
BitmapZoomRotate causes problems on my system as well. Any pixels that have a higher resolution then the viewport size in which the Bitmap is processed end up being black. Check out this demonstration. BitmapBlur however works fine on my system ( at any bitmap & viewport resolution ).
Rado1 wrote:BitmapDistort produces too "pixelated" results.
BitmapDistort doesn't do anything on my system. Not sure what it's supposed to do either though ..
Rado1 wrote:Why tiled textures are too "pixelated" and deformed when applied to large objects (e.g. sprites) and texture scale is very large
This might have something to do with the mipmap or precision settings of the ZGE OpenGL context and / or your video-card drivers. Could you post a screenshot of this?
Rado1 wrote:Why bitmap editor offers SampleExpression and SampleImport components?
They shouldn't, they are Audio components. Should be pretty easy to exclude them though.

K

Posted: Tue Feb 14, 2012 5:12 pm
by y offs et
"my GPU (ATI Radeon X1400)"

I'm running ATI Radeon X1650 and in the past we spent a lot of time debugging problems with this early generation card and ZGE.

Posted: Tue Feb 14, 2012 6:22 pm
by jph_wacheski
bitmapDistort takes two inputs the first is the image data used and the second is the distortion applied.

Try this as a basic setup;

Code: Select all

ZZDC<?xml version="1.0" encoding="iso-8859-1" ?>
<Bitmap Name="Bitmap1" Width="4" Height="4">
  <Producers>
    <BitmapNoise Octaves="4"/>
    <BitmapCells CellStyle="4"/>
    <BitmapDistort Amount="1"/>
  </Producers>
</Bitmap>

Posted: Tue Feb 14, 2012 10:40 pm
by Rado1
To explain my problems better, I'm sending you screenshots of how I see bitmaps in my example project.

Posted: Tue Feb 14, 2012 10:44 pm
by Rado1
... and here is example of strange displaying of a texture with high TextureScale; (6000.0, 6000.0, 0.0) in this case.

Posted: Fri Feb 17, 2012 11:12 am
by VilleK
In general the bitmap generators of Tg and Werkzeug are of much higher quality. In particular the ZoomRotate was one of the first components I wrote for ZGE and haven't updated it much since. Unfortunately most demoscene whizkids are reluctant to share sources so it will be difficult to match the quality of those products unless we can find reference material elsewhere.

- BitmapBlur: This does not produce any problems here. It should work everywhere because it is implemented in the CPU. Could it be a problem with the texture preview window only? Does the texture look as weird if you texture a 3d-object with it?

- BitmapZoomRotate: This works here too. But like Kjell says, it is limited to work with the desktop resolution. To avoid that I would need to rely on render-to-texture functionality which is not available on low-end laptops. Also most bitmap components would best be implemented as GPU-shaders, but again that would not work on laptops with integrated GPUs. I'm not sure how to deal with that. Maybe at one point we decide that ZGE should require GL 2.0 with shaders minimum.

- BitmapDistort: The quality could be improved if the component used bilinear interpolation when distoring the image. It was forum member Kattle who wrote that component but he left long ago so I'll see if I can update the code myself.

- Texture-scaling: I get the strange effect. I seem to remember reading that this is a problem many GPUs share, the internal texture coordinate resolution is not designed to work with such large scale so it starts to lose precision. So I would recommend trying to find an alternative to using large texture coordinate scaling.

- Sample-components visible in bitmap editor: That was a bug and is already fixed now.

Posted: Fri Feb 17, 2012 11:44 am
by Kjell
Hej Ville,
VilleK wrote:But like Kjell says, it is limited to work with the desktop resolution.
Not the desktop resolution, the viewport resolution ( which is much worse ). Check out the video.
VilleK wrote:To avoid that I would need to rely on render-to-texture functionality which is not available on low-end laptops.
You could always use the legacy / super-slow glCopyTexImage2D on systems without FBO support.
VilleK wrote:Maybe at one point we decide that ZGE should require GL 2.0 with shaders minimum.
Personally I think the fact that ( most of ) ZGE runs on bare-bone OpenGL cards is actually a big strength.
VilleK wrote:the internal texture coordinate resolution is not designed to work with such large scale so it starts to lose precision.
This is probably one of those situations where you wish you could call glTexCoord2d .. with the d from double ;)

K

Posted: Fri Feb 17, 2012 1:37 pm
by Rado1
Hi Ville, Kjell,
VilleK wrote:In general the bitmap generators of Tg and Werkzeug are of much higher quality.
Yes, but they do not provide expressions in bitmaps, just nicely configurable predefined components. ZGE is more powerful with this feature.
VilleK wrote:- BitmapBlur: This does not produce any problems here. It should work everywhere because it is implemented in the CPU. Could it be a problem with the texture preview window only? Does the texture look as weird if you texture a 3d-object with it?
If Width (independently on Height) is 2048 the produced bitmap itself is weird, not just its displaying. When I apply it as a texture or export it to a file, I got always the same strange bitmap.

Also loading a 2048 width bitmap from jpeg file produces the same weird bitmap as for blur, unless Transparency is set to BlackColor or AlphaLayer.

BitmapRect component exposes the same defect on my notebook as I previously described for the BitmapZoomRotate component.

BTW BitmapCells or BitmapExpression work correctly.
VilleK wrote:- BitmapZoomRotate: This works here too. But like Kjell says, it is limited to work with the desktop resolution.
I'm getting sad, because BitmapZoomRotate stops working on 512 width or height bitmaps on my laptop.
VilleK wrote:Maybe at one point we decide that ZGE should require GL 2.0 with shaders minimum.
I fully agree with Kjell. What about to support CPU implementations of bitmap components if a bare-bone OpenGL card is detected, else to use faster/better GL implementations? I know instead of complicated re-implementation of bitmap components in ZGE we can load bitmaps from files; but I really like small executables and computed bitmaps - that's one of my reasons for using cool! ZGE.
VilleK wrote:- BitmapDistort: The quality could be improved if the component used bilinear interpolation when distoring the image. It was forum member Kattle who wrote that component but he left long ago so I'll see if I can update the code myself.
This would be nice.

I was thinking also about a BitmapExpression with two inputs to be able to implement user-defined "binary bitmap operators". At the level of bitmap expression there would be variables such as "input1" and "input2", in addition to (or instead of?) "this". You could use them like this: input1.Pixel + input1.Pixel to produce additive combination, for instance. To allow effects such as blur or symmetry, also this.Pixel[x,y] (where x,y are floats from [0,1] and the result is pixel at given position) would help.

Posted: Fri Feb 17, 2012 5:45 pm
by VilleK
Kjell wrote:Not the desktop resolution, the viewport resolution ( which is much worse ). Check out the video.
Aha, I see what is wrong. Actually I do set the viewport to the size of the texture but it doesn't take effect because the current GL-window is the preview window and glViewport won't accept arguments that is larger than the window. I'm not sure how to fix this because I don't think I can disconnect GL from the preview window precisely when the bitmap is regenerated.
Kjell wrote:This is probably one of those situations where you wish you could call glTexCoord2d .. with the d from double ;)
I don't think it is certain the hardware won't downscale the doubles into a lower precision format anyway, so it might not help.

I also want ZGE to be backwards compatible with older OpenGL versions as far as possible. In fact I wonder what is the current minimum requirement for ZGE generated exe-files because I'm actually not sure. I would guess WinXP + GL 1.4 or something like that.

About the weird Blur-problem: Does it look the same when you generate a exe-file? And could you please post two bitmaps (using "Save to file" button), one at a lower resolution when it is working, and one with the wrong output.

Posted: Fri Feb 17, 2012 6:22 pm
by Kjell
Hej Ville,
VilleK wrote:glViewport won't accept arguments that is larger than the window.
It does actually .. but it skips any pixels that are outside the context resolution. Anyway, either you take the slower CPU route instead, or you could split the rendering process into multiple passes making each pass fit in the context resolution ( similar to how those super-HD screenshot utilities work ).

Or, simply add a note to the documentation that you shouldn't use this component on textures that are larger then the minimum resolution that you want to support :wink:

K

Posted: Sat Feb 18, 2012 4:46 pm
by Rado1
VilleK wrote: About the weird Blur-problem: Does it look the same when you generate a exe-file? And could you please post two bitmaps (using "Save to file" button), one at a lower resolution when it is working, and one with the wrong output.
Yes, the same look also for exe file. Here are the bitmaps.

Posted: Mon Feb 20, 2012 12:36 pm
by VilleK
I can't figure out what is wrong. It looks like it is not created like requested from GL, rgb float format, instead it becomes grayscale for some reason. I suppose it could be out of video memory but your card should have at least 128mb which should be enough.

Do you see any GL-error messages in the ZGE log window? Please also check for updated GL-drivers from AMD.

Any particular reason you want these highres textures? If you are looking for making a large non-repeating texture maybe another approach can be using two or more layers of lower-res textures blended on top of each other with different scaling.

Posted: Tue Feb 21, 2012 8:40 am
by Rado1
VilleK wrote:Do you see any GL-error messages in the ZGE log window? Please also check for updated GL-drivers from AMD.
No error messages appear.
VilleK wrote:Any particular reason you want these highres textures?
I have no particular reason to use highres textures in my current projects. There are usually workarounds how to avoid them. This problem was observed during testing.