Hi,
anyone know what might be causing QC to crash whenever I try to run the
following GLSL Vertex shader program?
===========================
// Vertex tweaks
uniform vec3 point1, point2;
float width = 0.25;
uniform float amp;// "Curve" 0.0 > 2.0
uniform float bend;// "Bend" -0.5 > 1.0
uniform float gamma;// "Gamma" -1.0 > 1.0
uniform float pitch;
const float PI=3.1415926535;
vec3 rotate(in vec3 Pos, in float pitch) // Thanks to tonfilm
{
vec3 vect = normalize(vec3(0.0,sin(pitch*2.0*PI),cos(pitch*2.0*PI)));
if ((vect.z==0.0)) {vect.z=0.0001;}
float angle=atan(vect.y,vect.z);
// Rotation matrix
mat3 m;
m[0][0]=1.0;
m[0][1]=0.0;
m[0][2]=0.0;
m[1][0]=0.0;
m[1][1]=cos(angle);
m[1][2]=-sin(angle);
m[2][0]=0.0;
m[2][1]=sin(angle);
m[2][2]=cos(angle);
Pos*=m;
return Pos;
}
struct PosNorm
{
vec4 Pos;
vec3 Norm;
};
PosNorm segment(in vec4 Pos) {
float maximum = 0.5*abs(amp)*PI;
float range=Pos.x*abs(amp)*PI;
float x_clamp=sin(maximum)/0.5;
float zero_one=Pos.x+0.5;
float sinus=(pow(zero_one,2.0)-zero_one)*4.0;
Pos.x=((sin(range+(gamma*sinus))/x_clamp)-(gamma*sinus));
Pos.y*=width*(1.0-((bend*sinus)+abs(bend)));
Pos.z+=(((cos(range)-cos(max))/x_clamp))*sign(amp);
Pos.xyz=rotate(Pos.xyz,pitch);
vec3 max_const=vec3(0.5,0.0,0.0);
vec3 diff=mix(point1+max_const,point2-max_const,zero_one);
Pos.xyz+=diff;
vec3 Norm=vec3(0.0);
Norm.x=(sin(range+(gamma*sinus)))*sign(amp);
Norm.z=(cos(range+(gamma*sinus)))*sign(amp);
Norm=rotate(Norm,pitch);
PosNorm Out;
Out.Pos=Pos;
Out.Norm=Norm;
return Out;
}
varying vec3 Normal;
void main()
{
vec4 vertex = gl_Vertex;
//Normal = normalize(gl_NormalMatrix * segment(vertex).Norm);
vertex = segment(vertex).Pos;
//Transform vertex by modelview and projection matrices
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
//Forward current color and texture coordinates after applying texture matrix
gl_FrontColor = gl_Color;
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
}
===============================================
Whenever I uncomment either of the 2 lines in the main loop that call the
'segment' function, QC crashes.
Anyone any thoughts on why this might be the case? It could easily be a driver
bug. Haven't tried the shader on an NVIDIA-equipped machine (I'm currently on a
1st-gen MacBook Pro with ATI Radeon X1600.256mb).
a|x
http://machinesdontcare.wordpress.com
__________________________________________________________
Not happy with your email address?.
Get the one you really want - millions of new email addresses available now at
Yahoo! http://uk.docs.yahoo.com/ymail/new.html _______________________________________________
Do not post admin requests to the list. They will be ignored.
Quartzcomposer-dev mailing list ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/quartzcomposer-dev/archive%40mail-archive.com
This email sent to [EMAIL PROTECTED]