Difference between revisions of "TEST-STRCMP4CODES"

From SimsWiki
Jump to: navigation, search
 
(57 intermediate revisions by one user not shown)
Line 1: Line 1:
EP3-OFB
+
define TransparentMirrorReflection()
0xCD7FE87A
+
0x1C0532FA
+
0xB00AEAC0
+
0xFF7D973E
+
# rug
+
 
+
 
+
##############################################################
+
# Rugs
+
#
+
 
+
seti rugLayer -2
+
setb forceFF false
+
setb hasShapeColor false
+
 
+
define RugMaterialFF()
+
 
   material
 
   material
       shader -layer $rugLayer          
+
       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
  
        if ($hasShapeColor)        
+
define TransparentBlankMirrorMaterial(renderType)
            pass -fixedFunction -modifiedEachFrameHint
+
      shader
         else
+
         validateRenderShaderContext -viewerRenderType  &renderType
            pass -fixedFunction
+
        endif
+
 
          
 
          
             create LightingStates()
+
        pass              
             create AttenuatedMatCoef(1)                     
+
             shaderProgram -target vertexProgram -method assemble
                   
+
              bindConstants 0 -bindingID geomToClip -constantCount 4
                             
+
              shaderSource
             ffDepthOffset 2           
+
                  vs_1_1
 +
                  dcl_position v0
 +
                  m4x4 oPos, v0, c0
 +
              endShaderSource
 +
             end
 
              
 
              
            alphaTest true 127
+
             colorScalar (0,0,0) 0.5
            alphaTestFunction acceptIfGreater
+
             stage
            depthTest true -enableDepthWrite false                       
+
               textureBlend select(colorScalar) select(colorScalar)
           
+
            end             
             colorScalar (0.8, 0.8, 0.8, 1)
+
         end
           
+
       end    
            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
 
enddef
  
setv3 matdiffuse (0.8, 0.8, 0.8)
+
define TransparentMirrorReflectionMaterial()
 
+
define RugMaterialGen()
+
  material     
+
      create DetermineHardwareSupport()        
+
 
        
 
        
       #trace "$currentMaterialName : $forceFF"
+
       shader -layer -9998  # this material must render first
     
+
        validateRenderShaderContext -viewerRenderType $kRenderTypeMirror  # reflection render
      if (not $hasShapeColor and ($useHWShader1Path or $useHWShader2Path))
+
        create RugMaterialHW()
+
      else
+
        create RugMaterialFF()
+
  
         # ultimate fallback pass? no light map, one stage.
+
         pass -renderEachFrame
  shader -layer $rugLayer
+
            renderTarget $reflectionRenderTarget -setViewport viewportFromParentRenderContext
  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
+
            depthTest true -enableDepthWrite true
  texture $rugTexture
+
  textureAddressing clamp clamp
+
  ffTextureCoordsSource 0
+
  textureBlend multiplyScale2(texture diffuse) select(outRegister)
+
  end
+
  end
+
end
+
      endif
+
  end # material
+
enddef
+
  
define RugMaterialHW()
+
            applyStencilStateForOverlappingReflections
  shader -layer $rugLayer
+
 
      validateRenderShaderContext -vertexFormat position 0 required
+
            alphaBlend srcFactor(zero) add dstFactor(one)
      validateRenderShaderContext -vertexFormat texcoord 0 required       
+
 
 +
            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
 
        
 
        
       pass
+
       shader -layer 6     
         alphaTest true 127
+
         validateRenderShaderContext -viewerRenderType $kRenderTypeNormal
         alphaTestFunction acceptIfGreater
+
         pass -modifiedEachFrameHint
depthTest true -enableDepthWrite false
+
            shaderProgram -target vertexProgram -method assemble           
depthTestFunction acceptIfLess
+
              bindConstants 0 -bindingID geomToClip -constantCount 4
             
+
              bindConstants 4 -bindingID clipToViewTarget -constantCount 4
        shaderProgram -target vertexProgram -method compile -version 1_1
+
              shaderSource
            bindConstants 0 -bindingID geomToCamera -constantCount 3
+
                  vs_1_1
            bindConstants 3 -bindingID cameraToClipWithDepthOffset -constantCount 4 -data(2, 2, 2, 2)
+
                  dcl_position v0
           
+
                  def c8,    -0.5, -0.5, 1, 1
            shaderSource
+
                  def c9,    0.5, 0.5, 0, 0
              float4x3 geomToCameraMatrix : register(c0);                 
+
                  def c10,    0.25, 0.25, 0, 0
              float4x4 cameraToClipWithDOMatrix : register(c3);
+
                   m4x4 r0,   v0,  c0
             
+
                   mov oPos, r0
              struct cVertexIn
+
                   mul r2, c9, r0.w
              {
+
                   mad r4, r0, c8, r2
                   float3 mPosition : POSITION0;    
+
                   rcp r3.x, c4.x                                 
                   float2 mTC0 : TEXCOORD0;                 
+
                   rcp r3.y, c5.y
                   float2 mTC1 : TEXCOORD1;
+
                   mov r3.zw, c9.zw
              };
+
                   mul r3, r3, c10
             
+
                   mad r1, r0, r3, r4
              struct cVertexOut
+
                   rcp r1.w, r1.w
              {
+
                   mul oT0.xy, r1.w, r1.xy
                   float4 mClipPosition : POSITION;                   
+
               endShaderSource             
                   float2 mTC0 : TEXCOORD0;
+
             end
                   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
+
            alphaBlend srcFactor(srcAlpha) add dstFactor(invSrcAlpha)
             bindConstants 0 -bindingID immediateData -data($matdiffuse, 1)
+
             depthTest true -enableDepthWrite false
 +
            colorScalar (0,0,0) 0.25
 +
 
 +
            stage
 +
              textureAddressing clamp clamp
 +
              texture $reflectionRenderTarget
 +
              textureBlend select(texture) select(colorScalar)
 +
            end
 
              
 
              
            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
 
         end
       
 
        sampler 1
 
texture "floorLightMap_${page}"
 
end
 
 
       end
 
       end
  end 
 
 
enddef
 
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
+
materialDefinition transparent_mirror_reflection
  addParam rugTexture rug
+
   setDefinition TransparentMirrorReflection
  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
 
end

Latest revision as of 00: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