Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


wtherapy

Member Since 05 Oct 2012
Offline Last Active Nov 23 2012 08:58 AM

Posts I've Made

In Topic: Sending a simple heightmap as texture to vertex shader

19 November 2012 - 11:39 AM

hello,

I don't need 'nice slopes', since my grid of 256x256 is much smaller than my 3d world. I am using interpolation functions to create the smooth surface. I just want every texel to contain 3 floats and I want o access them as memory data. Here is a snippet from my shader:

#define OPENTG_HEIGHTMAPRES 256
float xn = X / OPENTG_SUBCELLSIZE;
float yn = Y / OPENTG_SUBCELLSIZE;

unsigned int i = (uint)floor( yn );
unsigned int j = (uint)floor( xn );
 
float u = fract(xn);
float v = fract(yn);

if( OPENTG_HEIGHTMAPRES == i )
{
  i --;
  v = 1;
}
if( OPENTG_HEIGHTMAPRES == j )
{
  j --;
  u = 1;
}
vec4 vH00 = GetVertCellParameters( i, j );
vec4 vH10 = GetVertCellParameters( i + 1u, j );
vec4 vH01 = GetVertCellParameters( i, j + 1u );
vec4 vH11 = GetVertCellParameters( i + 1u, j + 1u );
/*do something with the vec4's
they contain infos of height values in i, j cell and gradient information
*/
}

it seems there are problems if some of those values are negative - the rendering looks somehow like it renders part of the scene and then stops rendering anything else in a certain point.

In Topic: Reading a grid stored in the video card's memory

06 October 2012 - 11:23 AM

I guess I will try uniform buffer objects, move to OpenGL 3.*. Keep you informed about this if any relevant increase in speed is noticed. Thanks for the answers.

In Topic: Reading a grid stored in the video card's memory

05 October 2012 - 10:28 AM

Hi,

thanks for the answer, to make everything more clear, I was using uniforms for this and invoking a vertex shader for each terrain quad that project, in the XY plane, into an original grid location. That was very slow and wasn't taking advantage of the fact that the grid never gets modified.

PARTNERS