|
| ||||||||||
| Tags: 3d texture, glsl, opengl shading language, texture |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| How to index a texture
Imagine the simple case of a 1D texture of size N. I want to access the value in box number k of my texture. The case k may for example contain the number of a child or a neighbor in my data structure. It is very important that I get exactly the value stored at this location in the texture and not an interpolated value. Does texture1D(id, k / (float) N) work? Is that from the data access there is no interpolation or other filtering that could screw up my value? |
|
#2
| |||
| |||
| Re: How to index a texture
According to me, it depends on how the sampler is configured. It should be put in nearest. After the formatting of the coordinate, we must watch the conventions used in OpenGL. That means sampling in texture, it can be done by nearest sampling, bilinear filtering, with mipmapping, trilinear aniso bili / tril. Logically for unfiltered access, it must be nearest (no mipmap). |
|
#3
| |||
| |||
| Re: How to index a texture
But, now I have another problem. To my index I use floating, and I have problems with details of what is stored in textures. Let's say I want to store an integer n in a square texture. I store a float: n / coef where I am assured that float coef always be greater than all the n possible to always have a float value between 0 and 1. Then in my fragment shader that I value and I remultiply by coef. I should return by n. But that does not work well at all. When n and coef are about 1000 of my value is of type n + - 20% of true value! To make the indexing is not really top ... You have an idea of where it can go and how to fix that? Unfortunately I also need to store floating in my texture so I can not use a full texture. I tested by the scope of division and multiplication in the shader and I have no problem with accuracy. This indicates that my lose data precision somewhere in the transfer. I'm a glTexImage3D (GL_TEXTURE_3D, 0, GL_RGBA16, arraySize [0], arraySize [1], arraySize [2] 0, GL_RGBA, GL_FLOAT, array); |
|
#4
| |||
| |||
| Re: How to index a texture
With GL_RGBA16, you have the 16 bits integers with internal format. Basically the problem is that floats are on 32bit CPU on your machine and it is trashing you to convert 16bits on the GPU. The conversion must still be well because to lose 20% on something on the order of 10 ^ -3 is terrible. Try RGBA32F, without your conversion, and see if it works. |
![]() |
|
| Thread Tools | Search this Thread |
| |
Similar Threads for: "How to index a texture" | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Saints Row 3 texture are not appropriate | Edie Adams | Video Games | 7 | 20-11-2011 10:54 AM |
| CG Texture Conservation Help | Bhartiya-Technician | Windows Software | 6 | 13-05-2010 04:11 PM |
| Does Google decides which content to index & what not to index? | Uddhav | Technology & Internet | 5 | 04-03-2010 06:37 PM |
| Inserting an index entry into index 0 of file 25 | Dharmesh Arora | Operating Systems | 3 | 16-07-2009 10:10 AM |
| UV Texture in blender 2.48 | Lord | Windows Software | 6 | 24-03-2009 10:01 PM |