#pragma bind appin.Position = ATTR0 // Wrong line since // Cg1.1 - warning C7008: non-uniform variable has both semantics and binding "Position" // // Cg1.2.1001 - error C5040: type of parameter "Position" incompatible with bind directive // Important Note: this error shows up when you compile using cgc compiler in shell command. // At the execution time the cgErrorCallback does not capture this error and // the application has Segmentation fault (core dumped). For more details check // http://www.csit.fsu.edu/~blanco/Cg/cg_srcUpdate.htm // // Solution: remove it. Or ATTR0 => POSITION // ================================================================================================ struct appin : application2vertex // since Cg1.1 - warning C7017: use of connectors such as 'application2vertex' is deprecated { float4 Position : POSITION; }; struct vertout : vertex2fragment // since Cg1.1 - warning C7017: use of connectors such as 'application2vertex' is deprecated { float4 HPosition :POSITION; float4 Color0 :COLOR0; float4 Texture0 :TEXCOORD0; }; vertout main(appin IN, uniform float4x4 ModelViewProj, // Modelview-projection matrix uniform float4x4 ModelView, // Modelview matrix uniform float4x4 ModelViewIT, // Inverse transpose modelview matrix uniform float4 SinTime, uniform float4 WaveOscillator, // (x,y)->base center (z,w)->amplitude,frequency uniform float4 WaveOscillator1, // x ->phase (y,z)-> velocity uniform float4 WaveRippleTank) // x ->waveSpeed y->damping { vertout OUT; float z, dt; float angleZ; float2 q = float2( IN.Position.x, IN.Position.y); float dist = distance ( q, float2(WaveOscillator.x, WaveOscillator.y)); // Evaluating //------------------------------------------------------------------------------------ dt = dist/WaveRippleTank.x; angleZ = 2.0*3.141592653589 * WaveOscillator.w * (SinTime.x - dt) + WaveOscillator1.x; float cosVal; float sinVal; sincos( angleZ, sinVal, cosVal); OUT.HPosition = mul( ModelViewProj, float4(IN.Position.x, IN.Position.y, sinVal * WaveOscillator.z, IN.Position.w)); //------------------------------------------------------------------------------------ // Calculate vertex normal float4 normal; normal.x = (IN.Position.x / dist) *cosVal; normal.y = (IN.Position.y / dist) *cosVal; normal.z = 1.0; normal.w = 1.0; // transform normal from model-space to view-space normal = normalize(mul(ModelViewIT, normal).xyz).xyzz; // Output vertex color float4 light = float4( 0.0, 2.0, 0.0, 1.0); float4 eye = normalize(mul(ModelView, IN.Position)); float4 half = normalize ( light + eye); float diffuse = dot (normal, light); float specular = dot (normal, half); specular = pow( specular, 32); float4 diffuseMaterial = float4( 0.3, 0.3, 0.3, 1.0); float4 specularMaterial = float4( 1.0, 1.0, 1.0, 1.0); OUT.Color0 = diffuse * diffuseMaterial + specular * specularMaterial; // Mapping texture float dampingScale = 1.0; float4 texCoord = float4( angleZ / (2.0*3.141592653589), 0.96* 1.0 + 0.02, abs( 90*sin(angleZ)), 1.0); OUT.Texture0 = texCoord; OUT.Texture0.w = 1.0; return OUT; }