flat assembler
Message board for the users of flat assembler.
Index
> Windows > [solved]direct3d9, textures seam Goto page 1, 2 Next |
Author |
|
DimonSoft 27 Feb 2018, 21:35
vivik wrote: I'm writing an image viewer for direct3d9, I'm splitting an image into a bunch of 512x512 textures and joining them together. There is an ugly seam if I'm zooming out and setting filtering. What can I do about it? I’d say you’re using a tool that is not suitable for your task. To perform a resize (zoom a raster image in/out) it would be enough to use StretchBlt. If you need something that looks better than that, you can try some combination of such stretches, GDI+, some other library that focuses on image processing or even write such an algorithm yourself. Direct3D is more about faster 3D to 2D transformations. And even if you want to use Direct3D, why not just use a billboard and change its world matrix? This would let you avoid: 1) frequent vertex buffer updates which are considered bad due to the way the graphics pipeline works; 2) splitting images into custom-sized parts, then trying to glue them back on the screen. |
|||
27 Feb 2018, 21:35 |
|
vivik 28 Feb 2018, 06:03
Can't really avoid splitting them. Maximum texture size is 4096x4096, and image can potentially be bigger. Or there is some way?
I will try the world matrix now. |
|||
28 Feb 2018, 06:03 |
|
DimonSoft 28 Feb 2018, 09:58
vivik wrote: Can't really avoid splitting them. Maximum texture size is 4096x4096, and image can potentially be bigger. Or there is some way? Then again, we should talk about Direct3D being the wrong tool. After all, textures have other limits as well, like that they should be squares. If you have to glue something because you had to cut something beforehand then you’re definitely doing something wrong. |
|||
28 Feb 2018, 09:58 |
|
vivik 28 Feb 2018, 10:23
Are you sure you know what you are talking about? There is a reason why photoshop and krita use 3d acceleration. I researched shit.
Actually, I'm considering using directdraw for that later, and doing all the rescaling by myself in software. Found the solution, "Clamp Texture Address Mode": g_pd3dDevice->SetSamplerState( 0, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP); g_pd3dDevice->SetSamplerState( 0, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP); |
|||
28 Feb 2018, 10:23 |
|
DimonSoft 28 Feb 2018, 11:14
vivik wrote: Are you sure you know what you are talking about? There is a reason why photoshop and krita use 3d acceleration. I researched shit. “3D acceleration” is not equal to “using Direct3D”. You might want to do more research and learn about the graphics pipeline of a modern video card. Quote: Actually, I'm considering using directdraw for that later Bad idea. DirectDraw has been deprecated for years since version 7. Since June 2010 even DirectDraw headers are not included in DirectX SDK anymore. Direct3D is the way to go for effective graphics output. But you should make difference between just graphics output and image processing: Direct3D itself has very limited capabilities in the latter. |
|||
28 Feb 2018, 11:14 |
|
vivik 28 Feb 2018, 16:15
>“3D acceleration” is not equal to “using Direct3D”. You might want to do more research and learn about the graphics pipeline of a modern video card.
I don't get it. >DirectDraw has been deprecated for years since version 7. who cares about deprecations, like they are going to replace all the hardware they already sold. I'm using a pc, ide and sdk from 2005. |
|||
28 Feb 2018, 16:15 |
|
Tomasz Grysztar 28 Feb 2018, 17:40
I have been successfully using SDL to do scrolling of a very large image through stitched segments. If you're interested, I could perhaps share some code.
|
|||
28 Feb 2018, 17:40 |
|
DimonSoft 28 Feb 2018, 18:39
vivik wrote: >DirectDraw has been deprecated for years since version 7. They can (and have the right to) suddenly remove the API or break its underlying kernel support in future versions of Windows. They are unlikely to remove it (a lot of APIs from early 90s and even 80s are still there) but they will definitely stop testing the support, and some day simple copying of a DLL (which might be forbidden by license agreement) may stop working. |
|||
28 Feb 2018, 18:39 |
|
Siekmanski 28 Feb 2018, 19:03
Direct3D9 is an excellent choice to do what you want.
It has nice texture filters (linear, mipmap etc.) Use the D3DFVF_XYZRHW Vertex Format to project texures in 2D mode. ( no need to set up the 3D pipeline ) Errors in seamless connected textures can occur on older video cards, you can prevent that by setting the UV coords to 0.003 and 0.997 and setting the correct samplerstate UV addressing mode. Use the Direct3D9 pixelshader to do any possible image processing with ease and incredible speed. For examples see https://www.shadertoy.com/ it runs on a Direct3D9 engine. I use Direct3D9 for ages now for all my graphics coding. |
|||
28 Feb 2018, 19:03 |
|
DimonSoft 28 Feb 2018, 20:35
Siekmanski wrote: by setting the UV coords to 0.003 and 0.997 Why not 0.002 and 0.998? Isn’t it what we call a kludge? Siekmanski wrote: For examples see https://www.shadertoy.com/ it runs on a Direct3D9 engine. The site (well-known among democoders) uses WebGL which is explicitly and clearly stated at the site itself. WebGL is based on OpenGL, not Direct3D. Even if it was Direct3D-based it would be more likely to be based on Direct3D 10 or 11: WebGL dates back to 2011 while Direct3D 10 has been around since 2006 and Direct 3D 11—since 2009. |
|||
28 Feb 2018, 20:35 |
|
rugxulo 28 Feb 2018, 21:58
DimonSoft wrote:
ZDNet wrote:
Just FYI. |
|||
28 Feb 2018, 21:58 |
|
Siekmanski 28 Feb 2018, 22:09
DimonSoft wrote:
-> Because in the evening it is colder than outside???? Siekmanski wrote: For examples see https://www.shadertoy.com/ it runs on a Direct3D9 engine. DimonSoft wrote:
-> WebGl (opengl) -> Angle transpiler -> Direct3D9 executes the code. |
|||
28 Feb 2018, 22:09 |
|
vivik 01 Mar 2018, 06:41
@Tomasz Grysztar
>I have been successfully using SDL to do scrolling of a very large image through stitched segments. If you're interested, I could perhaps share some code. I already got my code working, but I'm curious to look. Maybe I'll learn a thing or two. @Siekmanski >by setting the UV coords to 0.003 and 0.997 Hm, looks like my videocard isn't that old, D3DTADDRESS_CLAMP worked for me. Do you know somebody with a videocard like that? Model, prooflinks? |
|||
01 Mar 2018, 06:41 |
|
Siekmanski 01 Mar 2018, 08:00
+/- 20 years ago it was a commonly known trick to get seamless texture connections on older videocards.
It's all explained in the DirectX SDK. Nearest-Point Sampling Notice that the texture coordinates, 0.0 and 1.0 for this illustration, are exactly at the boundary between texels. Using the method by which Direct3D maps values, the texture coordinates range from [–0.5, 4 – 0.5], where 4 is the width of the texture. For this case, the sampled texel is the 0 texel for a texture index of 1.0. However, if the texture coordinate was only slightly less than 1.0, the sampled texel would be the n texel instead of the 0 texel. The implication of this is that magnifying a small texture using texture coordinates of exactly 0.0 and 1.0 with nearest-point filtering on a screen-space aligned triangle results in pixels for which the texture map is sampled at the boundary between texels. Any inaccuracies in the computation of texture coordinates, however small, results in artifacts along the areas in the rendered image which correspond to the texel edges of the texture map. Performing this mapping of floating point texture coordinates to integer texels with perfect accuracy is difficult, computationally time-consuming, and generally not necessary. Most hardware implementations use an iterative approach for computing texture coordinates at each pixel location within a triangle. Iterative approaches tend to hide these inaccuracies because the errors are accumulated evenly during iteration. |
|||
01 Mar 2018, 08:00 |
|
DimonSoft 01 Mar 2018, 09:26
rugxulo wrote:
So? How does it prevent DirectDraw from being removed in the future? |
|||
01 Mar 2018, 09:26 |
|
DimonSoft 01 Mar 2018, 09:38
Siekmanski wrote:
Good way to write airplane-driving software Siekmanski wrote:
Good point, thanks. Happy to see that at least browser vendors are still worrying about using Direct3D versions that run on most hardware and Windows versions. Depends on the browser implementation though. What about Linux? Note that this doesn’t necessarily make Direct3D a good tool for image processing. |
|||
01 Mar 2018, 09:38 |
|
Siekmanski 01 Mar 2018, 10:58
IMHO for Windows ( from Win98 till Win10 ) Direct3D9 is the best candidate to do fast and very advanced Image Processing. You got all the resources to do everything you want.
Use the pixel shader to do complex processing per pixel by using the mathematical instrinsics provided by the HLSL shader language ps_3_0. You don't need Matrices and Billboards as you mentioned before, to do 2D imaging. You can set Direct3D9 up in 2D mode ( D3DFVF_XYZRHW Vertex Format ) and still use the vertex pipeline to do hardware accelerated zooming, scrolling, rotations, filtering etc. You don't need badly written incomplete 3th party image processing wrapper libraries if you can do it all by yourself with the wonderful pixel shader provided by Direct3D9. Here are some Masm Direct3D9 examples: - A picture transpose 2D imaging routine as discussed at the Masm32 forum - And some Pixel Shader examples ( incl. the executables of the examples, most of them translated from Shadertoy examples ) . One source to compile the shader code. . One source to execute the precompiled shader byte code without the need of one of the D3DX9_xx.dll wrapper libs, so it executes on all windows computers with at least a shader v3.0 compatible graphics card.
|
|||||||||||||||||||||
01 Mar 2018, 10:58 |
|
vivik 01 Mar 2018, 16:47
Thank you for your replies. To summarise this thread:
Use GDI+ if you want some simple gui, it will most likely be enough. It still uses 3D accel. Use Direct3D if you want to work with hardware more directly and do some advanced image processing. Use DirectDraw/SDL1 if you want to do everything on cpu for some unknown reason, like if your videocard got fried resently. And if you're not afraid of your code suddenly stopping working one day (like Fallout 1, which used DirectDraw + pallete. Colors displayed wrong. Fans made a patch that made it use RGB color instead). Use SDL2 + OpenGL if you want to write crossplatform code and don't care about details and extra libraries. Use ANGLE if you want to write crossplatform OpenGL code that still uses Direct3D internally on windows. Use GTK/Qt for crossplatform gui, they most likely use OpenGL or something else. Personally I'm writing for Direct3D right now, because that is what my browser uses internally. Using OpenGL causes a delay at the first start, i guess that's due to the driver loading. It also seems a bit less buggy on older devices. |
|||
01 Mar 2018, 16:47 |
|
Hrstka 28 Mar 2018, 08:06
@Siekmanski
Wow, the pixel shader examples are really impressive. However, I have an issue with the 2D Imaging. If I save the image, it's not exactly the same as the original, but seems a little blurred. I also used a png file instead of jpg as the source image, but the result was the same. |
|||
28 Mar 2018, 08:06 |
|
Goto page 1, 2 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.