Sign in to follow this  
Dragon_Strike

problems with vertex textures *SOLVED*

Recommended Posts

im trying to implement some vertex displacing in the vertex shader but for somereason the scene doesnt get rendered... im using GLSL

ShaderProgram->sendUniform("ScaleFactor", scale, scale, x, z);
ShaderProgram->sendUniform("Color", color.x, color.y, color.z);
ShaderProgram->sendUniform("heightmap", 0);
ShaderProgram->sendUniform("FineBlockOrig", 1.0f/m_iSize, 1.0f/m_iSize, (x-100000.0f+m_iSize/2)/m_iSize, (z-100000.0f+m_iSize/2)/m_iSize);


#version 110

uniform vec4 ScaleFactor;
uniform vec4 FineBlockOrig;

uniform sampler2D heightmap;

varying vec2 uv;

void main()
{
	gl_TexCoord[0] = gl_MultiTexCoord0;
	vec2 Gridpos = gl_TexCoord[0].st;
	
	vec2 WorldPos = Gridpos * ScaleFactor.xy + ScaleFactor.zw;
	
	uv = Gridpos * ScaleFactor.xy * FineBlockOrig.xy+FineBlockOrig.zw;
		
	float height = texture2D(heightmap, uv).r;
	

	gl_Position = gl_ModelViewProjectionMatrix * vec4(WorldPos.x, height, WorldPos.y, 1.0) ;
}


i have no clue how to use vertex textures.. so im basicly just guessing.. my video card supporst shader 3.0 [Edited by - Dragon_Strike on October 21, 2006 4:48:49 AM]

Share this post


Link to post
Share on other sites
First, check for any errors/warnings when compiling/linking the shaders using glGetInfoLogARB.

Second, what graphics card are you using?

ATi SM3 cards (X1300-X1900) don't support texture lookup in Vertex Shaders and NVIDIA cards (6600-7xxx) only support a few formats for vertex texture lookup (no filtering etc), not sure if it works in GLSL or if you need to use NVIDIAs extensions for it.

Share this post


Link to post
Share on other sites
Quote:
Original post by nts
First, check for any errors/warnings when compiling/linking the shaders using glGetInfoLogARB.

Second, what graphics card are you using?

ATi SM3 cards (X1300-X1900) don't support texture lookup in Vertex Shaders and NVIDIA cards (6600-7xxx) only support a few formats for vertex texture lookup (no filtering etc), not sure if it works in GLSL or if you need to use NVIDIAs extensions for it.


i only get this info

Vertex info
-----------
warning: no vertex attribute is explicitly assigned to vertex attribute zero

but if i remove the part where i call the texture object.. it works fine and i get the same error...

im using a 7800gt... with GLSL

im trying to implement geometry clipmaps.. and i dont have much left... but if i dont get this part right.. its pretty much useless... ive checked that the textures works and that its ok with the fragment shader...

does anyone know how exactly i could do use vertex texture with what ive got?

Share this post


Link to post
Share on other sites
Looks like to me you for some reason aren't assigning the vertex data to unit 0 of the vertex attributes? IIRC vertex data needs to be 0 on Nvidia or ATI or both...

Either way check out

http://www.ozone3d.net/tutorials/vertex_displacement_mapping.php

and NTS your incorrect on the ATI stuff from what the ozone site says x1800 and x1900 have vertex texture support... Just thought I would point it out so don't quote me. [smile]

Share this post


Link to post
Share on other sites
Quote:
Original post by MARS_999
and NTS your incorrect on the ATI stuff from what the ozone site says x1800 and x1900 have vertex texture support... Just thought I would point it out so don't quote me. [smile]

They do report support (Required by the SM3 spec) but they don't report any supported texture formats for the vertex texture lookup (none are required by the SM3 spec).

There is however a way around it by using R2VB which is free of the limitations of VTF on NVIDIA cards but would be nice if both vendors supported one common method...



Share this post


Link to post
Share on other sites
Quote:
Original post by MARS_999
Looks like to me you for some reason aren't assigning the vertex data to unit 0 of the vertex attributes? IIRC vertex data needs to be 0 on Nvidia or ATI or both...
[smile]


i dont understand what u mean by "unit 0 of the vertex attributes"... ive binded the texture to TEXTURE0 and then sent sendUniform("heightmap", 0).. if tahts what u meant..?

thx for the link btw... ill check it out tomorow

EDOT::

just a thought but maybe im using the wring texture parameters...?


void CTERRAIN::RGB_BindFPTexture(float* Data, int size)
{
unsigned int iTempID;
glGenTextures(1, &iTempID);
glBindTexture(GL_TEXTURE_2D, iTempID);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB16F_ARB, size, size, 0, GL_RGB, GL_FLOAT, Data );
}


Share this post


Link to post
Share on other sites
ok ive got the texture fecthing the vertex shader work by using the texture type GL_RGBA_FLOAT32_ATI... but now the texture doesnt get created right...

what type does GL_RGBA_FLOAT32_ATI use? is it float, double or somethin else?

EDIT:
its seems like teh float type only works with the RGBA16F parameter..? which type should i use for 32bit?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this