Difference between revisions of "TEST-STRCMP4CODES"

From SimsWiki
Jump to: navigation, search
m (nei 2)
 
(7 intermediate revisions by one user not shown)
Line 1: Line 1:
shaderSource
+
define TransparentMirrorReflection()
 +
  material
 +
      if (viewerRenderType = $kRenderTypeShadow)
 +
        create StandardShaderShadow()
 +
      else
 +
        if (viewerRenderType = $kRenderTypeThumbnail)
 +
            create TransparentBlankMirrorMaterial($kRenderTypeThumbnail)
 +
        else           
 +
            if (not $mirrorReflectionsEnabled)
 +
              set currentType (viewerRenderType)
 +
              create TransparentBlankMirrorMaterial($currentType)
 +
            else
 +
              create TransparentMirrorReflectionMaterial()
 +
            endif           
 +
        endif       
 +
      endif
 +
  end
 +
enddef
  
float4 frameInfo : register(c7);
+
define TransparentBlankMirrorMaterial(renderType)
float4 waveDataX : register(c11);
+
      shader
float4 waveDataY : register(c12);
+
        validateRenderShaderContext -viewerRenderType  &renderType
float4 waveDataHelper : register(c13);
+
       
float4x4 clipSpaceMatrix : register(c0);
+
        pass           
float4x3 cameraSpaceMatrix : register(c4);
+
            shaderProgram -target vertexProgram -method assemble
float4x3 cameraToGlobalMatrix : register(c18);
+
              bindConstants 0 -bindingID geomToClip -constantCount 4
float4x3 cameraToGeomMatrix : register(c21);
+
              shaderSource
+
                  vs_1_1
float4 nightColor: register(c25);
+
                  dcl_position v0
float4 waterTint: register(c28);
+
                  m4x4 oPos, v0, c0
           
+
              endShaderSource
float4 lightDirection : register(c14);
+
            end
float4 lightColor : register(c15);
+
           
float4 lightSpecular : register(c16);
+
            colorScalar (0,0,0) 0.5
+
            stage
const static float4 refractionWeights={1,1,2,0};
+
              textureBlend select(colorScalar) select(colorScalar)
### MODDED11 # in-lot lotskirt water: Just alter the highlit RGB values (in bold style)
+
            end           
const static float4 layerBlue={0.098, 0.336, 0.469, 1.0};
+
        end
+
      end     
struct InputVertex
+
enddef
{
+
 
float3 position: POSITION0;
+
define TransparentMirrorReflectionMaterial()
float3 normal : NORMAL0;
+
     
float2 alpha  : TEXCOORD1;
+
      shader -layer -9998  # this material must render first
};
+
        validateRenderShaderContext -viewerRenderType $kRenderTypeMirror # reflection render
+
 
struct OutputVertex
+
        pass -renderEachFrame
{
+
            renderTarget $reflectionRenderTarget -setViewport viewportFromParentRenderContext
float4 clipPosition : POSITION;
+
 
float4 sPos        : TEXCOORD0;
+
            depthTest true -enableDepthWrite true
float2 Wave0        : TEXCOORD1;
+
 
float2 Wave1        : TEXCOORD2;
+
            applyStencilStateForOverlappingReflections
float2 Wave2        : TEXCOORD3;
+
 
float2 Wave3        : TEXCOORD4;
+
            alphaBlend srcFactor(zero) add dstFactor(one)
float3 Eye          : TEXCOORD5;
+
 
float4 specular    : COLOR0;    
+
            cullmode none
float4 colorTint    : COLOR1;
+
 
};
+
            shaderProgram -target vertexProgram -method assemble           
           
+
              bindConstants 0 -bindingID geomToClipFromParentView -constantCount 4
+
              shaderSource
+
                  vs_1_1
OutputVertex VertexMain( InputVertex inputVertex)
+
                  dcl_position v0
{
+
                  def c5, 1,0,0,1
// Do Y-direction waves
+
                  m4x4 r0,   v0,  c0
// r0 = (x, y, z, t)
+
                  mov oPos.x,  -r0
+
                  mov oPos.yzw, r0                 
OutputVertex outputVertex;
+
              endShaderSource
+
            end
float4 posAndTime;
+
        end
posAndTime.xyz = inputVertex.position;
+
      end
posAndTime.w = frameInfo.w;
+
 
+
      shader -layer 6
float temp = dot(posAndTime, waveDataX);
+
        validateRenderShaderContext -viewerRenderType $kRenderTypeNormal
float z = sin(temp) * waveDataX.z + inputVertex.position.z;
+
        pass -modifiedEachFrameHint
temp = dot(posAndTime, waveDataY);
+
            shaderProgram -target vertexProgram -method assemble           
posAndTime.z = z + sin(temp) * waveDataY.z ;//-0.1f; //The -.01 is a fudge factor to remove some of the edge creep associated with moving the height of the wave. -tom
+
              bindConstants 0 -bindingID geomToClip -constantCount 4
posAndTime.w = 1.0f;
+
              bindConstants 4 -bindingID clipToViewTarget -constantCount 4
+
              shaderSource
outputVertex.clipPosition = mul( posAndTime, clipSpaceMatrix);
+
                  vs_1_1
outputVertex.sPos = float4(0.5f*(outputVertex.clipPosition.ww - outputVertex.clipPosition.xy), outputVertex.clipPosition.ww);
+
                  dcl_position v0
+
                  def c8,   -0.5, -0.5, 1, 1
float3 waveNormal = normalize(inputVertex.normal + float3(cos(temp)*waveDataHelper.xy, 0));
+
                  def c9,    0.5, 0.5, 0, 0
float3 cameraSpaceNormal = normalize(mul(waveNormal, cameraSpaceMatrix));
+
                  def c10,    0.25, 0.25, 0, 0
float3 cameraSpacePosition = mul( posAndTime, cameraSpaceMatrix);
+
                  m4x4 r0,  v0,  c0
float3 viewVector = normalize(-cameraSpacePosition);
+
                  mov oPos, r0
+
                  mul r2, c9, r0.w
float3 halfVector = normalize(viewVector + lightDirection);
+
                  mad r4, r0, c8, r2
outputVertex.specular = lightSpecular*pow(dot(cameraSpaceNormal, halfVector), 50)*nightColor*lightColor*0.5;
+
                  rcp r3.x, c4.x                                 
+
                  rcp r3.y, c5.y
+
                  mov r3.zw, c9.zw
float2 fTranslation=float2(fmod(frameInfo.w, 100)*0.005, fmod(frameInfo.w, 100)*0.005);
+
                  mul r3, r3, c10
float2 vTexCoords = posAndTime.xy*0.05;
+
                  mad r6, r0, r3, r4
               
+
                  mov oT0, r6.xyww
// Output bump layers texture coordinates   
+
              endShaderSource             
float fSinTranslation=sin(fTranslation*100)*0.005;
+
            end
float2 vTranslation0=fTranslation+fSinTranslation;
+
 
float2 vTranslation1=fTranslation-fSinTranslation;
+
            alphaBlend srcFactor(srcAlpha) add dstFactor(invSrcAlpha)
float2 vTranslation2=fTranslation;
+
            depthTest true -enableDepthWrite false
               
+
            colorScalar (0,0,0) 0.25
// Scale texture coordinates to get mix of low/high frequency details
+
 
outputVertex.Wave0.xy = vTexCoords.xy*0.01+fTranslation*2.0;
+
            stage
outputVertex.Wave1.xy = vTexCoords.xy+fTranslation*2.5;
+
              textureTransformType vector3 homogeneous
outputVertex.Wave2.xy = vTexCoords.xy+fTranslation*-2.3;
+
              textureAddressing clamp clamp
outputVertex.Wave3.xy = vTexCoords.xy*0.1+fTranslation*1.5;               
+
              texture $reflectionRenderTarget
                                   
+
              textureBlend select(texture) select(colorScalar)
// compute binormal
+
            end
float3 binormal = normalize(cross(waveNormal, float3(1.0f, 0.0f, 0.0f)));              
+
                     
float3 tangent = normalize(cross(binormal, waveNormal));
+
        end
           
+
      end
// tangent space matrix
+
     
float3x3 objToTangentSpace = float3x3(tangent, binormal, waveNormal);
+
      shader -layer 6     
           
+
        validateRenderShaderContext -viewerRenderType $kRenderTypeNormal
float3 viewVectorInObjSpace = mul(viewVector, (float3x3)cameraToGeomMatrix);
+
        pass -modifiedEachFrameHint
           
+
            shaderProgram -target vertexProgram -method assemble           
outputVertex.Eye.xyz = mul(objToTangentSpace, viewVectorInObjSpace);
+
              bindConstants 0 -bindingID geomToClip -constantCount 4
outputVertex.colorTint = waterTint;
+
              bindConstants 4 -bindingID clipToViewTarget -constantCount 4
outputVertex.colorTint.a = inputVertex.alpha.xxxx;
+
              shaderSource
// outputVertex.color = waterTint.xxxx;
+
                  vs_1_1
+
                  dcl_position v0
return(outputVertex);
+
                  def c8,    -0.5, -0.5, 1, 1
}
+
                  def c9,    0.5,  0.5, 0, 0
+
                  def c10,    0.25, 0.25, 0, 0
endShaderSource 
+
                  m4x4 r0,  v0,  c0
end # shaderProgram
+
                  mov oPos, r0
 +
                  mul r2, c9, r0.w
 +
                  mad r4, r0, c8, r2
 +
                  rcp r3.x, c4.x                                 
 +
                  rcp r3.y, c5.y
 +
                  mov r3.zw, c9.zw
 +
                  mul r3, r3, c10
 +
                  mad r1, r0, r3, r4
 +
                  rcp r1.w, r1.w
 +
                  mul oT0.xy, r1.w, r1.xy
 +
              endShaderSource             
 +
             end
 +
 
 +
            alphaBlend srcFactor(srcAlpha) add dstFactor(invSrcAlpha)
 +
            depthTest true -enableDepthWrite false
 +
            colorScalar (0,0,0) 0.25
 +
 
 +
            stage
 +
              textureAddressing clamp clamp
 +
              texture $reflectionRenderTarget
 +
              textureBlend select(texture) select(colorScalar)
 +
            end
 +
           
 +
        end
 +
      end
 +
enddef
 +
 
 +
#---------------------------------------------------------------------------------------------------------------#
 +
 
 +
materialDefinition transparent_mirror_reflection
 +
  setDefinition TransparentMirrorReflection
 +
end

Latest revision as of 06:44, 9 July 2009

define TransparentMirrorReflection()

  material
     if (viewerRenderType = $kRenderTypeShadow)
        create StandardShaderShadow()
     else
        if (viewerRenderType = $kRenderTypeThumbnail)
           create TransparentBlankMirrorMaterial($kRenderTypeThumbnail)
        else            
           if (not $mirrorReflectionsEnabled)
              set currentType (viewerRenderType)
              create TransparentBlankMirrorMaterial($currentType)
           else
              create TransparentMirrorReflectionMaterial()
           endif            
        endif         
     endif
  end

enddef

define TransparentBlankMirrorMaterial(renderType)

     shader
        validateRenderShaderContext -viewerRenderType  &renderType
        
        pass             
           shaderProgram -target vertexProgram -method assemble
              bindConstants 0 -bindingID geomToClip -constantCount 4
              shaderSource
                 vs_1_1
                 dcl_position v0
                 m4x4 oPos, v0, c0
              endShaderSource
           end
           
           colorScalar (0,0,0) 0.5
           stage
              textureBlend select(colorScalar) select(colorScalar)
           end            
        end
     end      

enddef

define TransparentMirrorReflectionMaterial()

     shader -layer -9998   # this material must render first
        validateRenderShaderContext -viewerRenderType $kRenderTypeMirror  # reflection render
        pass -renderEachFrame
           renderTarget $reflectionRenderTarget -setViewport viewportFromParentRenderContext
           depthTest true -enableDepthWrite true
           applyStencilStateForOverlappingReflections
           alphaBlend srcFactor(zero) add dstFactor(one)
           cullmode none
           shaderProgram -target vertexProgram -method assemble            
              bindConstants 0 -bindingID geomToClipFromParentView -constantCount 4
              shaderSource
                 vs_1_1
                 dcl_position v0
                 def c5, 1,0,0,1
                 m4x4 r0,   v0,  c0
                 mov oPos.x,  -r0
                 mov oPos.yzw, r0                  
              endShaderSource
           end
        end
     end
     shader -layer 6
        validateRenderShaderContext -viewerRenderType $kRenderTypeNormal
        pass -modifiedEachFrameHint
           shaderProgram -target vertexProgram -method assemble            
              bindConstants 0 -bindingID geomToClip -constantCount 4
              bindConstants 4 -bindingID clipToViewTarget -constantCount 4
              shaderSource
                 vs_1_1
                 dcl_position v0
                 def c8,    -0.5, -0.5, 1, 1
                 def c9,     0.5,  0.5, 0, 0 
                 def c10,    0.25, 0.25, 0, 0
                 m4x4 r0,   v0,  c0
                 mov oPos, r0
                 mul r2, c9, r0.w
                 mad r4, r0, c8, r2
                 rcp r3.x, c4.x                                   
                 rcp r3.y, c5.y
                 mov r3.zw, c9.zw
                 mul r3, r3, c10
                 mad r6, r0, r3, r4
                 mov oT0, r6.xyww
              endShaderSource               
           end
           alphaBlend srcFactor(srcAlpha) add dstFactor(invSrcAlpha)
           depthTest true -enableDepthWrite false
           colorScalar (0,0,0) 0.25
           stage
              textureTransformType vector3 homogeneous
              textureAddressing clamp clamp
              texture $reflectionRenderTarget
              textureBlend select(texture) select(colorScalar)
           end
                      
        end
     end
     
     shader -layer 6      
        validateRenderShaderContext -viewerRenderType $kRenderTypeNormal
        pass -modifiedEachFrameHint
           shaderProgram -target vertexProgram -method assemble            
              bindConstants 0 -bindingID geomToClip -constantCount 4
              bindConstants 4 -bindingID clipToViewTarget -constantCount 4
              shaderSource
                 vs_1_1
                 dcl_position v0
                 def c8,    -0.5, -0.5, 1, 1
                 def c9,     0.5,  0.5, 0, 0
                 def c10,    0.25, 0.25, 0, 0
                 m4x4 r0,   v0,  c0
                 mov oPos, r0
                 mul r2, c9, r0.w
                 mad r4, r0, c8, r2
                 rcp r3.x, c4.x                                   
                 rcp r3.y, c5.y
                 mov r3.zw, c9.zw
                 mul r3, r3, c10
                 mad r1, r0, r3, r4
                 rcp r1.w, r1.w
                 mul oT0.xy, r1.w, r1.xy
              endShaderSource               
           end
           alphaBlend srcFactor(srcAlpha) add dstFactor(invSrcAlpha)
           depthTest true -enableDepthWrite false
           colorScalar (0,0,0) 0.25
           stage
              textureAddressing clamp clamp
              texture $reflectionRenderTarget
              textureBlend select(texture) select(colorScalar)
           end
           
        end
     end

enddef

  1. ---------------------------------------------------------------------------------------------------------------#

materialDefinition transparent_mirror_reflection

  setDefinition TransparentMirrorReflection

end

Personal tools
Namespaces

Variants
Actions
Navigation
game select
Toolbox