[Feature request] support vertex texture fetch on GL3 / DX10+ #823
Comments
On my voxel renderer that I am working on I made a texture buffer object that take in an index buffer. https://github.com/friesencr/Urho3D/blob/voxel/Source/Urho3D/Graphics/OpenGL/OGLTextureBuffer.h I just hacked mine in to get it to work because I didn't feel like setting up all the datatypes. This change also broke the name 'IndexBuffer' since it wasn't an index buffer anymore. |
Yours vtf hacking more clever then mine, and may be used as std method for both renders, i guess
then I just load manually special prepared image and put it in proper TU for special shader |
I have pushed some changes to master that were necessary for D3D11 VTF to work properly. Otherwise OpenGL worked out of the box. I tested with the Terrain shader on fairly recent Nvidia & Intel hardware, and simply made it read the weight texture (which is plain RGBA8) in the VS and pass it directly to PS. If you need the texture to be RGBA16F, please set that format already in Texture2D::SetSize(), then set the data appropriately, though I understand you can't use a load from a regular Image in that case. I would rather not add a VTF boolean flag. Is what you're doing necessary for older hardware? Terrain GLSL code:
Terrain HLSL code (D3D11 only):
Please close the issue if this was satisfactory. |
How much older? I suppose that older ATI 9500 support or GFX 7600 support VTF each in own way, on old GL and DX9. Anyway, maybe also add some function to engine that allow do check, something like - bool checkSupportingVertexTextureFetch(format) ? |
There seemed to be vendor-specific rules that are rather complex (including things like what filter settings and mipmapping you're using), especially for the old hardware, so if that can be avoided I'd rather not go there. Maybe you could assume that VTF is available (with sane formats) if you're able to run GL3 / D3D11? I will however verify that setting floating point texture data works on all APIs. |
Heh I restarted my GL4 patches again locally friesencr and made a TextureBuffer class very similar to yours, except I've also made a GPUBuffer class which is designed to house all the different BO's and setting them with an enum in SetSize, same for DX11. Cadaver would you accept stuff like the extra shader stages in a patch as long as it doesn't break GL3.2/ES 2.0 and supports DX11, for instance, by having appropriate fallbacks or flags? MonkeyFirst: Fancy explosion, I saw the article to make that one with a noise function... :) |
Yes, that's very much my hope to receive things like tessellation / geometry shaders as contribution because I don't presently have time / expertise to implement them (and any related API) myself. Naturally, when something as big as that is contributed the hope / expectation is that you then continue the development and fixing of possible issues, so that it doesn't become a commit-and-run type operation, resulting in increased amount of burden to the core contributors (or alternatively: unmaintained code), which has been somewhat of a danger as Urho3D has grown. |
Fair call on the maintenance burden, it might make sense to keep it in another branch for now as I'm worried that I wouldn't have the time to maintain it. Although Sinoid on the forums is also doing similar things, so it might make sense that we all collaborate so we don't do duplicate efforts. 'No expertise' and 'Cadaver/Lasse' don't go together in my head at all, btw... :P but yeah, lack of time is always a killer. |
Yeah, but it so far from finished fx I trying last master with VTF changes for DX11 and found what it not working. The shader compiled is fine. Moreover I may change clip factor of pixels in material editor, but I guess what VS shader do not read texture. LitSolidVTF.hlsl Samplers.hlsl Uniforms.hlsl Also am add setting for displace texture in xml file -texture- it placed into NormalMap TU (only this map used for VTF in VS shader) so i'm think the main thing to solve this is there maybe also need add parameter in xml file something like |
oh, I found what in void Graphics::PrepareDraw() (D3D11Graphics.cpp) some textures are also established for VS shader( with PS) this firstDirtyTexture_... is this textures from material TU-slots or this for other use? |
I suppose that i found some new issue. And that's why my VTF not working on DX11. Now am use uniforms with various names and common uniform(for VS/PS) i'm put in VS(MaterialVS) and then pass they into PS shader through VS-shader output values + semantic. In this case I see some displacement, but now have other problems with ramp texture. |
I'm don't know why but this VTF works only with directional and spot lights and I got this with point light how type of light may affect on this? DiffVTF.xml litSolidVTF.hlsl |
The dirty textures range should be set whenever SetTexture() is called in D3D11, so the end result should be that the exactly same textures in same units are available for both VS & PS. I'll investigate the difference with point lights, it seems odd. @boberfly: that's one of the tough parts writing a graphics engine, one should update knowledge regularly. In this case I haven't used geometry shaders, tessellation, or compute, which, in the end, I guess ties back to the lack of time :) |
With the shader you provided, I'm not able to make it behave differently under different lights. All CBuffer parameters seem to be working as expected. I sometimes have seen a situation where defining VS outputs & PS inputs in different order wreaks havoc in the compiled D3D11 shader, for example defining COLOR0 before TEXCOORD0 in VS and COLOR0 after TEXCOORD0 in PS, so make sure the order is same. The point light uses different texcoord inputs/outputs than the others. If you want me to investigate further, please provide all your current data (shader code, material, technique, textures), that produces the light issue, in a zip archive or similar to make sure we're using the same data. |
Yes you're right it was an order, but strange my out/in-put variable placed in same position in both shaders VP and PS and out side any define group. |
"Ability from the box" that allow you create textures for vertex fetch still not haven't.
Actually, i'm may to imagine how to tweak engine for supporting manual created VTF-textures on GL-Renderer. But currently i'm use DX11-Renderer and absolutely don't know how to create VTF texture in DX11.
But also i think what this must be a standard feature for both renderers and not user's tweaks of renderer.
The text was updated successfully, but these errors were encountered: