Newsgroup: it.fan.studio-vit
Titolo: Nvidia Cg

scaricate e ammirate, prego
20 linee di codice et voilà, l'acqua di ico che tanti di voi hanno
apprezzato

 apprezzato
Prego postare (non cg, la ho gia'... le 20 linee di codice plz).
--
 ==> Atlantis <==
 Icq # 18752702
http://thenomad.homeip.net
"Il discorso doveva finire qui. Kjow, invece, sprezzante del pericolo,
indiscusso campione dello sci su merda, si arma di sciolina e va.." by cyb

 apprezzato
?
Sarà mica bella l'acqua di Ico, adesso?


copy&past from effects browser
#pragma bind vertexin.Position        = ATTR0
#pragma bind vertexin.TexCoord0        = ATTR1
struct vertexin : application2vertex
{
    float4 Position;
    float4 TexCoord0;
};
#pragma bind vertexout.HPosition    = HPOS
#pragma bind vertexout.TexCoord0    = TEX0
#pragma bind vertexout.TexCoord1    = TEX1
#pragma bind vertexout.TexCoord2    = TEX2
#pragma bind vertexout.TexCoord3    = TEX3
struct vertexout : vertex2fragment
{
    float4 HPosition;
    float4 TexCoord0;
    float4 TexCoord1;
    float4 TexCoord2;
    float4 TexCoord3;
};
#pragma bind main.WorldViewProj        = c CV_WORLDVIEWPROJ_0
#pragma bind main.T0_Offset            = c CV_T0_OFFSET
#pragma bind main.T1_Offset            = c CV_T1_OFFSET
#pragma bind main.T2_Offset            = c CV_T2_OFFSET
#pragma bind main.T3_Offset            = c CV_T3_OFFSET
vertexout main( vertexin IN,
                uniform float4x4 WorldViewProj,
                uniform float4 T0_Offset,
                uniform float4 T1_Offset,
                uniform float4 T2_Offset,
                uniform float4 T3_Offset
            )
{
    vertexout OUT;
    // Transform position to HCLIP space
    OUT.HPosition = mul( WorldViewProj, IN.Position );
    // Add texture coordinate offsets to the single input
    //  vertex texture coordinate.  This will cause
    //  a pattern of texels (for example, the nearest
    //  neighbors) to be sampled into the pixel shader
    //  texture sample registers t0 through t3.
    // If the original texture coordinates are a one-to-one
    //  mapping of texels in the source to pixels of the
    //  render target, then these offsets will sample the
    //  same pattern of neighboring texels surrounding each
    //  pixel rendered.
    OUT.TexCoord0 = IN.TexCoord0 + T0_Offset;
    OUT.TexCoord1 = IN.TexCoord0 + T1_Offset;
    OUT.TexCoord2 = IN.TexCoord0 + T2_Offset;
    OUT.TexCoord3 = IN.TexCoord0 + T3_Offset;
    return( OUT );
}
*******************************************
Comments:
Step one in the nearest-neighbor force calculation for height-based water
simulation.
This step takes the center point and three neighboring points, and computes
the texel difference as the "force" acting to pull on the center texel.
The amount to which the computed force is applied to the texel is controlled
in a separate shader.
This shader also copies the input t0 green, blue, and alpha to the output,
 so only the red is new.
For the water simulation:
position    is duplicated in blue and alpha, so that .rgb and .a ops can be
            used simultaneously.
velocity    is held in the green color
force       is held in the red color
***
Older version of nvasm do not support the .b blue-to-alpha replicate
modifier,
so you may want to use Microsoft's psa.exe instead.  Replace the
file->settings->
custom build step:    ..\..\..\..\..\bin\nvasm $(InputPath)
with:                psa -p $(InputPath)
****************************************************************************
**
#include "Constants.h"
// Declare pixel shader version
ps.1.1
// Define a few masks and biasing values for putting things
//  in the right place
def c3, 0.5, 0.0, 0.0, 0.0
def c4, 0.0, 1.0, 1.0, 1.0
def c5, 1.0, 0.0, 0.0, 0.0
def c6, 0.0, 0.0, 1.0, 0.0
def c7, 0.5, 0.5, 0.5, 0.5    // Constant to determine equilibrium position
                            // A gentle force pulls the blue and alpha to
this
                            //   value.
//  Height must be in blue and alpha components
//  Red = force
//  green = velocity
// Get colors from all 4 texture stages
// A vertex shader sets up texture coordinates so that the sampled
//  texels are the following for the pixel being rendered:
//
//  t0 = texel at coordinate we are rendering to, and for which
//           we are computing the force.
//  t1 = 1st neighbor to the t0 texel
//  t2 = 2nd neighbor
//  t3 = 3rd neighbor
tex t0
tex t1
tex t2
tex t3
sub    r0.rgb,   t1,   t0            // Diff between 1st neighbor and center
texel
 + sub r0.a,     t2.b, t0.b            // Diff between 2nd neighbor and
center texel
                                    //  Use blue replicate to move blue into
alpha
                                    //  as the alpha might be dirty from a
previous
                                    //  alpha blend
//@@ + sub r0.a,     t2.a, t0.a            // Diff between 2nd neighbor and
center texel
                                    // c7 - t0
sub     r1.rgb,  c7,     t0            // Force to pull t0 center to the c7
equilibrium value
 + sub  r1.a,    t3.b,   t0.b        // Diff between 3rd neighbor and center
texel to .a
                                    //  Use blue replicate to move blue into
alpha
                                    //  as the alpha might be dirty from a
previous
                                    //  alpha blend
//@@ + sub  r1.a,    t3.a,   t0.a        // Diff between 3rd neighbor and
center texel to .a
// Multiply r1.rgb by PCN_EQ_REST_FAC, and add it to the r0.rgb
// Also add the .a components with no scaling factor -- all neighbor
differences
//  scale the same.
// Reason for multiplying by PCN_EQ_REST_FAC is to vary the strength of the
//  force pulling the center position to the value defined in c7
mad     r1.rgb,  r1,  c[PCN_EQ_REST_FAC],    r0        // scale the
equilibrium restore force
 + add  r1.a,    r1.a,  r0.a                        // Add 3rd neighbor diff
to 2nd neighbor diff
// Add the force components in alpha to the force components in blue
add  r1, r1, r1.a                // r1 = r1.rgba + r1.aaaa
                                // Blue now holds the correct total 'force'
before
                                //  biasing to the unsigned range.
// Replicate blue to rgba with a dp3
// This is to move the total force into the red component so we can
//   store it in the texture render target.
dp3  r1.rgba,  r1, c6
// Mask force to red only, and add 0.5 red to bias the signed
//  force value up to center about 0.5.  This is so we can store
//  the force value in the unsigned bits of the texture target
mad  r1.rgba,  r1, c5,  c3
// Mask off red of t0 source and put the r1 force result into red.
// This carries forward the t0 position (blue,alpha) and velocity (green)
//   to the next stage
// The output contains ( 0, t0.g, t0.b, t0.a )  + ( r1.r, 0, 0, 0 )
mad  r0.rgba,  t0, c4,  r1

#pragma bind vertexin.Position        = ATTR0
snip
davide, che è successo?
--
"Non mi piacciono le persone ipocrite, di conseguenza sei pregato di
far finta di non conoscermi, la prossima volta che mi vedi."