Difference between revisions of "TEST-STRCMP4CODES"

From SimsWiki
Jump to: navigation, search
 
(22 intermediate revisions by one user not shown)
Line 1: Line 1:
EP6-BV
+
define TransparentMirrorReflection()
0xCD7FE87A
+
  material
0x1C0532FA
+
      if (viewerRenderType = $kRenderTypeShadow)
0x8674B810
+
        create StandardShaderShadow()
0xFF9F1489
+
      else
# glow
+
        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
  
# Used for glow/steam effects: transparency falls off at edges
+
define TransparentMirrorReflectionMaterial()
# of object. (Camera-relative normal looks up into a cube map.)
+
     
define CubeAlphaFalloff()
+
       shader -layer -9998  # this material must render first
  material
+
         validateRenderShaderContext -viewerRenderType $kRenderTypeMirror  # reflection render
       attributes
+
         attribute steamRGB float3
+
        attribute steamAlpha float1
+
      end
+
  
      shader -layer ($stdMatLayer * 18 + 17)
+
        pass -renderEachFrame
        vertexFormatPred position      0 true
+
            renderTarget $reflectionRenderTarget -setViewport viewportFromParentRenderContext
        vertexFormatPred normal        0 true
+
        vertexFormatPred texcoord      0 true
+
        vertexFormatPred blendindices  0 false
+
        vertexFormatPred targetindices 0 false
+
  
create DetermineHardwareSupport()
+
            depthTest true -enableDepthWrite true
+
if ($useFixedFunctionPath or $useSWVertexShaderPath)
+
pass -fixedFunction
+
create LightingStatesNoStdLightsParam(true false)
+
alphaBlend srcFactor(srcAlpha) add dstFactor(one)
+
depthTest true -enableDepthWrite false
+
ffMatCoef -amb (1,1,1) -diff (1,1,1) -emit (0,0,0) -spec (0,0,0) -specPow 0
+
colorScalar $stdMatDiffCoeff $stdMatAlphaMultiplier
+
fillmode $stdMatFillMode
+
  
stage
+
            applyStencilStateForOverlappingReflections
texture $stdMatEnvCubeTextureName -alphaFalloffCubeMap 64 (0, 1, 0) (-30, 255) 5
+
textureMIPFilterHint disabled
+
ffTextureCoordsSource fromNormal
+
textureTransformType vector3
+
textureAddressing clamp clamp clamp
+
textureBlend select(texture:alphaReplicate) multiply(texture colorScalar)
+
end
+
  
stage
+
            alphaBlend srcFactor(zero) add dstFactor(one)
texture $stdMatBaseTextureName ${stdMatBaseTextureParam} 
+
ffTextureCoordsSource 0
+
textureBlend select(colorScalar) multiply(outRegister texture)
+
end
+
end
+
else
+
+
# VS/PS equivelant
+
pass
+
create NonStandardLighting()
+
+
alphaBlend srcFactor(srcAlpha) add dstFactor(one)
+
depthTest true -enableDepthWrite false
+
fillmode $stdMatFillMode
+
  
shaderProgram -target vertexProgram -method assemble
+
            cullmode none
bindConstants 0 -bindingID geomToClip -constantCount 4
+
 
bindConstants 4 -bindingID geomToCamera -constantCount 3
+
            shaderProgram -target vertexProgram -method assemble          
shaderSource
+
              bindConstants 0 -bindingID geomToClipFromParentView -constantCount 4
vs_1_1
+
              shaderSource
dcl_position v0
+
                  vs_1_1
dcl_normal v1
+
                  dcl_position v0
dcl_texcoord v2
+
                  def c5, 1,0,0,1
+
                  m4x4 r0,   v0, c0
m4x4 oPos, v0, c0   ; send to clip space
+
                  mov oPos.x-r0
+
                  mov oPos.yzw, r0                 
mov oT1.xy, v2 ; copy tex coords straight out
+
              endShaderSource
+
            end
m3x3 oT0.xyz, v1, c4  ; transform normal to camera space.
+
        end
+
      end
endShaderSource
+
 
end
+
      shader -layer 6
+
        validateRenderShaderContext -viewerRenderType $kRenderTypeNormal
shaderProgram -target pixelProgram -method assemble
+
        pass -modifiedEachFrameHint
+
            shaderProgram -target vertexProgram -method assemble          
setv3 evalDiffuse ($stdMatDiffCoeff)
+
              bindConstants 0 -bindingID geomToClip -constantCount 4
bindConstants 0 -bindingID immediateData -data ($evalDiffuse, $stdMatAlphaMultiplier)
+
              bindConstants 4 -bindingID clipToViewTarget -constantCount 4
+
              shaderSource
shaderSource
+
                  vs_1_1
ps_1_1
+
                  dcl_position v0
tex t0 ; a cube map
+
                  def c8,    -0.5, -0.5, 1, 1
tex t1 ; a 2D texture
+
                  def c9,    0.5,  0.5, 0, 0
+
                  def c10,    0.25, 0.25, 0, 0
mov r0.rgb, c0 ; output color from the diffuse
+
                  m4x4 r0,  v0c0
+ mul r0.a, t0.a, c0.a  ; alpha = tex0.a * tex1.a * alphaMultiplier
+
                  mov oPos, r0
mul r0.a, r0.a, t1.a
+
                  mul r2, c9, r0.w
+
                  mad r4, r0, c8, r2
endShaderSource
+
                  rcp r3.x, c4.x                                 
+
                  rcp r3.y, c5.y
end
+
                  mov r3.zw, c9.zw
+
                  mul r3, r3, c10
+
                  mad r6, r0, r3, r4
sampler 0
+
                  mov oT0, r6.xyww
texture $stdMatEnvCubeTextureName -alphaFalloffCubeMap 64 (0, 1, 0) (-30, 255) 5
+
              endShaderSource              
textureMIPFilterHint disabled
+
            end
textureAddressing clamp clamp clamp
+
 
end
+
            alphaBlend srcFactor(srcAlpha) add dstFactor(invSrcAlpha)
sampler 1
+
            depthTest true -enableDepthWrite false
texture $stdMatBaseTextureName ${stdMatBaseTextureParam} 
+
            colorScalar (0,0,0) 0.25
end
+
 
+
            stage
end
+
              textureTransformType vector3 homogeneous
+
              textureAddressing clamp clamp
endif
+
              texture $reflectionRenderTarget
      end # shader
+
              textureBlend select(texture) select(colorScalar)
     
+
            end
      #fallback, do nothing
+
                     
      shader
+
        end
 
       end
 
       end
 
        
 
        
   end
+
      shader -layer 6     
enddef
+
        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)
# Various lighting glows.
+
            depthTest true -enableDepthWrite false
#
+
            colorScalar (0,0,0) 0.25
materialDefinition lightingTableBigBulb_glowSphere
+
  setDefinition CubeAlphaFalloff
+
  addParam stdMatLayer 15
+
  addParam stdMatDiffCoeff (1, 1, .8)
+
  addParam stdMatAlphaBlendMode additive
+
  addParam stdMatAlphaMultiplier 0.55
+
  addParam stdMatEnvCubeTextureName lightingStreetlight_glow_alphaFalloff5
+
  addParam stdMatBaseTextureName lightingStreetlight-glowSphere-alpha
+
end
+
  
materialDefinition lightingStreetlight_glowSphereNull
+
            stage
  setDefinition Null
+
              textureAddressing clamp clamp
  addParam stdMatLayer 15
+
              texture $reflectionRenderTarget
  addParam stdMatDiffCoeff (1, 1, 1)
+
              textureBlend select(texture) select(colorScalar)
  addParam stdMatAlphaBlendMode additive
+
            end
  addParam stdMatAlphaMultiplier 1
+
           
  addParam stdMatEnvCubeTextureName steamSphere_alphaFalloff5
+
        end
  addParam stdMatBaseTextureName steam-alpha
+
      end
end
+
enddef
  
materialDefinition lightingStreetlight_glowSphere
+
#---------------------------------------------------------------------------------------------------------------#
  setDefinition CubeAlphaFalloff
+
  addParam stdMatLayer 15
+
  addParam stdMatDiffCoeff (1, 1, .8)
+
  addParam stdMatAlphaBlendMode additive
+
  addParam stdMatAlphaMultiplier 1
+
  addParam stdMatEnvCubeTextureName lightingStreetlight_glow_alphaFalloff5
+
  addParam stdMatBaseTextureName lightingStreetlight-glowSphere-alpha
+
end
+
  
materialDefinition memoryIcon_glowSphere
+
materialDefinition transparent_mirror_reflection
   setDefinition CubeAlphaFalloff
+
   setDefinition TransparentMirrorReflection
  addParam stdMatLayer 15
+
  addParam stdMatDiffCoeff (1, 1, .8)
+
  addParam stdMatAlphaBlendMode additive
+
  addParam stdMatAlphaMultiplier 1
+
 
+
  addParam stdMatEnvCubeTextureName lightingStreetlight_glow_alphaFalloff5
+
  addParam stdMatBaseTextureName reflection3DGlow-envcube6
+
 
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