Amiga.org
Operating System Specific Discussions => Amiga OS => Amiga OS -- Development => Topic started by: kas1e on March 05, 2005, 06:33:48 AM
-
Hi 2 all. I want to draw part of my picture as texture. But i want to do it as 1:1, without any intropalation/etc.I tryed to disable all warp3d states (dithering,gouraud,etc), but in any case i do not have 1:1 color scheme. Here is a 2 screenshoots.
1. It is original picture, and WritePixelArray do it good (but too slow of course). (http://sager.org/test/writepixelarray.jpg)
2. It is the same picture, but draw as texture (fast, but ugly).
(http://sager.org/test/texture.jpg)
Well, i want to draw this pict as texture, but in original format (as WritePixelArray). It is possible i hope ? If yes, plz, explain me what states i must be enable/disable.
Thanks all for advance answers.
-
I guess you are using a voodoo 3000 (or similar)? If this is the case, you are out of luck for true colour textures. They will be converted to 16-bits per pixel by the fastest means possible.
Score 1 to the Permedia2 which renders 32-bit textures perfectly well on 15/16/32-bit targets.
-
Yes, here is voodoo3 3000.. So, only way is creating 16bit picts and using W3D_A4R4G4B4 in W3D_AllocTexObj fucntion ?
-
You could try hinting to the driver to use "nicer" texture quality. However, I don't know if the voodoo3000 actually supports 32-bit texel data at all.
-
Karlos wrote:
You could try hinting to the driver to use "nicer" texture quality. However, I don't know if the voodoo3000 actually supports 32-bit texel data at all.
I thought the reason why 3DFx died was because the Voodoo range of cards suffered from terrible 3D image quality, when compared with the nVidia and ATI cards.
-
The later cards definately support 32-bit rendering, both for target surfaces and for texel data.
I think the voodoo3000 might have been the last of the 16-bit only chips.
The last generation voodoos to appear were both surprisingly powerful rasterizers, had decent render quality as well as some features not seen elsewhere at that time. They also supported multiple GPU rendering. However, nobody really wanted to spend a fortune on a 6-GPU card by then when it was clear that existing CPUs couldn't keep them fed fast enough. By this point NVidia and ATI were making T&L hardware that simply removed that existing bottleneck, giving much better overall performance.
-
-
@Cymric
WritePixelArray() is a function provided by CyberGraphX (IIRC, it isn't provided by the OS) that takes a pointer to some chunky pixel data (in a typical ARGB32, RGB24 or 256-colour "CLUT") format and writes it to a RastPort.
The hardware pixel format of the underlying BitMap is understandably device specific, so WritePixelArray() does conversion of the data where needed. Unfortunately (as I discovered a long time ago) this function (as well as BlitBitMap between different pixel formats) are rather slow.
What kas1e is trying to do instead is to take his 32-bit source data and use it as a warp3d texture map instead.
The reason for this is that 3D hardware can generally take colour conversion in its stride, mapping a 32-bit source texture to a polygon on any supported 15/16 bit screen, dithering it, processing transparancy, shading it (in a variety of ways), scaling it, filtering all with total hardware acceleration that leaves the equivalent OS/CyberGraphX/P96 routines (where they even exist) eating dust.
Unfortunately, it seems the voodoo3000 only wants to use 16-bit texel data, so kas1e's 32-bit source data is being pre-converted by the driver.
-
to Karlos
i tryed use W3D_HINT, and played with all params, but here is no any good result. Maybe do you know some software for convert 32bit pict to 16bit for A4R4G4B4 ?
-
kas1e wrote:
to Karlos
i tryed use W3D_HINT, and played with all params, but here is no any good result. Maybe do you know some software for convert 32bit pict to 16bit for A4R4G4B4 ?
Photoshop is pretty good at that.
-
kas1e wrote:
Yes, here is voodoo3 3000.. So, only way is creating 16bit picts and using W3D_A4R4G4B4 in W3D_AllocTexObj fucntion ?
The Voodoo 3 does not support anything but 16 bit render targets and 16 bit textures. Only the Voodoo 4/5 can actually do 32 bits.
The only additional quality improvement you could do is to enable dithering (or change the graphics card, but that is probably not what you would want to hear :-) )
-
well, how i can exactly do it ?:) i trying to found any mode for 4bit per pixel, but only 8bite minimum is here. And if i saved any pict as tiff, png, etc, in any case i have 8bit per pixel.
-
@ kas1e
If you don't need the alpha channel, you can us W3D_R5G6B5. Still not as good as 24 bit, but definitely better than 4 bit per color.
Only the Voodoo 4/5 has support for 32 bit textures, and only the OS4 Warp3D driver will support it (sorry).
-
You should all bow to the superiority of the Permedia2
/ducks
-
Alpha channel need it for me.. Actually, my problem is it:
i want to do alpha fade/out with 24bit picture. If i can't
to do it directly on voodoo3, maybe here is way like:
1. creating 'black screen as textures'
2. draw picture by WritePixelArray.
3. draw black screen with alpha 0, and change alpha in loop
to 1. and we have alpha fade out.
but what about alpha fade in ? i mean it must be like this:
user run programm, and watch black screen. And 24bit picture fade in. Some delay, and picture fade out.
any idea ?:)
-
Just use the vertex colours to perform the fade.
Let's assume you can get a nice RGB565 format texture made in an art package and properly dithered to that depth.
Use that texture on a white polygon with W3D_MODUALTE as your texture environment. The vertex colour is then multiplied by the texture colour. Since the vertex colour is white, you get your original texture colour unmodified.
However, the vertex alpha colour is also included in the process if you have W3D_BLENDING enabled. For basic alpha blending, set the blend mode source and destination factors to W3D_SOURCE_ALPHA, W3D_ONE_MINUS_SOURCE_ALPHA respectively.
Now, you can render your rectangle each frame and progressively increase the alpha component to make your image more and more opaque.
-
Alternatively, to make a simple fade to any colour from the picture:
Draw the picture with the OS routines to get it on screen. To fade the image out, you can render a 75% transparent (using the vertex alpha again) polygon on top (no texture needed this time, just the vertex colour).
In this case, you don't clear the frame each time, just put another almost transparent layer of colour on it each time and over successive frames they will completely replace the image.
-
"Let's assume you can get a nice RGB565 format texture made in an art package"
what name of art package which can allow to me create R5G6B5 picts ?
btw, if i will using OS function (WritePixelArray) to draw pict on screen, i will see as slow draw my pict. So, for fade-out is ok, but not for fade-in ..
-
The fade I was talking about in the second post was fading from the image to a colour (so yes, a fade out).
For creating your images there are a few ways. One of them is to simply view your image in multiview with the maximum dithering and stuff turned on for a 16-bit screen and then simply grab the window with cybergrab or something. Make sure you save your grab as iff or png (something lossless) and then load it into any old 24-bit package, crop as needed (if needed) and save it off. Of course it will be saved directly as 24-bit data even though there are only 16 meaningful bits for each pixel.
Another way is to use PaintShop Pro (or whatever) on the PC which has the option to dither from 32/24-bit to 15 or 16 bit colour. It will still save as 24-bit in the same way.
Ideally you should write a small tool to then convert this 24-bit data to raw 16-bit data for your application (dropping the extra unused bits) but even if you load the data as 24 bit and it gets converted to 16-bits again, it only contained 16-bit colour resolution anyway; it's just a bit less efficient than being able to load the 16-bit data directly as a source for your texture.
-
Hi all agayn :) I try to write some stuff with bvision and voodoo3 support, and have some problems with it .. On bvision i _CAN'T_ do
W3D_SetBlendMode(context, W3D_SRC_ALPHA, W3D_DST_ALPHA);
I check all W3D_QUEREs and ENV_BLEND for bvision do not work, as MIPMAPPING. But mipmapping is not problem, but ENV_BLEND it is big problem ..
Under voodoo3 it works fine. So..I do not have bvision for tests, and do not know where is a problem and how i can do it the same as on voodoo3 .. So, i must write here and talk about it with peoples, and try to write virtual stuff :)
Btw, maybe here is any way for emulate by warp3d library unsupported blend_modes states ? I mean use hardware drivers, use all states which can be doit by hardware driver, and for unsupported states use software driver ?
-
kas1e wrote:
Btw, maybe here is any way for emulate by warp3d library unsupported blend_modes states ? I mean use hardware drivers, use all states which can be doit by hardware driver, and for unsupported states use software driver ?
Not easy and likely a very big performance hit.
-
Permedia2 only offers normal alpha blending (W3D_SRC_ALPHA, W3D_ONE_MINUS_SRC_ALPHA). There is another blending mode based on some apple model, sort of an additive blend but it doesn't actually conform to any GL ones and ergo is not really supported.
-
Thanks Karlos, will try to rewrite all with W3D_SRC_ALPHA, W3D_ONE_MINUS_SRC_ALPHA.
-
@Kas1e
Only do that it if it makes sense for your application, of course. This mode gives you basic alpha channel based transparency. However it is also about the lowest common denominator - pretty much all supported cards on W3D offer it.
If this is not whant you need, you might find you can change your texture data in some way to achieve the effect you are after.
-
@Karlos
I am already rewrite my little code with only 2 poor scenes with W3D_SRC_ALPHA, W3D_ONE_MINUS_SRC_ALPHA, for first scene (fade in/out of picture) it just work as for my voodoo3 settings, so 2 minuts of change, for second scene i was little tired with photoshop, but in end i create normal bitmap with no colors in background and can use one_minus_src_alpha. Also i remove mipmapping seetings . Well, will try to test it today/tommorow, hope no more new differens :)
-
hi karlos.
tests give to me strange result :) i handled all return values of all w3d funcs (except drawtriangles and lock/unlock hardware), and .. all is good. All states setup correctly, textures loading is good too. But! I have only this:
15 bit = black screen, music (but here is 2 scene)
16/24 = black color of my textures!
Well .. maybe bvision do not support A8R8G8B8 texture modes ?
Or work bad with auto_tex mapping ? Or must be set mipmapping
option to 0xffff (but bvision can't mipmapping as i know).
-
For the BVision:
Dont use MIP maps at all when you allocate the texture objects. It shouldn't hurt but it doesnt do anything anyway.
Make sure that your vertex colours are set up correctly too.
As for textures, it definately supports A8R8G8B8 (and A4R4G4B4), it's the voodoo3000 that has to convert this into A4R4G4B4.
Ensure that all your blending modes etc are set up in advance of any rendering too. Make sure you aren't blending your texture with a black polygon too (for W3D_MODULATE)!
If you want me to examine your code, email it to me and I'll try to check the problem out.
-
Hm .. i little fear about 'black polygon'. I hope black screen it is only black screen, and alpha will work with it too ? And yes, i use W3D_SetTexEnv(context, tex, W3D_MODULATE, NULL)..
So, my steps is it:
1. I fill screen with black color by ClearDrawRegion.
2. I set MODULATE and BLEND(with mode).
3. Try to draw pict .. and .. it's sad but i think bvision think that black color of screen it is black texture and just can't blend with it ? but why ?
Anyway, i send code to you, check it plz, maybe you can found somethink here .. Thanks.
edit: hm, it works on voodoo3 without MODULATE too. Maybe W3D_DECAL best way ? or just unused W3D_SetTexEnv .. (it is not very need it for me anyway, and i think mostly stuff can be done without it).
edit2: btw, if i disable GOURAUD state, i have on voodoo3 the same as for bvision (but with gouraud and modulate) - black color of textures.
edit3: i remove MODULATE from code, and test on bvision agayn. BLACK COLOR AGAYN :))
-
Ok, Karlos already help me with this problems. Problems is little buggy permedia2 driver (?). But, anyway, i want to up old question about dithering on voodoo3.
So (Rogue,EntilZha do you here?), voodoo3 chip can only 16bit targets/textures. But, it is possible to use Dithering. So, fitst question:
What ditherting method is used in warp3d 4.2 drivers ?
Average dithering ? Floyd-Steinberg dithering ? ordered dithering or random dithering ? or somethink other ?
Second question:
What do it warp3d voodoo3 driver with 32bit data to convert it to 16bit ? Just drop older 4 bits or what ?
And third, and also very interesting question:
Why, if i enable W3D_Dithering state in my programm, nothink happened, and image draw with the same ugly color artefacts as with no enabled W3d_dithering state ? Fuction just do not work or i must setup somethink more ?
Thanks all for answers.
-
Ok, time to up warp3d talks ;) Thanks to karlos for lot of help, but i have new question: have warp3d4.2 somethink like 'color-key' in old directx ? I mean i want do somethink like this: i draw texture, but all color which i setup by somethink warp3d fuction just do not draw. For example i have black background with sprite. And want draw all, except black color.
it is possible by w3d 4.2 ?
-
kas1e wrote:
Ok, time to up warp3d talks ;) Thanks to karlos for lot of help, but i have new question: have warp3d4.2 somethink like 'color-key' in old directx ? I mean i want do somethink like this: i draw texture, but all color which i setup by somethink warp3d fuction just do not draw. For example i have black background with sprite. And want draw all, except black color.
it is possible by w3d 4.2 ?
See the docs / W3D_SetChromaTestBounds(W3D_Context* context, W3D_Texture* texture, ULONG lower, ULONG upper, ULONG mode)
This function allows you to set a range of colours (both defined as 32-bit ARGB values). If you set the lower range as 0x00010101 and the upper limit as 0xFFFFFFFF and the mode to W3D_CHROMATEST_INCLUSIVE, then any texel that isn't black will be rendered.
Of course, unless you are doing something complex already with alpha, the simplest thing to do would be to use the alpha channel of the texture to dictate which parts of your sprite are opaque.
-
thanks ! i ask about color keys becouse i want to draw some text as textures, and want to use rgb565 mode, so no alpha.
edit: chromatest is works :)
-
but agayn chip war, or i am just stoopid man :) So, in docs about cromatest said:
res = W3D_SetChromaTestBounds(context, texture, lower, upper, mode)
lower - lower bound. This is a 32 bit RGBA value.
upper - upper bound. This is a 32 bit RGBA value.
mode - chroma test mode
The following values are possible:
W3D_CHROMATEST_NONE disable chroma testing
W3D_CHROMATEST_INCLUSIVE texels within the specified range pass
the test (i.e. get drawn)
W3D_CHROMATEST_EXCLUSIVE only texels outside the specified range are drawn, others are rejected.
So, as i understand if i want _DO NOT DRAW_ black color, i must be just use :
W3D_SetChromaTestBounds(context, texture, 01010100, ffffffff, W3D_CHROMATEST_INCLUSIVE).
Before of course i must SetState of W3D_ChromaTest to enabled.
And i do it! And it's strange, but, for me on my a1200 with voodoo3 it works. for a1 with voodoo3 it works too. But for a1 with radeon, and for pegasos with voodoo3/radeon, i always have black color :) why ? maybe i missunderstude somethink ?
-
Time to reply to myself.
So, if someone in interest, Color Keys feature works only on voodoo3 on classic and a1. Also color keys works on classic with bvision (and maybe cvision)
And do not works on:
totally not works on MOS. (it said man from mos dev. team, and i test it myself)
totally not works on WinUae wrapper (quarktex) (it sais author, and i test it myself)
totally not works on a1 with radeon cards (it sais Rogue, and i test it myself agayn)
So, if someone will do code over warp3d - do not use color keys never, if you want to do full compatibility stuff :)