Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I have a height map of 256x256, containing, foreach cell, not only height as a normal float value ( not 0-1 ) and also 2 gradient values ( for X and Y ), also as normal float values ( not 0-1 ). I have uploaded the texture via normal texture loading:

glEnable( GL_TEXTURE_2D );
glGenTextures( 1, &m_uglID );
DEBUG_OUTPUT("Err %x\n", glGetError());
glBindTexture( GL_TEXTURE_2D , m_uglID );
DEBUG_OUTPUT("Err %x\n", glGetError());
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB32F, unW + 1, unH + 1, 0, GL_RGB, GL_FLOAT, pvBytes );
DEBUG_OUTPUT("Err %x\n", glGetError());
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_LINEAR);
DEBUG_OUTPUT("Err %x\n", glGetError());
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_LINEAR);
DEBUG_OUTPUT("Err %x\n", glGetError());
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
DEBUG_OUTPUT("Err %x\n", glGetError());
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
DEBUG_OUTPUT("Err %x\n", glGetError());

as a parenthesis, the debug output is:

Err 500 Err 0 Err 0 Err 0 Err 500 Err 500 Err 0 Err 0

pvBytes is a 256x256 array of

typedef struct _tGradientHeightCell
{
    float v;
    float px;
    float py;
}
TGradientHeightCell, *LPTGradientHeightCell;

then,

m_ugl_HeightMapTexture = glGetUniformLocation(m_uglProgram, "TexHeightMap");

I load it via:

glEnable(GL_TEXTURE_2D );
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D , pTexture->GetID());
glUniform1i(m_ugl_HeightMapTexture, 0);

in shader, I just access it:

uniform sampler2D TexHeightMap;

vec4 GetVertCellParameters( uint i, uint j ) { return texture( TexHeightMap, vec2( i, j ) ); }

vec4 vH00 = GetVertCellParameters( i, j );

My problem is that, when passing negative values in one of the values in TGradientHeightCell ( v, px, py ), the texture is corrupted. I need the values to be passed exact as I have them in memory.

Any help appreciated.

share|improve this question
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.