Difference between revisions of "TEST-STRCMP4CODES"

From SimsWiki
Jump to: navigation, search
Line 1: Line 1:
  pass
+
# Pool depth layer materials
#fillmode wireframe
+
alphaBlend srcFactor(one) add dstFactor(one)
+
+
      shaderProgram -target vertexProgram -method compile -version 1_1
+
     
+
        bindConstants 0 -bindingID geomToClip -constantCount 4
+
        bindConstants 4 -bindingID geomToCamera -constantCount 3
+
     
+
        bindConstants 7 -bindingID frameInfo
+
     
+
        bindConstants 11 -bindingID immediateData -data ($wmXRepeat, 0, $wmXWaveHeight, $wmXSpeed)
+
        bindConstants 12 -bindingID immediateData -data (0, $wmYRepeat, $wmYWaveHeight, $wmYSpeed)
+
     
+
        # pre-evaluate these
+
        setf xscale (-$wmXRepeat * $wmXWaveHeight)
+
        setf yscale (-$wmYRepeat * $wmYWaveHeight)
+
        bindConstants 13 -bindingID immediateData -data ($xscale,$yscale, 1,0)
+
        bindConstants 14 -bindingID allStandardLightData -constantCount 4 -constantType float
+
        bindConstants 18 -bindingID cameraToGlobal -constantCount 3
+
 
+
        shaderSource
+
     
+
            float4 frameInfo : register(c7);
+
            float4 waveDataX : register(c11);
+
            float4 waveDataY : register(c12);
+
            float4 waveDataHelper : register(c13);
+
            float4x4 clipSpaceMatrix : register(c0);
+
            float4x3 cameraSpaceMatrix : register(c4);
+
            float4x3 cameraToGlobalMatrix : register(c18);
+
           
+
            float4 lightDirection : register(c14);
+
            float4 lightColor : register(c15);
+
            const static float4 refractionWeights={1,1,2,0};
+
           
+
            struct InputVertex
+
            {
+
              float4 position: POSITION0;
+
              float3 normal : NORMAL0;
+
              float2 texc : TEXCOORD0;
+
            };
+
           
+
            struct OutputVertex
+
            {
+
              float4 clipPosition : POSITION;
+
              float3 normal : TEXCOORD0;
+
              float3 viewVector : TEXCOORD1;
+
       
+
            };
+
           
+
            static float2 waveCenter1 = {0.0, 0.0};
+
            static float2 waveCenter2 = {-0.6, 0.2};
+
           
+
            static float2 timeScale = {2,1};
+
            static float2 waveHeight = {0.04, 0.02};
+
            static float2 distScale = {12, 8};
+
           
+
           
+
           
+
            float4 ComputeWavePositionTwoWay(float2 pos1, float2 pos2)
+
            {
+
           
+
  float2 vec;
+
              float4 dist;
+
             
+
              vec = waveCenter1 - pos1;
+
              dist.x = dot(vec, vec);
+
             
+
              vec = waveCenter2 - pos1;
+
              dist.y = dot(vec,vec);
+
             
+
  vec = waveCenter2 - pos2;
+
              dist.z = dot(vec, vec);
+
             
+
              vec = waveCenter2 - pos2;
+
              dist.w = dot(vec,vec);
+
 
+
  dist *= distScale.xyxy;
+
 
+
  float4 sinResult = sin(dist + frameInfo.w * timeScale.xyxy);
+
  
  //sinResult = 1.0- abs(sinResult);
+
# this is here soley because the layering on standard material
+
# is too constrained. We need a layer less than 7, or we'll
  return(sinResult);
+
# render over transparent areas of Sims (e.g. hair) when
+
# they're in the pool at a shallow view angle.
             }
+
setc poolLayerColour (0, 0.5, 1.0, 1.0)
 +
define PoolDepthLayerMaterial()
 +
  material   
 +
      create DetermineHardwareSupport()  
 +
      if ($useSWVertexShaderPath or $useFixedFunctionPath)
 +
        shader
 +
        end
 +
      else
 +
        shader -layer $poolWaterLayer
 +
             validateRenderShaderContext -vertexFormat position 0 required
 +
            validateRenderShaderContext -vertexFormat texcoord 0 required
 
              
 
              
             float2 ComputeWavePosition(float2 pos1)
+
             pass
            {
+
              alphaBlend srcFactor(srcAlpha) add dstFactor(invSrcAlpha)
           
+
      depthTest true -enableDepthWrite false
  float2 vec;
+
              #fillmode wireframe
              float2 dist;
+
              shaderProgram -target vertexProgram -method compile -version 1_1
 
+
                  bindConstants 0 -bindingID geomToClip -constantCount 4
  vec = waveCenter1 - pos1;
+
                  bindConstants 4 -bindingID immediateData -data ($poolLayerColour)
              dist.x = dot(vec, vec);
+
                 
 +
                  shaderSource
 +
                    float4x4 clipSpaceMatrix      : register(c0);
 +
                    float4  poolLayer            : register(c4);
 +
                   
 +
                    struct cVertexIn
 +
                    {
 +
                        float3 mPosition : POSITION0; 
 +
                        float2 alpha    : TEXCOORD0;                
 +
                    };
 +
                   
 +
                    struct cVertexOut
 +
                    {
 +
                        float4 mClipPosition : POSITION;                   
 +
                        float4 mColor        : COLOR0;
 +
                    };
 +
                   
 +
                    cVertexOut VertexMain(cVertexIn vertexIn)
 +
                    {               
 +
                        cVertexOut result;                                                                       
 +
                        result.mClipPosition = mul(float4(vertexIn.mPosition, 1), clipSpaceMatrix);                    
 +
                        result.mColor = float4(poolLayer.r, poolLayer.g, poolLayer.b, poolLayer.a * vertexIn.alpha.x);  
 +
                        return result;       
 +
                    }
 +
                   
 +
                  endShaderSource
 +
              end                     
 
                
 
                
               vec = waveCenter2 - pos1;
+
               shaderProgram -target pixelProgram -method compile -version 1_1
              dist.y = dot(vec,vec);
+
                  shaderSource                 
               
+
                    float4 PixelMain(float4 color : COLOR) : COLOR
  dist *= distScale.xy;
+
                    {                                           
 
+
                        return color;
  float2 sinResult = sin(dist + frameInfo.w * timeScale);
+
                    }
 +
                  endShaderSource
 +
              end                       
 +
            end       
 +
        end
 +
      endif
 +
  end
 +
enddef
  
  //sinResult = 1.0- abs(sinResult);
+
materialDefinition "poolWaterLayer-0"
+
  # this layer does nothing but create the caustics tile.
  return(sinResult);
+
  setDefinition CausticsGeneratorMaterial 
+
end
            }
+
           
+
            OutputVertex VertexMain( InputVertex inputVertex)
+
            {
+
              // Do Y-direction waves
+
              // r0 = (x, y, z, t)
+
             
+
              OutputVertex outputVertex;
+
+
float4 pos = inputVertex.position;
+
+
float2 sample1, sample2, sample3;
+
+
sample1 = inputVertex.position;
+
sample2 = inputVertex.position;
+
sample3 = inputVertex.position;
+
sample2.x += 0.1;
+
sample3.y += 0.1;
+
+
float4 heights1=ComputeWavePositionTwoWay(sample1, sample2);
+
float2 heights2=ComputeWavePosition(sample3);
+
+
+
float3 pos1, pos2;
+
pos1 = pos;
+
pos2 = pos;
+
+
  pos.z += (heights1.x* waveHeight.x);// + heights1.y *  waveHeight.y);
+
  pos1.z += (heights1.z* waveHeight.x);// + heights1.w *  waveHeight.y);
+
  pos2.z += (heights2.x* waveHeight.x);// + heights2.y *  waveHeight.y);
+
+
pos1.x +=0.1;
+
pos2.y +=0.1;
+
float3 vec1, vec2;
+
vec1 = normalize(pos1 - pos);
+
vec2 = normalize(pos2 - pos);
+
+
float3 normal = cross(vec1, vec2);
+
+
normal = mul(normal, (float3x3)cameraSpaceMatrix);
+
  
float3 viewVector = mul(pos, cameraSpaceMatrix);
+
materialDefinition "poolWaterLayer-1"
+
  setDefinition PoolDepthLayerMaterial 
outputVertex.viewVector = normalize(-viewVector);
+
  addParam poolLayerColour (0, 0.5, 1.0, 0.2)
+
end
              outputVertex.clipPosition = mul(pos, clipSpaceMatrix);
+
materialDefinition "poolWaterLayer-2"
              outputVertex.normal = normal;
+
  setDefinition PoolDepthLayerMaterial  
              return(outputVertex);
+
  addParam poolLayerColour (0, 0.5, 1.0, 0.2)  
             
+
end
        }
+
materialDefinition "poolWaterLayer-3"
           
+
  setDefinition PoolDepthLayerMaterial
        endShaderSource
+
  addParam poolLayerColour (0, 0.5, 1.0, 0.5)    
     
+
end
      end # end shaderProgram
+
       
+
      shaderProgram -target pixelProgram -method assemble
+
        bindConstants 0 -bindingID allStandardLightData -constantCount 4 -constantType float
+
 
+
        shaderSource
+
            ps_2_0
+
            def c10,20,4,0,0
+
            def c11, 0,0.5,1,2
+
            dcl t0
+
            dcl t1 ; v
+
dcl_cube s0
+
     
+
            nrm r0, t0      ; n
+
           
+
            add r1, r0, r0 ; 2N
+
           
+
            dp3 r1.w, r0, t1 ; N.V
+
mad r2.xyz, r1, r1.w, -t1    ; 2N * (N.V) -V
+
+
texld r5, r2, s0
+
+
dp3 r3.x, r2, c0  ; R.L
+
pow r4, r3.x, c10.x
+
+
mov_sat r1.x, r1.w
+
+
add r6.x, c11.z, -r1.x      ; 1 - Fresnel
+
+
pow r3.y, r6.x, c10.y   ; N.V ^ 4
+
+
mul r7, r5, r3.y
+
mad r4, r4, r3.y, r7
+
mul r4, r4, c11.y
+
+
mov oC0, r4
+
           
+
        endShaderSource
+
      end
+
     
+
      sampler 0
+
texture $wmReflectionTexture
+
textureAddressing clamp clamp clamp
+
      end
+
  end  # pass
+
 
+
enddef
+

Revision as of 00:48, 3 September 2007

  1. Pool depth layer materials
  1. this is here soley because the layering on standard material
  2. is too constrained. We need a layer less than 7, or we'll
  3. render over transparent areas of Sims (e.g. hair) when
  4. they're in the pool at a shallow view angle.

setc poolLayerColour (0, 0.5, 1.0, 1.0) define PoolDepthLayerMaterial()

  material     
     create DetermineHardwareSupport() 
     if ($useSWVertexShaderPath or $useFixedFunctionPath)
        shader
        end
     else
        shader -layer $poolWaterLayer
           validateRenderShaderContext -vertexFormat position 0 required
           validateRenderShaderContext -vertexFormat texcoord 0 required
           
           pass
              alphaBlend srcFactor(srcAlpha) add dstFactor(invSrcAlpha)

depthTest true -enableDepthWrite false

              #fillmode wireframe
              shaderProgram -target vertexProgram -method compile -version 1_1
                 bindConstants 0 -bindingID geomToClip -constantCount 4
                 bindConstants 4 -bindingID immediateData -data ($poolLayerColour)
                 
                 shaderSource
                    float4x4 clipSpaceMatrix      : register(c0);
                    float4   poolLayer            : register(c4);
                    
                    struct cVertexIn
                    {
                       float3 mPosition : POSITION0;   
                       float2 alpha     : TEXCOORD0;                  
                    };
                    
                    struct cVertexOut
                    {
                       float4 mClipPosition : POSITION;                     
                       float4 mColor        : COLOR0;
                    };
                    
                    cVertexOut VertexMain(cVertexIn vertexIn)
                    {                 
                       cVertexOut result;                                                                        
                       result.mClipPosition = mul(float4(vertexIn.mPosition, 1), clipSpaceMatrix);                     
                       result.mColor = float4(poolLayer.r, poolLayer.g, poolLayer.b, poolLayer.a * vertexIn.alpha.x); 
                       return result;         
                    }
                    
                 endShaderSource
              end                       
              
              shaderProgram -target pixelProgram -method compile -version 1_1
                 shaderSource                  
                    float4 PixelMain(float4 color : COLOR) : COLOR
                    {                                             
                       return color;
                    }
                 endShaderSource
              end                        
           end         
        end
     endif
  end

enddef

materialDefinition "poolWaterLayer-0"

  # this layer does nothing but create the caustics tile.
  setDefinition CausticsGeneratorMaterial   

end

materialDefinition "poolWaterLayer-1"

  setDefinition PoolDepthLayerMaterial   
  addParam poolLayerColour (0, 0.5, 1.0, 0.2)

end materialDefinition "poolWaterLayer-2"

  setDefinition PoolDepthLayerMaterial  
  addParam poolLayerColour (0, 0.5, 1.0, 0.2)    

end materialDefinition "poolWaterLayer-3"

  setDefinition PoolDepthLayerMaterial
  addParam poolLayerColour (0, 0.5, 1.0, 0.5)   

end

Personal tools
Namespaces

Variants
Actions
Navigation
game select
Toolbox