On Tue, 2006-04-18 at 18:57 -0400, Timothy Miller wrote:
> On 4/18/06, Timothy Baldridge <[EMAIL PROTECTED]> wrote:
> > Oh, there can be much more than that.  Here is a more complete vertex
> > & fragment shader program.
> 
> 
> I can't work on it right at this moment, but what we should do is go
> through some of these shader programs and "hand compile" them.  We can
> just go through what's happening at each statement and reduce them to
> primitives.

You can use the NVidia Cg compiler (available free-of-charge, although
without source; versions are available for at least Windows and Linux)
to compile Cg and OpenGL Shader Language shaders into various forms of
shader assembly language.  I am attaching the result of running an old
version of the compiler on the shaders posted by Timothy Baldridge.
Note that this file contains one vertex shader, and four independent
fragment shaders; so I have run the compiler 5 times.  The vertex shader
targets "arbvp1" (ARB Vertex Program version 1); the pixel shaders
target "arbfp1" (ARB Fragment Program version 1).  Other targets are
available.  The "-oglsl" argument is for compiling OpenGL Shading
Language programs; otherwise, it would compile Cg programs.

Carl Witty

[EMAIL PROTECTED]:/tmp$ cgc -profile arbvp1 -oglsl -entry vertexProgram 
shader.glsl
shader.glsl
265 lines, 0 errors.
!!ARBvp1.0
# cgc version 1.3.0001, build date Aug  4 2004 10:24:23
# command line args: -profile arbvp1 -oglsl -entry vertexProgram
# source file: shader.glsl
#vendor NVIDIA Corporation
#version 1.0.02
#profile arbvp1
#program vertexProgram
#semantic vertexProgram.bumpScale
#semantic vertexProgram.diseaseMapScale
#semantic vertexProgram.diseaseBumpScale
#semantic vertexProgram.modelViewProj
#semantic vertexProgram.modelView
#var float4 oPosition : $vin.POSITION : POSITION : 0 : 1
#var float2 texcoord0 : $vin.TEXCOORD0 : TEXCOORD0 : 1 : 1
#var float3 tangent : $vin.ATTR14 : ATTR14 : 2 : 1
#var float3 binormal : $vin.ATTR15 : ATTR15 : 3 : 1
#var float3 normal : $vin.NORMAL : NORMAL : 4 : 1
#var float4 hPosition : $vout.HPOS : HPOS : 5 : 1
#var float4 color : $vout.COL0 : COL0 : 6 : 1
#var float2 OUT.texcoords : $vout.TEX0 : TEX0 : 7 : 1
#var float2 OUT.texcoords1 : $vout.TEX1 : TEX1 : 7 : 1
#var float4 OUT.tangentToEyeMat0 : $vout.TEX4 : TEX4 : 7 : 1
#var float4 OUT.tangentToEyeMat1 : $vout.TEX5 : TEX5 : 7 : 1
#var float3 OUT.tangentToEyeMat2 : $vout.TEX6 : TEX6 : 7 : 1
#var float4 OUT.eyeSpacePosition : $vout.TEX7 : TEX7 : 7 : 1
#var float bumpScale :  : c[10] : 8 : 1
#var float diseaseMapScale :  : c[9] : 9 : 1
#var float diseaseBumpScale :  : c[11] : 10 : 1
#var float4x4 modelViewProj :  : c[0], 4 : 11 : 1
#var float4x4 modelView :  : c[4], 4 : 12 : 1
#const c[8] = 1
PARAM c[12] = { program.local[0..7],
                { 1 },
                program.local[9..11] };
TEMP R0;
TEMP R1;
MOV result.color, c[8].x;
MOV result.texcoord[0].xy, vertex.texcoord[0];
MUL result.texcoord[1].xy, vertex.texcoord[0], c[9].x;
MOV result.texcoord[4].w, c[10].x;
DP3 result.texcoord[4].z, vertex.normal, c[4];
DP3 result.texcoord[4].y, vertex.attrib[15], c[4];
DP3 result.texcoord[4].x, vertex.attrib[14], c[4];
MOV result.texcoord[5].w, c[11].x;
DP3 result.texcoord[5].z, vertex.normal, c[5];
DP3 result.texcoord[5].y, vertex.attrib[15], c[5];
DP3 result.texcoord[5].x, vertex.attrib[14], c[5];
DP3 result.texcoord[6].z, vertex.normal, c[6];
DP3 result.texcoord[6].y, vertex.attrib[15], c[6];
DP3 result.texcoord[6].x, vertex.attrib[14], c[6];
MUL R1, vertex.position.y, c[5];
MUL R0, vertex.position.y, c[1];
MAD R0, vertex.position.x, c[0], R0;
MAD R1, vertex.position.x, c[4], R1;
MAD R1, vertex.position.z, c[6], R1;
MAD R0, vertex.position.z, c[2], R0;
MAD result.position, vertex.position.w, c[3], R0;
MAD result.texcoord[7], vertex.position.w, c[7], R1;
END
# 22 instructions, 2 R-regs
[EMAIL PROTECTED]:/tmp$ cgc -profile arbfp1 -oglsl -entry blinnSkin shader.glsl
shader.glsl
265 lines, 0 errors.
!!ARBfp1.0
# cgc version 1.3.0001, build date Aug  4 2004 10:24:23
# command line args: -profile arbfp1 -oglsl -entry blinnSkin
# source file: shader.glsl
#vendor NVIDIA Corporation
#version 1.0.02
#profile arbfp1
#program blinnSkin
#semantic blinnSkin.normalTexture
#semantic blinnSkin.diffuseTexture
#semantic blinnSkin.glossyTexture
#semantic blinnSkin.eyeSpaceLightPosition
#var half2 In.texcoords : $vin.TEX0 : TEX0 : 0 : 1
#var half2 In.diseasecoords :  :  : 0 : 0
#var half4 In.tangentToEyeMat0 : $vin.TEX4 : TEX4 : 0 : 1
#var half4 In.tangentToEyeMat1 : $vin.TEX5 : TEX5 : 0 : 1
#var half3 In.tangentToEyeMat2 : $vin.TEX6 : TEX6 : 0 : 1
#var half3 In.eyeSpacePosition : $vin.TEX7 : TEX7 : 0 : 1
#var sampler2D normalTexture :  : texunit 0 : 1 : 1
#var sampler2D diffuseTexture :  : texunit 1 : 2 : 1
#var sampler2D glossyTexture :  : texunit 2 : 3 : 1
#var half3 eyeSpaceLightPosition :  : c[1] : 4 : 1
#var half4 blinnSkin : $vout.COL : COL : -1 : 1
#const c[0] = 1 34
PARAM c[2] = { { 1, 34 },
                program.local[1] };
TEMP R0;
TEMP R1;
TEMP R2;
TEMP R3;
ADD R1.xyz, -fragment.texcoord[7], c[1];
DP3 R0.y, R1, R1;
RSQ R0.y, R0.y;
MUL R2.xyz, R0.y, R1;
DP3 R0.x, -fragment.texcoord[7], -fragment.texcoord[7];
RSQ R0.x, R0.x;
MUL R0.xyz, R0.x, -fragment.texcoord[7];
ADD R3.xyz, R0, R2;
TEX R0.xyz, fragment.texcoord[0], texture[0], 2D;
DP3 R0.w, R3, R3;
MOV R1.xy, fragment.texcoord[4].w;
MOV R1.z, c[0].x;
MUL R1.xyz, R1, R0;
DP3 R0.z, fragment.texcoord[6], R1;
DP3 R0.x, fragment.texcoord[4], R1;
DP3 R0.y, fragment.texcoord[5], R1;
DP3 R1.x, R0, R0;
RSQ R1.y, R0.w;
RSQ R0.w, R1.x;
MUL R1.xyz, R1.y, R3;
MUL R0.xyz, R0.w, R0;
DP3 R1.y, R0, R1;
DP3 R1.x, R0, R2;
MOV R1.z, c[0].y;
LIT R2.yz, R1.xyzz;
TEX R0, fragment.texcoord[0], texture[2], 2D;
MUL R1, R2.z, R0;
TEX R0, fragment.texcoord[0], texture[1], 2D;
MAD result.color, R2.y, R0, R1;
END
# 29 instructions, 4 R-regs
[EMAIL PROTECTED]:/tmp$ cgc -profile arbfp1 -oglsl -entry crawlSkin shader.glsl
shader.glsl
265 lines, 0 errors.
!!ARBfp1.0
# cgc version 1.3.0001, build date Aug  4 2004 10:24:23
# command line args: -profile arbfp1 -oglsl -entry crawlSkin
# source file: shader.glsl
#vendor NVIDIA Corporation
#version 1.0.02
#profile arbfp1
#program crawlSkin
#semantic crawlSkin.normalTexture
#semantic crawlSkin.diffuseTexture
#semantic crawlSkin.glossyTexture
#semantic crawlSkin.diseaseNormalTexture
#semantic crawlSkin.eyeSpaceLightPosition
#var half2 In.texcoords : $vin.TEX0 : TEX0 : 0 : 1
#var half2 In.diseasecoords : $vin.TEX1 : TEX1 : 0 : 1
#var half4 In.tangentToEyeMat0 : $vin.TEX4 : TEX4 : 0 : 1
#var half4 In.tangentToEyeMat1 : $vin.TEX5 : TEX5 : 0 : 1
#var half3 In.tangentToEyeMat2 : $vin.TEX6 : TEX6 : 0 : 1
#var half3 In.eyeSpacePosition : $vin.TEX7 : TEX7 : 0 : 1
#var sampler2D normalTexture :  : texunit 0 : 1 : 1
#var sampler2D diffuseTexture :  : texunit 1 : 2 : 1
#var sampler2D glossyTexture :  : texunit 2 : 3 : 1
#var sampler2D diseaseNormalTexture :  : texunit 3 : 4 : 1
#var half3 eyeSpaceLightPosition :  : c[1] : 5 : 1
#var half4 crawlSkin : $vout.COL : COL : -1 : 1
#const c[0] = 1 2 34
PARAM c[2] = { { 1, 2, 34 },
                program.local[1] };
TEMP R0;
TEMP R1;
TEMP R2;
DP3 R0.w, -fragment.texcoord[7], -fragment.texcoord[7];
TEX R0.xyz, fragment.texcoord[1], texture[3], 2D;
MOV R2.xy, fragment.texcoord[4].w;
MOV R2.z, c[0].x;
TEX R1.xyz, fragment.texcoord[0], texture[0], 2D;
MUL R1.xyz, R2, R1;
MAD R2.xyz, R0, c[0].y, -c[0].x;
MOV R0.xy, fragment.texcoord[5].w;
MOV R0.z, c[0].x;
MAD R2.xyz, R0, R2, R1;
ADD R1.xyz, -fragment.texcoord[7], c[1];
DP3 R1.w, R1, R1;
RSQ R1.w, R1.w;
MUL R1.xyz, R1.w, R1;
DP3 R0.z, fragment.texcoord[6], R2;
DP3 R0.y, fragment.texcoord[5], R2;
DP3 R0.x, fragment.texcoord[4], R2;
RSQ R0.w, R0.w;
MUL R2.xyz, R0.w, -fragment.texcoord[7];
ADD R2.xyz, R2, R1;
DP3 R1.w, R0, R0;
DP3 R0.w, R2, R2;
RSQ R1.w, R1.w;
MUL R0.xyz, R1.w, R0;
DP3 R1.x, R0, R1;
RSQ R0.w, R0.w;
MUL R2.xyz, R0.w, R2;
DP3 R1.y, R0, R2;
MOV R1.z, c[0];
LIT R2.yz, R1.xyzz;
TEX R0, fragment.texcoord[0], texture[2], 2D;
MUL R1, R2.z, R0;
TEX R0, fragment.texcoord[0], texture[1], 2D;
MAD result.color, R2.y, R0, R1;
END
# 34 instructions, 3 R-regs
[EMAIL PROTECTED]:/tmp$ cgc -profile arbfp1 -oglsl -entry diseaseSkin 
shader.glsl
shader.glsl
265 lines, 0 errors.
!!ARBfp1.0
# cgc version 1.3.0001, build date Aug  4 2004 10:24:23
# command line args: -profile arbfp1 -oglsl -entry diseaseSkin
# source file: shader.glsl
#vendor NVIDIA Corporation
#version 1.0.02
#profile arbfp1
#program diseaseSkin
#semantic diseaseSkin.normalTexture
#semantic diseaseSkin.diffuseTexture
#semantic diseaseSkin.glossyTexture
#semantic diseaseSkin.diseaseNormalTexture
#semantic diseaseSkin.diseaseTexture
#semantic diseaseSkin.eyeSpaceLightPosition
#semantic diseaseSkin.diseaseColor
#var half2 In.texcoords : $vin.TEX0 : TEX0 : 0 : 1
#var half2 In.diseasecoords : $vin.TEX1 : TEX1 : 0 : 1
#var half4 In.tangentToEyeMat0 : $vin.TEX4 : TEX4 : 0 : 1
#var half4 In.tangentToEyeMat1 : $vin.TEX5 : TEX5 : 0 : 1
#var half3 In.tangentToEyeMat2 : $vin.TEX6 : TEX6 : 0 : 1
#var half3 In.eyeSpacePosition : $vin.TEX7 : TEX7 : 0 : 1
#var sampler2D normalTexture :  : texunit 0 : 1 : 1
#var sampler2D diffuseTexture :  : texunit 1 : 2 : 1
#var sampler2D glossyTexture :  : texunit 2 : 3 : 1
#var sampler2D diseaseNormalTexture :  : texunit 3 : 4 : 1
#var sampler2D diseaseTexture :  : texunit 4 : 5 : 1
#var half3 eyeSpaceLightPosition :  : c[1] : 6 : 1
#var half3 diseaseColor :  : c[2] : 7 : 1
#var half4 diseaseSkin : $vout.COL : COL : -1 : 1
#const c[0] = 1 2 34
PARAM c[3] = { { 1, 2, 34 },
                program.local[1..2] };
TEMP R0;
TEMP R1;
TEMP R2;
TEMP R3;
DP3 R0.w, -fragment.texcoord[7], -fragment.texcoord[7];
TEX R3.x, fragment.texcoord[1], texture[4], 2D;
TEX R0.xyz, fragment.texcoord[1], texture[3], 2D;
MOV R2.xy, fragment.texcoord[4].w;
MOV R2.z, c[0].x;
TEX R1.xyz, fragment.texcoord[0], texture[0], 2D;
MUL R1.xyz, R2, R1;
MAD R2.xyz, R0, c[0].y, -c[0].x;
MOV R0.xy, fragment.texcoord[5].w;
MOV R0.z, c[0].x;
MAD R2.xyz, R0, R2, R1;
ADD R1.xyz, -fragment.texcoord[7], c[1];
DP3 R1.w, R1, R1;
RSQ R1.w, R1.w;
MUL R1.xyz, R1.w, R1;
DP3 R0.z, fragment.texcoord[6], R2;
DP3 R0.y, fragment.texcoord[5], R2;
DP3 R0.x, fragment.texcoord[4], R2;
RSQ R0.w, R0.w;
MUL R2.xyz, R0.w, -fragment.texcoord[7];
ADD R2.xyz, R2, R1;
DP3 R1.w, R0, R0;
DP3 R0.w, R2, R2;
RSQ R1.w, R1.w;
MUL R0.xyz, R1.w, R0;
DP3 R1.x, R0, R1;
RSQ R0.w, R0.w;
MUL R2.xyz, R0.w, R2;
DP3 R1.y, R0, R2;
MOV R1.z, c[0];
LIT R3.yz, R1.xyzz;
TEX R0, fragment.texcoord[0], texture[2], 2D;
MUL R1, R3.z, R0;
TEX R0, fragment.texcoord[0], texture[1], 2D;
ADD R2.xyz, -R0, c[2];
ADD R2.w, -R3.x, c[0].x;
MAD R0.xyz, R2.w, R2, R0;
MAD result.color, R3.y, R0, R1;
END
# 38 instructions, 4 R-regs
[EMAIL PROTECTED]:/tmp$ cgc -profile arbfp1 -oglsl -entry chromeSkin shader.glsl
shader.glsl
shader.glsl(234) : warning C7011: implicit cast from "float4" to "half3"
shader.glsl(234) : warning C7011: implicit cast from "float4" to "half3"
265 lines, 2 warnings, 0 errors.
!!ARBfp1.0
# cgc version 1.3.0001, build date Aug  4 2004 10:24:23
# command line args: -profile arbfp1 -oglsl -entry chromeSkin
# source file: shader.glsl
#vendor NVIDIA Corporation
#version 1.0.02
#profile arbfp1
#program chromeSkin
#semantic chromeSkin.normalTexture
#semantic chromeSkin.diffuseTexture
#semantic chromeSkin.glossyTexture
#semantic chromeSkin.diseaseNormalTexture
#semantic chromeSkin.diseaseTexture
#semantic chromeSkin.envTexture
#semantic chromeSkin.eyeSpaceLightPosition
#var half2 In.texcoords : $vin.TEX0 : TEX0 : 0 : 1
#var half2 In.diseasecoords : $vin.TEX1 : TEX1 : 0 : 1
#var half4 In.tangentToEyeMat0 : $vin.TEX4 : TEX4 : 0 : 1
#var half4 In.tangentToEyeMat1 : $vin.TEX5 : TEX5 : 0 : 1
#var half3 In.tangentToEyeMat2 : $vin.TEX6 : TEX6 : 0 : 1
#var half3 In.eyeSpacePosition : $vin.TEX7 : TEX7 : 0 : 1
#var sampler2D normalTexture :  : texunit 0 : 1 : 1
#var sampler2D diffuseTexture :  : texunit 1 : 2 : 1
#var sampler2D glossyTexture :  : texunit 2 : 3 : 1
#var sampler2D diseaseNormalTexture :  : texunit 3 : 4 : 1
#var sampler2D diseaseTexture :  : texunit 4 : 5 : 1
#var samplerCUBE envTexture :  : texunit 5 : 6 : 1
#var half3 eyeSpaceLightPosition :  : c[1] : 7 : 1
#var half4 chromeSkin : $vout.COL : COL : -1 : 1
#const c[0] = 1 2 34 0.5
#const c[2] = 3
PARAM c[3] = { { 1, 2, 34, 0.5 },
                program.local[1],
                { 3 } };
TEMP R0;
TEMP R1;
TEMP R2;
TEMP R3;
TEMP R4;
DP3 R0.w, -fragment.texcoord[7], -fragment.texcoord[7];
TEX R0.xyz, fragment.texcoord[1], texture[3], 2D;
MOV R2.xy, fragment.texcoord[4].w;
MOV R2.z, c[0].x;
TEX R1.xyz, fragment.texcoord[0], texture[0], 2D;
MUL R1.xyz, R2, R1;
MAD R2.xyz, R0, c[0].y, -c[0].x;
MOV R0.xy, fragment.texcoord[5].w;
MOV R0.z, c[0].x;
MAD R3.xyz, R0, R2, R1;
ADD R2.xyz, -fragment.texcoord[7], c[1];
DP3 R1.w, R2, R2;
DP3 R1.z, fragment.texcoord[6], R3;
DP3 R1.y, fragment.texcoord[5], R3;
DP3 R1.x, fragment.texcoord[4], R3;
RSQ R1.w, R1.w;
MUL R3.xyz, R1.w, R2;
RSQ R0.w, R0.w;
MUL R2.xyz, R0.w, -fragment.texcoord[7];
ADD R4.xyz, R2, R3;
DP3 R0.w, R4, R4;
DP3 R1.w, R1, R1;
RSQ R1.w, R1.w;
MUL R2.xyz, R1.w, R1;
DP3 R3.x, R2, R3;
RSQ R0.w, R0.w;
MUL R1.xyz, R0.w, R4;
DP3 R3.y, R2, R1;
MOV R3.z, c[0];
LIT R4.yz, R3.xyzz;
TEX R3.xyz, R2, texture[5], CUBE;
TEX R2, fragment.texcoord[0], texture[1], 2D;
TEX R4.x, fragment.texcoord[1], texture[4], 2D;
ADD R0.w, -R4.x, c[0].x;
MAD R0.xyz, R0, R0.w, -c[0].w;
TEX R1, fragment.texcoord[0], texture[2], 2D;
MUL R1, R4.z, R1;
MOV R0.w, c[2].x;
ADD R3.xyz, R3, -R2;
RCP R4.x, c[0].w;
RCP R4.w, c[0].w;
RCP R4.z, c[0].w;
MUL_SAT R4.xzw, R0.xyyz, R4;
MAD R0.xyz, -R4.xzww, c[0].y, R0.w;
MUL R4.xzw, R4, R4;
MUL R0.xyz, R4.xzww, R0;
MAD R0.xyz, R0, R3, R2;
MOV R0.w, R2;
MAD result.color, R4.y, R0, R1;
END
# 49 instructions, 5 R-regs
_______________________________________________
Open-graphics mailing list
[email protected]
http://lists.duskglow.com/mailman/listinfo/open-graphics
List service provided by Duskglow Consulting, LLC (www.duskglow.com)

Reply via email to