最近涉及到ARB assembly语言,说白了就是OpenGL的低级着色语言,语言组织看起来有点像汇编语言,下面就摘抄点网络上对这个语言的介绍:
ARB assembly language is a low-level shading language, which can be characterized as an assembly language. It was created by the OpenGL Architecture Review Board (ARB) to standardize GPU instructions controlling the hardware graphics pipeline.
它也是OpenGL ARB这个组织创建的,用来控制图像管道。
大家想了解可以去这个网站看看:http://en.wikipedia.org/wiki/ARB_assembly_language
我现在正在看NV的一个例子,等我把这个改造完了,在上传上来大家一起学习。
NV的assembly语言如下:
static const char *fprog_code = "!!NVfp4.0 \n" "TEMP texcoord; \n" "MOV texcoord, fragment.texcoord[0]; \n" "FLR texcoord.z, texcoord; \n" "TEX result.color, texcoord, texture[0], ARRAY2D; \n" "END";
#version 400 #extension GL_EXT_texture_array : enable layout( location = 0) out vec4 FragColor; in vec3 TexCoord; uniform sampler2DArray textureID; void main() { vec3 TCoord = TexCoord; TCoord.z = floor(TCoord.z); FragColor = texture2DArray( textureID, TCoord.xyz ); }
static const char *lerp_fprog_code = "!!NVfp4.0 \n" "TEMP texcoord, c0, c1, frac; \n" "MOV texcoord, fragment.texcoord[0]; \n" "FLR texcoord.z, texcoord; \n" "TEX c0, texcoord, texture[0], ARRAY2D; \n" "ADD texcoord.z, texcoord, { 0, 0, 1, 0 }; \n" "TEX c1, texcoord, texture[0], ARRAY2D; \n" "FRC frac.x, fragment.texcoord[0].z; \n" "LRP result.color, frac.x, c1, c0; \n" "END";
#version 400 #extension GL_EXT_texture_array : enable layout( location = 0) out vec4 FragColor; uniform sampler2DArray textureID; in vec3 TexCoord; void main() { vec3 texCo; vec4 c0, c1; float frac; texCo = TexCoord; texCo.z = floor( TexCoord.z ); c0 = texture2DArray( textureID, texCo ); texCo.z += 1.0; c1 = texture2DArray( textureID, texCo ); frac = fract( TexCoord.z ); FragColor = mix( c0, c1, frac ); }