I've been trying to figure out how to integrate this shader code into Blockland's code, changing certain variables to fit. But I have yet to figure out what file to put it in, which command, where in which command, and how to change some parts to work. I have been told there is no uniform for worldTime, and was going to opt for converting the vec camPos to an int for the purpose of the script. Could someone figure out how to integrate this into the shaders?
vec4 position = gl_ModelViewMatrix * gl_Vertex;
float distanceSquared = position.x * position.x + position.z * position.z;
position.y += 5*sin(distanceSquared*sin(float(worldTime)/143.0)/1000);
float y = position.y;
float x = position.x;
float z = position.z * ( (sin(float(worldTime)/256.0) + 1.75) / 2);
float om = sin(distanceSquared*sin(float(worldTime)/256.0)/5000) * sin(float(worldTime)/200.0);
position.y = x*sin(om)+y*cos(om);
position.x = x*cos(om)-y*sin(om);
position.z = z;
gl_Position = gl_ProjectionMatrix * position;
This is the best I could figure trying to put it into renderVsm_vert.glsl:
worldTime = camPos.x + camPos.y + camPos.z;
float distanceSquared = vPos.x * vPos.x + vPos.z * vPos.z;
vPos.y += 5*sin(distanceSquared*sin(float(worldTime)/143.0)/1000);
float y = vPos.y;
float x = vPos.x;
float z = vPos.z * ( (sin(float(worldTime)/256.0) + 1.75) / 2);
float om = sin(distanceSquared*sin(float(worldTime)/256.0)/5000) * sin(float(worldTime)/200.0);
vPos.y = x*sin(om)+y*cos(om);
vPos.x = x*cos(om)-y*sin(om);
vPos.z = z;
I have no idea if it'd even go in there, or if this would even work in the end. But so far, I've definitely been coding this wrong. I wish Port would have not contradicted himself by first editing the code and then saying he does not understand it. Maybe you just switched some numbers, but you know more than me.
Edit: I managed to sort of get it working, although it ends up looking very buggy:
http://www.youtube.com/watch?v=jZ7QOvw9P1Y Here is the code I used in
generateVsm_frag.glsl and
renderVsm_frag.glsl:
float distanceSquared = vPos.x * vPos.x + vPos.z * vPos.z;
int worldTime = int(camPos.x + camPos.y + camPos.z);
int oScale = int(256.0/2);
int eScale = int(200.0/2);
vPos.y += 5*sin(distanceSquared*sin(float(worldTime)/143.0)/1000);
float y = vPos.y;
float x = vPos.x;
float z = vPos.z * ( (sin(float(worldTime)/oScale) + 1.75) / 2);
float om = sin(distanceSquared*sin(float(worldTime)/oScale)/5000) * sin(float(worldTime)/eScale);
vPos.y = x*sin(om)+y*cos(om);
vPos.x = x*cos(om)-y*sin(om);
vPos.z = z;
Edit2: I tried halving more of the values to see if it was a scale issue. It seemed to make things work somewhat better, although it also allows things to skew the hell out suddenly:
http://www.youtube.com/watch?v=RcPCYHLWouk Here is the code I currently have:
float distanceSquared = vPos.x * vPos.x + vPos.z * vPos.z;
int worldTime = int(camPos.x + camPos.y + camPos.z);
int aScale = int(256.0/2);
int bScale = int(200.0/2);
int cScale = int(143.0/2);
int dScale = int(1000/2);
int eScale = int(5000/2);
vPos.y += 5*sin(distanceSquared*sin(float(worldTime)/cScale)/dScale);
float y = vPos.y;
float x = vPos.x;
float z = vPos.z * ( (sin(float(worldTime)/aScale) + 1.75) / 2);
float om = sin(distanceSquared*sin(float(worldTime)/aScale)/eScale) * sin(float(worldTime)/bScale);
vPos.y = x*sin(om)+y*cos(om);
vPos.x = x*cos(om)-y*sin(om);
vPos.z = z;
I'm putting them as separate ints instead of changing them internally so I can adjust the scaling on the original code without forgetting etc. etc.