411 lines
11 KiB
Text
411 lines
11 KiB
Text
|
renderBinding deformScroll { vector { 0 } }
|
||
|
renderBinding deformMagnitude { vector { 1 } }
|
||
|
|
||
|
renderProgram heatHaze {
|
||
|
state {
|
||
|
maskAlpha
|
||
|
}
|
||
|
|
||
|
program vertex arb { <%
|
||
|
OPTION ARB_position_invariant;
|
||
|
|
||
|
TEMP R0, R1, R2;
|
||
|
|
||
|
TEMP TC;
|
||
|
DP4 TC.x, $texCoordAttrib, $diffuseMatrix_s;
|
||
|
DP4 TC.y, $texCoordAttrib, $diffuseMatrix_t;
|
||
|
# texture 1 takes the texture coordinates and adds a scroll
|
||
|
ADD result.texcoord[1], TC, $deformScroll;
|
||
|
|
||
|
# texture 2 takes the deform magnitude and scales it by the projection distance
|
||
|
PARAM vec = { 1, 0, 0, 1 };
|
||
|
|
||
|
MOV R0, vec;
|
||
|
DP4 R0.z, $positionAttrib, state.matrix.modelview.row[2];
|
||
|
|
||
|
DP4 R1, R0, state.matrix.projection.row[0];
|
||
|
DP4 R2, R0, state.matrix.projection.row[3];
|
||
|
|
||
|
# don't let the recip get near zero for polygons that cross the view plane
|
||
|
MAX R2, R2, 1;
|
||
|
|
||
|
RCP R2, R2.w;
|
||
|
MUL R1, R1, R2;
|
||
|
|
||
|
# clamp the distance so the the deformations don't get too wacky near the view
|
||
|
MIN R1, R1, 0.02;
|
||
|
|
||
|
MUL result.texcoord[2], R1, $deformMagnitude;
|
||
|
%> }
|
||
|
|
||
|
program fragment arb { <%
|
||
|
OPTION ARB_precision_hint_fastest;
|
||
|
|
||
|
TEMP localNormal, R0;
|
||
|
|
||
|
PARAM subOne = { -1, -1, -1, -1 };
|
||
|
PARAM scaleTwo = { 2, 2, 2, 2 };
|
||
|
|
||
|
# load the filtered normal map and convert to -1 to 1 range
|
||
|
TEX localNormal, fragment.texcoord[1], $bumpMap, 2D;
|
||
|
$if !r_dxnNormalMaps
|
||
|
MOV localNormal.x, localNormal.a;
|
||
|
$endif
|
||
|
MAD localNormal, localNormal, scaleTwo, subOne;
|
||
|
|
||
|
$if r_normalizeNormalMaps
|
||
|
MOV localNormal.z, 0;
|
||
|
DP3 R0.x, localNormal,localNormal;
|
||
|
ADD R0.x, 1, -R0.x;
|
||
|
RSQ R0.x, R0.x;
|
||
|
RCP localNormal.z, R0.x;
|
||
|
$endif
|
||
|
|
||
|
|
||
|
# calculate the screen texcoord in the 0.0 to 1.0 range
|
||
|
MUL R0, fragment.position, $currentRenderTexelSize.zwzw;
|
||
|
|
||
|
# offset by the scaled localNormal and clamp it to 0.0 - 1.0
|
||
|
MAD_SAT R0, localNormal, fragment.texcoord[2], R0;
|
||
|
|
||
|
# scale by the screen adjust
|
||
|
MUL R0, R0, $currentRenderTexelSize.xyzy;
|
||
|
|
||
|
# load the screen render
|
||
|
TEX result.color.xyz, R0, $currentRender, RECT;
|
||
|
%> }
|
||
|
}
|
||
|
|
||
|
renderProgram heatHazeWithVertex {
|
||
|
state {
|
||
|
maskAlpha
|
||
|
}
|
||
|
|
||
|
program vertex arb { <%
|
||
|
OPTION ARB_position_invariant;
|
||
|
|
||
|
TEMP R0, R1, R2;
|
||
|
|
||
|
TEMP TC;
|
||
|
DP4 TC.x, $texCoordAttrib, $diffuseMatrix_s;
|
||
|
DP4 TC.y, $texCoordAttrib, $diffuseMatrix_t;
|
||
|
# texture 1 takes the texture coordinates and adds a scroll
|
||
|
ADD result.texcoord[1], TC, $deformScroll;
|
||
|
|
||
|
# texture 2 takes the deform magnitude and scales it by the projection distance
|
||
|
PARAM vec = { 1, 0, 0, 1 };
|
||
|
|
||
|
MOV R0, vec;
|
||
|
DP4 R0.z, $positionAttrib, state.matrix.modelview.row[2];
|
||
|
|
||
|
DP4 R1, R0, state.matrix.projection.row[0];
|
||
|
DP4 R2, R0, state.matrix.projection.row[3];
|
||
|
|
||
|
# don't let the recip get near zero for polygons that cross the view plane
|
||
|
MAX R2, R2, 1;
|
||
|
|
||
|
RCP R2, R2.w;
|
||
|
MUL R1, R1, R2;
|
||
|
|
||
|
# clamp the distance so the the deformations don't get too wacky near the view
|
||
|
MIN R1, R1, 0.02;
|
||
|
|
||
|
MUL result.texcoord[2], R1, $deformMagnitude;
|
||
|
|
||
|
MOV result.color, $colorAttrib;
|
||
|
%> }
|
||
|
|
||
|
program fragment arb { <%
|
||
|
OPTION ARB_precision_hint_fastest;
|
||
|
|
||
|
TEMP localNormal, mask, R0;
|
||
|
|
||
|
PARAM subOne = { -1, -1, -1, -1 };
|
||
|
PARAM scaleTwo = { 2, 2, 2, 2 };
|
||
|
|
||
|
# kill the pixel if the distortion wound up being very small
|
||
|
SUB mask.xy, fragment.color, 0.01;
|
||
|
MOV mask.zw, 0;
|
||
|
KIL mask;
|
||
|
|
||
|
# load the filtered normal map and convert to -1 to 1 range
|
||
|
TEX localNormal, fragment.texcoord[1], $bumpMap, 2D;
|
||
|
$if !r_dxnNormalMaps
|
||
|
MOV localNormal.x, localNormal.a;
|
||
|
$endif
|
||
|
MAD localNormal, localNormal, scaleTwo, subOne;
|
||
|
|
||
|
$if r_normalizeNormalMaps
|
||
|
MOV localNormal.z, 0;
|
||
|
DP3 R0.x, localNormal,localNormal;
|
||
|
ADD R0.x, 1, -R0.x;
|
||
|
RSQ R0.x, R0.x;
|
||
|
RCP localNormal.z, R0.x;
|
||
|
$endif
|
||
|
|
||
|
MUL localNormal, localNormal, mask;
|
||
|
|
||
|
# calculate the screen texcoord in the 0.0 to 1.0 range
|
||
|
MUL R0, fragment.position, $currentRenderTexelSize.zwzw;
|
||
|
|
||
|
# offset by the scaled localNormal and clamp it to 0.0 - 1.0
|
||
|
MAD_SAT R0, localNormal, fragment.texcoord[2], R0;
|
||
|
|
||
|
# scale by the screen adjust
|
||
|
MUL R0, R0, $currentRenderTexelSize.xyzy;
|
||
|
|
||
|
# load the screen render
|
||
|
TEX result.color.xyz, R0, $currentRender, RECT;
|
||
|
%> }
|
||
|
}
|
||
|
|
||
|
renderProgram heatHazeWithMask {
|
||
|
state {
|
||
|
maskAlpha
|
||
|
}
|
||
|
|
||
|
program vertex arb { <%
|
||
|
OPTION ARB_position_invariant;
|
||
|
|
||
|
TEMP R0, R1, R2;
|
||
|
|
||
|
TEMP TC;
|
||
|
DP4 TC.x, $texCoordAttrib, $diffuseMatrix_s;
|
||
|
DP4 TC.y, $texCoordAttrib, $diffuseMatrix_t;
|
||
|
|
||
|
MOV result.texcoord[0], TC;
|
||
|
# texture 1 takes the texture coordinates and adds a scroll
|
||
|
ADD result.texcoord[1], TC, $deformScroll;
|
||
|
|
||
|
|
||
|
# texture 2 takes the deform magnitude and scales it by the projection distance
|
||
|
PARAM vec = { 1, 0, 0, 1 };
|
||
|
|
||
|
MOV R0, vec;
|
||
|
DP4 R0.z, $positionAttrib, state.matrix.modelview.row[2];
|
||
|
|
||
|
DP4 R1, R0, state.matrix.projection.row[0];
|
||
|
DP4 R2, R0, state.matrix.projection.row[3];
|
||
|
|
||
|
# don't let the recip get near zero for polygons that cross the view plane
|
||
|
MAX R2, R2, 1;
|
||
|
|
||
|
RCP R2, R2.w;
|
||
|
MUL R1, R1, R2;
|
||
|
|
||
|
# clamp the distance so the the deformations don't get too wacky near the view
|
||
|
MIN R1, R1, 0.02;
|
||
|
|
||
|
MUL result.texcoord[2], R1, $deformMagnitude;
|
||
|
%> }
|
||
|
|
||
|
program fragment arb { <%
|
||
|
OPTION ARB_precision_hint_fastest;
|
||
|
|
||
|
TEMP localNormal, mask, R0;
|
||
|
|
||
|
PARAM subOne = { -1, -1, -1, -1 };
|
||
|
PARAM scaleTwo = { 2, 2, 2, 2 };
|
||
|
|
||
|
# load the distortion map
|
||
|
TEX mask, fragment.texcoord[0], $mask, 2D;
|
||
|
|
||
|
# kill the pixel if the distortion wound up being very small
|
||
|
SUB mask.xy, mask, 0.01;
|
||
|
MOV mask.zw, 0;
|
||
|
KIL mask;
|
||
|
|
||
|
# load the filtered normal map and convert to -1 to 1 range
|
||
|
TEX localNormal, fragment.texcoord[1], $bumpMap, 2D;
|
||
|
$if !r_dxnNormalMaps
|
||
|
MOV localNormal.x, localNormal.a;
|
||
|
$endif
|
||
|
MAD localNormal, localNormal, scaleTwo, subOne;
|
||
|
|
||
|
$if r_normalizeNormalMaps
|
||
|
MOV localNormal.z, 0;
|
||
|
DP3 R0.x, localNormal,localNormal;
|
||
|
ADD R0.x, 1, -R0.x;
|
||
|
RSQ R0.x, R0.x;
|
||
|
RCP localNormal.z, R0.x;
|
||
|
$endif
|
||
|
|
||
|
MUL localNormal, localNormal, mask;
|
||
|
|
||
|
# calculate the screen texcoord in the 0.0 to 1.0 range
|
||
|
MUL R0, fragment.position, $currentRenderTexelSize.zwzw;
|
||
|
|
||
|
# offset by the scaled localNormal and clamp it to 0.0 - 1.0
|
||
|
MAD_SAT R0, localNormal, fragment.texcoord[2], R0;
|
||
|
|
||
|
# scale by the screen adjust
|
||
|
MUL R0, R0, $currentRenderTexelSize.xyxy;
|
||
|
|
||
|
# load the screen render
|
||
|
TEX result.color.xyz, R0, $currentRender, RECT;
|
||
|
%> }
|
||
|
}
|
||
|
|
||
|
renderProgram heatHazeWithMaskAndVertex {
|
||
|
state {
|
||
|
maskAlpha
|
||
|
}
|
||
|
|
||
|
program vertex arb { <%
|
||
|
OPTION ARB_position_invariant;
|
||
|
|
||
|
TEMP R0, R1, R2;
|
||
|
|
||
|
TEMP TC;
|
||
|
DP4 TC.x, $texCoordAttrib, $diffuseMatrix_s;
|
||
|
DP4 TC.y, $texCoordAttrib, $diffuseMatrix_t;
|
||
|
|
||
|
MOV result.texcoord[0], TC;
|
||
|
# texture 1 takes the texture coordinates and adds a scroll
|
||
|
ADD result.texcoord[1], TC, $deformScroll;
|
||
|
|
||
|
# texture 2 takes the deform magnitude and scales it by the projection distance
|
||
|
PARAM vec = { 1, 0, 0, 1 };
|
||
|
|
||
|
MOV R0, vec;
|
||
|
DP4 R0.z, $positionAttrib, state.matrix.modelview.row[2];
|
||
|
|
||
|
DP4 R1, R0, state.matrix.projection.row[0];
|
||
|
DP4 R2, R0, state.matrix.projection.row[3];
|
||
|
|
||
|
# don't let the recip get near zero for polygons that cross the view plane
|
||
|
MAX R2, R2, 1;
|
||
|
|
||
|
RCP R2, R2.w;
|
||
|
MUL R1, R1, R2;
|
||
|
|
||
|
# clamp the distance so the the deformations don't get too wacky near the view
|
||
|
MIN R1, R1, 0.02;
|
||
|
|
||
|
MUL result.texcoord[2], R1, $deformMagnitude;
|
||
|
|
||
|
MOV result.color, $colorAttrib;
|
||
|
%> }
|
||
|
|
||
|
program fragment arb { <%
|
||
|
OPTION ARB_precision_hint_fastest;
|
||
|
|
||
|
TEMP localNormal, mask, R0;
|
||
|
|
||
|
PARAM subOne = { -1, -1, -1, -1 };
|
||
|
PARAM scaleTwo = { 2, 2, 2, 2 };
|
||
|
|
||
|
# load the distortion map
|
||
|
TEX mask, fragment.texcoord[0], $mask, 2D;
|
||
|
|
||
|
# kill the pixel if the distortion wound up being very small
|
||
|
MUL mask.xy, mask, fragment.color;
|
||
|
SUB mask.xy, mask, 0.01;
|
||
|
MOV mask.zw, 0;
|
||
|
KIL mask;
|
||
|
|
||
|
# load the filtered normal map and convert to -1 to 1 range
|
||
|
TEX localNormal, fragment.texcoord[1], $bumpMap, 2D;
|
||
|
$if !r_dxnNormalMaps
|
||
|
MOV localNormal.x, localNormal.a;
|
||
|
$endif
|
||
|
MAD localNormal, localNormal, scaleTwo, subOne;
|
||
|
|
||
|
$if r_normalizeNormalMaps
|
||
|
MOV localNormal.z, 0;
|
||
|
DP3 R0.x, localNormal,localNormal;
|
||
|
ADD R0.x, 1, -R0.x;
|
||
|
RSQ R0.x, R0.x;
|
||
|
RCP localNormal.z, R0.x;
|
||
|
$endif
|
||
|
|
||
|
|
||
|
MUL localNormal, localNormal, mask;
|
||
|
|
||
|
# calculate the screen texcoord in the 0.0 to 1.0 range
|
||
|
MUL R0, fragment.position, $currentRenderTexelSize.zwzw;
|
||
|
|
||
|
# offset by the scaled localNormal and clamp it to 0.0 - 1.0
|
||
|
MAD_SAT R0, localNormal, fragment.texcoord[2], R0;
|
||
|
|
||
|
# scale by the screen adjust
|
||
|
MUL R0, R0, $currentRenderTexelSize.xyxy;
|
||
|
|
||
|
# load the screen render
|
||
|
TEX result.color.xyz, R0, $currentRender, RECT;
|
||
|
%> }
|
||
|
}
|
||
|
|
||
|
// With a proper matrix instead of just a scroll
|
||
|
renderProgram heatHazeMatrix {
|
||
|
state {
|
||
|
maskAlpha
|
||
|
}
|
||
|
|
||
|
program vertex arb { <%
|
||
|
OPTION ARB_position_invariant;
|
||
|
|
||
|
TEMP R0, R1, R2;
|
||
|
|
||
|
# texture 1 takes the texture coordinates and adds a scroll
|
||
|
#ADD result.texcoord[1], $texCoordAttrib, $deformScroll;
|
||
|
DP4 result.texcoord[1].x, $texCoordAttrib, $diffuseMatrix_s;
|
||
|
DP4 result.texcoord[1].y, $texCoordAttrib, $diffuseMatrix_t;
|
||
|
|
||
|
# texture 2 takes the deform magnitude and scales it by the projection distance
|
||
|
PARAM vec = { 1, 0, 0, 1 };
|
||
|
|
||
|
MOV R0, vec;
|
||
|
DP4 R0.z, $positionAttrib, state.matrix.modelview.row[2];
|
||
|
|
||
|
DP4 R1, R0, state.matrix.projection.row[0];
|
||
|
DP4 R2, R0, state.matrix.projection.row[3];
|
||
|
|
||
|
# don't let the recip get near zero for polygons that cross the view plane
|
||
|
MAX R2, R2, 1;
|
||
|
|
||
|
RCP R2, R2.w;
|
||
|
MUL R1, R1, R2;
|
||
|
|
||
|
# clamp the distance so the the deformations don't get too wacky near the view
|
||
|
MIN R1, R1, 0.02;
|
||
|
|
||
|
MUL result.texcoord[2], R1, $deformMagnitude;
|
||
|
%> }
|
||
|
|
||
|
program fragment arb { <%
|
||
|
OPTION ARB_precision_hint_fastest;
|
||
|
|
||
|
TEMP localNormal, R0;
|
||
|
|
||
|
PARAM subOne = { -1, -1, -1, -1 };
|
||
|
PARAM scaleTwo = { 2, 2, 2, 2 };
|
||
|
|
||
|
# load the filtered normal map and convert to -1 to 1 range
|
||
|
TEX localNormal, fragment.texcoord[1], $bumpMap, 2D;
|
||
|
$if !r_dxnNormalMaps
|
||
|
MOV localNormal.x, localNormal.a;
|
||
|
$endif
|
||
|
MAD localNormal, localNormal, scaleTwo, subOne;
|
||
|
|
||
|
$if r_normalizeNormalMaps
|
||
|
MOV localNormal.z, 0;
|
||
|
DP3 R0.x, localNormal,localNormal;
|
||
|
ADD R0.x, 1, -R0.x;
|
||
|
RSQ R0.x, R0.x;
|
||
|
RCP localNormal.z, R0.x;
|
||
|
$endif
|
||
|
|
||
|
# calculate the screen texcoord in the 0.0 to 1.0 range
|
||
|
MUL R0, fragment.position, $currentRenderTexelSize.zwzw;
|
||
|
|
||
|
# offset by the scaled localNormal and clamp it to 0.0 - 1.0
|
||
|
MAD_SAT R0, localNormal, fragment.texcoord[2], R0;
|
||
|
|
||
|
# scale by the screen adjust
|
||
|
MUL R0, R0, $currentRenderTexelSize.xyzy;
|
||
|
|
||
|
# load the screen render
|
||
|
TEX result.color.xyz, R0, $currentRender, RECT;
|
||
|
%> }
|
||
|
}
|