Moinsen,
ich brächte den Spline Shader aus der NVidia OpenGL SDK in GLSL. Leider liegt der hier nur in Assembler vor. Könnt mir da jemand helfen?
hier der Shader:
Code: !!NVgp4.0 # geometry program computing cubic bezier curve PRIMITIVE_IN LINES_ADJACENCY; PRIMITIVE_OUT LINE_STRIP; VERTICES_OUT 100; PARAM segments = program.local[0]; PARAM mvp[4] = { state.matrix.mvp }; TEMP pos, t, dt, temp; TEMP omt, omt2, b; DIV dt.x, 1.0, segments.x; MOV t.x, 0.0; ADD temp.x, segments.x, 1; # loop segments + 1 times to compute the points of the line strip REP temp.x; # Calculate cubic Bernstein blending functions: # B0(t) = (1-t)^3 # B1(t) = 3t(1-t)^2 # B2(t) = 3t^2(1-t) # B3(t) = t^3 ADD omt.x, 1.0, -t.x; # omt = 1-t MUL omt2.x, omt.x, omt.x; # B1 = (1-t)^2 MUL b.x, omt2.x, omt.x; # B0 = (1-t)^2 * (1-t) = (1-t)^3 MUL temp.x, 3.0, t.x; # temp = 3*t MUL b.y, omt2.x, temp.x; # B1 = (1-t)^2 * 3*t MUL b.z, temp.x, t.x; # B2 = 3*t*t = 3t^2 MUL b.z, b.z, omt.x; # B2 = 3t^2 * (1-t) MUL b.w, t.x, t.x; # B3 = t*t MUL b.w, b.w, t.x; # B3 = t*t*t # evaluate curve MUL pos, vertex[0].position, b.x; MAD pos, vertex[1].position, b.y, pos; MAD pos, vertex[2].position, b.z, pos; MAD pos, vertex[3].position, b.w, pos; # transform to clip space #DP4 result.position.x, mvp[0], pos; #DP4 result.position.y, mvp[1], pos; #DP4 result.position.z, mvp[2], pos; #DP4 result.position.w, mvp[3], pos; MOV result.color.x, t.x; MOV result.position, pos; EMIT; ADD t, t, dt; ENDREP; END
|