Difference between revisions of "TEST-STRCMP4CODES"

From SimsWiki
Jump to: navigation, search
Line 1: Line 1:
# Pool depth layer materials
+
EP3-OFB
 +
0xCD7FE87A
 +
0x1C0532FA
 +
0xB00AEAC0
 +
0xFF7D973E
 +
# rug
  
# this is here soley because the layering on standard material
+
 
# is too constrained. We need a layer less than 7, or we'll
+
##############################################################
# render over transparent areas of Sims (e.g. hair) when
+
# Rugs
# they're in the pool at a shallow view angle.
+
#
setc poolLayerColour (0, 0.5, 1.0, 1.0)
+
 
define PoolDepthLayerMaterial()
+
seti rugLayer -2
   material    
+
setb forceFF false
       create DetermineHardwareSupport()
+
setb hasShapeColor false
      if ($useSWVertexShaderPath or $useFixedFunctionPath)
+
 
        shader
+
define RugMaterialFF()
         end
+
   material
      else
+
       shader -layer $rugLayer       
        shader -layer $poolWaterLayer
+
 
             validateRenderShaderContext -vertexFormat position 0 required
+
        if ($hasShapeColor)        
             validateRenderShaderContext -vertexFormat texcoord 0 required
+
            pass -fixedFunction -modifiedEachFrameHint
 +
         else
 +
            pass -fixedFunction
 +
        endif
 +
       
 +
             create LightingStates()
 +
             create AttenuatedMatCoef(1)                     
 +
                   
 +
                             
 +
            ffDepthOffset 2           
 
              
 
              
             pass
+
             alphaTest true 127
              alphaBlend srcFactor(srcAlpha) add dstFactor(invSrcAlpha)
+
            alphaTestFunction acceptIfGreater
      depthTest true -enableDepthWrite false
+
            depthTest true -enableDepthWrite false                      
              #fillmode wireframe
+
           
              shaderProgram -target vertexProgram -method compile -version 1_1
+
            colorScalar (0.8, 0.8, 0.8, 1)
                  bindConstants 0 -bindingID geomToClip -constantCount 4
+
           
                  bindConstants 4 -bindingID immediateData -data ($poolLayerColour)
+
            if ($hasShapeColor)
                 
+
               tsEdithShapeColor $currentMaterialName
                  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
+
               stage
                   shaderSource                 
+
                   texture $rugTexture
                    float4 PixelMain(float4 color : COLOR) : COLOR
+
                  ffTextureCoordsSource 0
                    {                                           
+
                  # add the lightmap lighting to any direct lights.
                        return color;
+
  # the light map has been prescaled by 0.5
                    }
+
  textureBlend multiply(texture colorScalar) select(texture)
                   endShaderSource
+
              end
               end                      
+
             
             end         
+
            else
         end
+
                                                     
 +
              stage
 +
                  texture "floorLightMap_${page}"
 +
                   ffTextureCoordsSource 1
 +
                  # add the lightmap lighting to any direct lights.
 +
  # the light map has been prescaled by 0.5
 +
  textureBlend multiply(texture colorScalar) select(texture)
 +
               end
 +
                                                           
 +
              stage
 +
                  texture $rugTexture
 +
                  textureAddressing clamp clamp
 +
                  ffTextureCoordsSource 0
 +
  textureBlend multiplyScale2(texture outRegister) select(texture)
 +
              end #end stage             
 +
             endif           
 +
                       
 +
        end #pass     
 +
      end #end shader 
 +
  end #end material
 +
enddef
 +
 
 +
setv3 matdiffuse (0.8, 0.8, 0.8)
 +
 
 +
define RugMaterialGen()
 +
  material     
 +
      create DetermineHardwareSupport()          
 +
     
 +
      #trace "$currentMaterialName : $forceFF"
 +
     
 +
      if (not $hasShapeColor and ($useHWShader1Path or $useHWShader2Path))
 +
         create RugMaterialHW()
 +
      else
 +
        create RugMaterialFF()
 +
 
 +
        # ultimate fallback pass? no light map, one stage.
 +
  shader -layer $rugLayer
 +
  validateRenderShaderContext -vertexFormat position 0 required
 +
  validateRenderShaderContext -vertexFormat normal 0 required
 +
  validateRenderShaderContext -vertexFormat texcoord 0 required  
 +
 
 +
  pass -fixedFunction
 +
  create LightingStates()
 +
  create AttenuatedMatCoef(1)
 +
 
 +
  ffDepthOffset 2                       
 +
              alphaTest true 127
 +
              alphaTestFunction acceptIfGreater
 +
              depthTest true -enableDepthWrite false                       
 +
 
 +
  stage
 +
  texture $rugTexture
 +
  textureAddressing clamp clamp
 +
  ffTextureCoordsSource 0
 +
  textureBlend multiplyScale2(texture diffuse) select(outRegister)
 +
  end
 +
  end
 +
end
 
       endif
 
       endif
   end
+
   end # material
 
enddef
 
enddef
  
materialDefinition "poolWaterLayer-0"
+
define RugMaterialHW()
   # this layer does nothing but create the caustics tile.
+
   shader -layer $rugLayer
   setDefinition CausticsGeneratorMaterial    
+
      validateRenderShaderContext -vertexFormat position 0 required
end
+
      validateRenderShaderContext -vertexFormat texcoord 0 required       
 +
     
 +
      pass
 +
        alphaTest true 127
 +
        alphaTestFunction acceptIfGreater
 +
depthTest true -enableDepthWrite false
 +
depthTestFunction acceptIfLess
 +
             
 +
        shaderProgram -target vertexProgram -method compile -version 1_1
 +
            bindConstants 0 -bindingID geomToCamera -constantCount 3
 +
            bindConstants 3 -bindingID cameraToClipWithDepthOffset -constantCount 4 -data(2, 2, 2, 2)
 +
           
 +
            shaderSource
 +
              float4x3 geomToCameraMatrix  : register(c0);                 
 +
              float4x4 cameraToClipWithDOMatrix : register(c3);
 +
             
 +
              struct cVertexIn
 +
              {
 +
                  float3 mPosition : POSITION0; 
 +
                  float2 mTC0 : TEXCOORD0;                 
 +
                  float2 mTC1 : TEXCOORD1;
 +
              };
 +
             
 +
              struct cVertexOut
 +
              {
 +
                  float4 mClipPosition : POSITION;                   
 +
                  float2 mTC0 : TEXCOORD0;
 +
                  float2 mTC1 : TEXCOORD1;
 +
              };
 +
             
 +
              cVertexOut VertexMain(cVertexIn vertexIn)
 +
              {               
 +
                  cVertexOut result;                                                                       
 +
                  float3 pos = mul(float4(vertexIn.mPosition, 1), geomToCameraMatrix);
 +
                  result.mClipPosition = mul(float4(pos, 1), cameraToClipWithDOMatrix);                   
 +
                  result.mTC0 = vertexIn.mTC0;
 +
                  result.mTC1 = vertexIn.mTC1;
 +
                  return result;       
 +
              }
 +
             
 +
            endShaderSource
 +
        end 
 +
 
 +
        shaderProgram -target pixelProgram -method assemble
 +
            bindConstants 0 -bindingID immediateData -data($matdiffuse, 1)
 +
           
 +
            shaderSource
 +
              ps_1_1
 +
              def c2, 1,1,1,1
 +
              tex t0 ; base
 +
              tex t1 ; lightmap
 +
             
 +
              mul r0, t0, t1  ; base floor * light map                             
 +
              mul_x2 r0.rgb, r0, c0 ; scale at the end to prevent precision/LDR errors
 +
              mov r0.a, t0.a             
 +
            endShaderSource
 +
        end # end shader program
 +
                   
 +
        sampler 0
 +
            texture $rugTexture
 +
            textureAddressing clamp clamp
 +
        end
 +
       
 +
        sampler 1
 +
texture "floorLightMap_${page}"
 +
end
 +
      end
 +
   end    
 +
enddef
  
materialDefinition "poolWaterLayer-1"
+
materialDefinition RugMaterial
   setDefinition PoolDepthLayerMaterial 
+
   addParam rugTexture rug
   addParam poolLayerColour (0, 0.5, 1.0, 0.2)
+
   addParam page 0
 +
  addParam stdMatDiffCoef (0.8, 0.8, 0.8)
 +
  addParam stdMatSpecPower 0
 +
  addParam stdMatEmissiveCoef 0,0,0
 +
  addParam stdMatSpecCoef 0,0,0
 +
  setDefinition RugMaterialGen
 
end
 
end
materialDefinition "poolWaterLayer-2"
+
 
   setDefinition PoolDepthLayerMaterial 
+
materialDefinition RugMaterialEdithColor
   addParam poolLayerColour (0, 0.5, 1.0, 0.2)  
+
   addParam rugTexture rug
end
+
   addParam page 0
materialDefinition "poolWaterLayer-3"
+
  addParam stdMatDiffCoef (0.8, 0.8, 0.8)
   setDefinition PoolDepthLayerMaterial
+
   addParam stdMatSpecPower 0
   addParam poolLayerColour (0, 0.5, 1.0, 0.5) 
+
   addParam stdMatEmissiveCoef 0,0,0
 +
  addParam stdMatSpecCoef 0,0,0
 +
  addParam hasShapeColor true
 +
  setDefinition RugMaterialGen
 
end
 
end

Revision as of 03:22, 7 September 2007

EP3-OFB 0xCD7FE87A 0x1C0532FA 0xB00AEAC0 0xFF7D973E

  1. rug


  1. Rugs

seti rugLayer -2 setb forceFF false setb hasShapeColor false

define RugMaterialFF()

  material
     shader -layer $rugLayer         
        if ($hasShapeColor)         
           pass -fixedFunction -modifiedEachFrameHint
        else
           pass -fixedFunction
        endif
        
           create LightingStates() 
           create AttenuatedMatCoef(1)                       
                   
                             
           ffDepthOffset 2            
           
           alphaTest true 127
           alphaTestFunction acceptIfGreater
           depthTest true -enableDepthWrite false                        
           
           colorScalar (0.8, 0.8, 0.8, 1)
           
           if ($hasShapeColor)
              tsEdithShapeColor $currentMaterialName
              
              stage
                 texture $rugTexture
                 ffTextureCoordsSource 0
                 # add the lightmap lighting to any direct lights.

# the light map has been prescaled by 0.5 textureBlend multiply(texture colorScalar) select(texture)

              end
              
           else
                                                     
              stage
                 texture "floorLightMap_${page}"
                 ffTextureCoordsSource 1
                 # add the lightmap lighting to any direct lights.

# the light map has been prescaled by 0.5 textureBlend multiply(texture colorScalar) select(texture)

              end
                                                            
              stage
                 texture $rugTexture
                 textureAddressing clamp clamp
                 ffTextureCoordsSource 0					

textureBlend multiplyScale2(texture outRegister) select(texture)

              end #end stage               
           endif            
                       
        end #pass      
     end #end shader   
  end #end material 

enddef

setv3 matdiffuse (0.8, 0.8, 0.8)

define RugMaterialGen()

  material      
     create DetermineHardwareSupport()         
     
     #trace "$currentMaterialName : $forceFF"
     
     if (not $hasShapeColor and ($useHWShader1Path or $useHWShader2Path))
        create RugMaterialHW()
     else
        create RugMaterialFF()
        # ultimate fallback pass? no light map, one stage. 

shader -layer $rugLayer validateRenderShaderContext -vertexFormat position 0 required validateRenderShaderContext -vertexFormat normal 0 required validateRenderShaderContext -vertexFormat texcoord 0 required

pass -fixedFunction create LightingStates() create AttenuatedMatCoef(1)

ffDepthOffset 2

              alphaTest true 127
              alphaTestFunction acceptIfGreater
              depthTest true -enableDepthWrite false                        

stage texture $rugTexture textureAddressing clamp clamp ffTextureCoordsSource 0 textureBlend multiplyScale2(texture diffuse) select(outRegister) end end end

     endif
  end # material 

enddef

define RugMaterialHW()

  shader -layer $rugLayer
     validateRenderShaderContext -vertexFormat position 0 required
     validateRenderShaderContext -vertexFormat texcoord 0 required         
     
     pass
        alphaTest true 127
        alphaTestFunction acceptIfGreater

depthTest true -enableDepthWrite false depthTestFunction acceptIfLess

        shaderProgram -target vertexProgram -method compile -version 1_1
           bindConstants 0 -bindingID geomToCamera -constantCount 3
           bindConstants 3 -bindingID cameraToClipWithDepthOffset -constantCount 4 -data(2, 2, 2, 2) 
           
           shaderSource
              float4x3 geomToCameraMatrix  : register(c0);                  
              float4x4 cameraToClipWithDOMatrix : register(c3);
              
              struct cVertexIn
              {
                 float3 mPosition : POSITION0;   
                 float2 mTC0 : TEXCOORD0;                  
                 float2 mTC1 : TEXCOORD1;
              };
              
              struct cVertexOut
              {
                 float4 mClipPosition : POSITION;                     
                 float2 mTC0 : TEXCOORD0;
                 float2 mTC1 : TEXCOORD1;
              };
              
              cVertexOut VertexMain(cVertexIn vertexIn)
              {                 
                 cVertexOut result;                                                                        
                 float3 pos = mul(float4(vertexIn.mPosition, 1), geomToCameraMatrix);
                 result.mClipPosition = mul(float4(pos, 1), cameraToClipWithDOMatrix);                     
                 result.mTC0 = vertexIn.mTC0;
                 result.mTC1 = vertexIn.mTC1;
                 return result;         
              }
              
           endShaderSource
        end   
        shaderProgram -target pixelProgram -method assemble
           bindConstants 0 -bindingID immediateData -data($matdiffuse, 1)
           
           shaderSource
              ps_1_1
              def c2, 1,1,1,1
              tex t0 ; base
              tex t1 ; lightmap
              
              mul r0, t0, t1  ; base floor * light map                              
              mul_x2 r0.rgb, r0, c0 ; scale at the end to prevent precision/LDR errors
              mov r0.a, t0.a               
           endShaderSource
        end # end shader program
                    
        sampler 0
           texture $rugTexture
           textureAddressing clamp clamp
        end
        
        sampler 1

texture "floorLightMap_${page}" end

     end
  end   

enddef

materialDefinition RugMaterial

  addParam rugTexture rug
  addParam page 0
  addParam stdMatDiffCoef (0.8, 0.8, 0.8)
  addParam stdMatSpecPower 0
  addParam stdMatEmissiveCoef 0,0,0
  addParam stdMatSpecCoef 0,0,0
  setDefinition RugMaterialGen

end

materialDefinition RugMaterialEdithColor

  addParam rugTexture rug
  addParam page 0
  addParam stdMatDiffCoef (0.8, 0.8, 0.8)
  addParam stdMatSpecPower 0
  addParam stdMatEmissiveCoef 0,0,0
  addParam stdMatSpecCoef 0,0,0
  addParam hasShapeColor true
  setDefinition RugMaterialGen

end

Personal tools
Namespaces

Variants
Actions
Navigation
game select
Toolbox