Difference between revisions of "TEST-STRCMP4CODES"

From SimsWiki
Jump to: navigation, search
Line 1: Line 1:
 
#
 
#
# Various material definitions for the ContentViewer.
+
# Materials used for lamps, mostly for broken states
 
#
 
#
  
# note: don't check this in -- seems to cause a crash if
+
materialDefinition brokenLampSparkFlash
# you don't have the debugger set up correctly
+
  setDefinition StandardMaterial
#enableShaderProgramDebugging -vertex
+
  addParam stdMatLayer 5
 
+
   addParam stdMatLightingEnabled false
# anything extra needed by the contentviewer should be moved
+
   addParam stdMatAlphaBlendMode additive
# from config.matShad to common.matShad.
+
   addParam stdMatAlphaTestEnabled false
#include "config.matshad"
+
   addParam stdMatAlphaMultiplier  3
 
+
   addParam stdMatBaseTextureAlphaReplicate true
# Lab extension stuff
+
   addParam stdMatDiffCoef (1, 1, 1)
 
+
   addParam stdMatBaseTextureEnabled true
define ShowRenderTypeMaterial()
+
   addParam stdMatBaseTextureName fireflyParticle-alpha
   material
+
   addParam stdMatEmissiveCoef (1, 1, 1)
      shader
+
   addParam stdMatBaseTextureAddressingU clamp
        viewerRenderTypePred viewerRenderType
+
   addParam stdMatBaseTextureAddressingV clamp
 
+
        pass -fixedFunction           
+
            ffMatCoef -diff (1, 0, 0)
+
            seti rt (viewerRenderType + 1)
+
            setc rtColor ((floor($rt / 4) % 2), (floor($rt / 2) % 2), (floor($rt) % 2))
+
            ffMatCoef -diff $rtColor
+
            create LightingStates()
+
           
+
            stage
+
              textureBlend select(diffuse) select(diffuse)
+
            end
+
        end
+
      end
+
   end
+
enddef
+
 
+
define TestGlow-AsmVertexProgram(numPass)
+
   vertexFormatPred position 0 true
+
 
+
   shaderProgram -target vertexProgram -method assemble
+
      bindConstants 0 -bindingID geomToCamera -constantCount 3
+
      bindConstants 3 -bindingID cameraToClip -constantCount 4
+
 
+
      shaderSource
+
        vs_1_1
+
        dcl_position v0
+
        dcl_normal  v1
+
 
+
        def c7,$color,0
+
        def c8,$offset,0
+
        def c9,$glowOffset,0
+
        def c10,$glowColor
+
        def c11, &{numPass},&{numPass},&{numPass},0
+
       
+
        add r0, v0, c8    ; add the offset
+
       
+
        ; add the glow offset along the normal
+
        mov  r1, c9
+
        mov  r2, v1
+
        mul  r0, c11, r1  ; numPass * glowOffset
+
        mad  r0, r2, r0, v0 ; (numPass * glowOffset * normal) + pos
+
        add  r0, r0, c8    ; (numPass * glowOffset * normal) + pos + offset
+
       
+
        m4x3 r1.xyz, r0, c0
+
        mov  r1.w,  v0.w
+
        m4x4 oPos,  r1, c3
+
        mov  r2,    c7
+
        add  oD0,   r2, c10
+
      endShaderSource
+
   end
+
enddef
+
 
+
define SimpleVS()
+
  # vertex program
+
  shaderProgram -target vertexProgram -method assemble
+
      bindConstants 0 -bindingID geomToCamera -constantCount 3
+
      bindConstants 3 -bindingID cameraToClip -constantCount 4
+
     
+
      shaderSource
+
        vs_1_1
+
        dcl_position v0
+
       
+
        def c7,$color
+
       
+
        m4x3 r1.xyz, v0, c0
+
        mov  r1.w,  v0.w
+
       
+
        m4x4 oPos,  r1, c3       
+
        mov  oD0,    c7
+
      endShaderSource
+
  end
+
enddef
+
 
+
define SimplePS()        
+
   # pixel program
+
   shaderProgram -target pixelProgram -method assemble
+
      shaderSource
+
        ps_1_1
+
        mov r0, v0
+
      endShaderSource
+
   end
+
enddef
+
 
+
setb glowEnabled false
+
define MaterialWithGlow()
+
# test material for glow effect
+
  seti maxRenderTargets (queryIntegerGraphicsDeviceCap(numSimultaneousRTs))
+
 
+
  material
+
      shader
+
        if ($maxRenderTargets > 1) # MRTs allowed, write out two color values in a single pass       
+
            pass
+
              renderTarget viewerRenderTarget -colorBuffers 2  # use two of the color buffers from the glow texture
+
              vertexFormatPred position 0 true
+
             
+
              # vertex program
+
              shaderProgram -target vertexProgram -method assemble
+
                  bindConstants 0 -bindingID geomToCamera -constantCount 3
+
                  bindConstants 3 -bindingID cameraToClip -constantCount 4
+
                 
+
                  shaderSource
+
                    vs_3_0
+
                    dcl_position v0
+
                    dcl_position0 o0
+
                    dcl_color o1
+
                   
+
                    def c7,$color
+
                   
+
                    m4x3 r1.xyz, v0, c0
+
                    mov  r1.w,  v0.w
+
                   
+
                    m4x4 o0,  r1, c3       
+
                    mov  o1,  c7
+
                  endShaderSource
+
              end
+
             
+
              # pixel program
+
              shaderProgram -target pixelProgram -method assemble
+
                  shaderSource
+
                    ps_3_0
+
                   
+
                    dcl_color v0
+
                    mov oC0, v0
+
                    mov oC1, v0
+
                  endShaderSource
+
              end
+
            end
+
        else  # only one render target allowed, use two passes
+
            if ($glowEnabled)
+
              pass # 1
+
                  # render object to glow buffer
+
                  renderTarget viewerRenderTarget
+
                 
+
                  vertexFormatPred position 0 true             
+
                  create SimpleVS()
+
                  create SimplePS()
+
              end
+
            endif       
+
       
+
            pass # 2
+
              # render object to backbuffer
+
              # Note: The backbuffer rendering pass should generally come after
+
              # all passes that render to other textures.
+
              # This is so that the render target is set to the backbuffer for
+
              # the next object to be rendered (which may not explicitly set it).
+
              renderTarget viewerCompositingTarget
+
             
+
              vertexFormatPred position 0 true           
+
              create SimpleVS()
+
              create SimplePS()
+
            end
+
        endif
+
      end
+
   end
+
enddef
+
 
+
 
+
if (not varExists(mvMaterialDefinition))
+
  set mvMaterialDefinition  StandardMaterial
+
endif
+
 
+
materialDefinition MVLab-CubeMat
+
  setDefinition $mvMaterialDefinition
+
   addParam stdMatDiffCoef (0, 0, 1)
+
 
end
 
end
  
materialDefinition "MVLab-SphereMat"
 
  setDefinition $mvMaterialDefinition
 
end
 
  
materialDefinition "MVLab-ConeMat"
+
materialDefinition sparks
   setDefinition $mvMaterialDefinition
+
   setDefinition StandardMaterial
   addParam stdMatDiffCoef (1, 0.5, 0)
+
  addParam stdMatLayer 5
 +
  addParam stdMatLightingEnabled false
 +
  addParam stdMatAlphaBlendMode additive
 +
  addParam stdMatAlphaTestEnabled false
 +
  addParam stdMatAlphaMultiplier  3
 +
  addParam stdMatBaseTextureAlphaReplicate true
 +
   addParam stdMatDiffCoef (0.85, 0.7, .46)
 +
  addParam stdMatBaseTextureEnabled true
 +
  addParam stdMatBaseTextureName fireflyParticle-alpha
 +
  addParam stdMatEmissiveCoef (0.8,0.56, .46)
 +
  addParam stdMatBaseTextureAddressingU clamp
 +
  addParam stdMatBaseTextureAddressingV clamp
 
end
 
end
  
materialDefinition MVLab-CylinderMat
 
  setDefinition $mvMaterialDefinition
 
  addParam stdMatDiffCoef (1, 1, 0)
 
end
 
  
materialDefinition MVLab-MeshMat
+
materialDefinition brokenLampSmoke2
   setDefinition $mvMaterialDefinition
+
   setDefinition StandardMaterial
   addParam stdMatDiffCoef (0, 0, 1)  
+
  addParam stdMatLayer 9
 +
  addParam stdMatLightingEnabled false
 +
  addParam stdMatAlphaBlendMode blend
 +
  addParam stdMatAlphaTestEnabled false
 +
  addParam stdMatAlphaMultiplier  0.08
 +
  addParam stdMatBaseTextureAlphaReplicate false
 +
   addParam stdMatDiffCoef (0.85, 0.7, .46)
 +
  addParam stdMatBaseTextureEnabled true
 +
  addParam stdMatBaseTextureName brokenLampSmoke
 +
  addParam stdMatEmissiveCoef (0.8,0.56, .46)
 +
  addParam stdMatBaseTextureAddressingU clamp
 +
  addParam stdMatBaseTextureAddressingV clamp
 
end
 
end
  
materialDefinition MVLab-CylinderTopMat
 
  setDefinition $mvMaterialDefinition
 
  addParam stdMatDiffCoef $blue
 
end
 
  
materialDefinition MVLab-CylinderBottomMat
+
materialDefinition brokenLampSmoke
   setDefinition $mvMaterialDefinition
+
   setDefinition StandardMaterial
   addParam stdMatDiffCoef $blue
+
  addParam stdMatLayer 15
 +
  addParam stdMatLightingEnabled false
 +
  addParam stdMatAlphaBlendMode blend
 +
  addParam stdMatAlphaTestEnabled false
 +
  addParam stdMatAlphaMultiplier  0.1
 +
  addParam stdMatBaseTextureAlphaReplicate false
 +
   addParam stdMatDiffCoef (.388, .312, .204)
 +
  addParam stdMatBaseTextureEnabled true
 +
  addParam stdMatBaseTextureName brokenLampSmoke
 +
  addParam stdMatEmissiveCoef (388, .312, .204)
 +
  addParam stdMatBaseTextureAddressingU clamp
 +
  addParam stdMatBaseTextureAddressingV clamp
 
end
 
end
  
materialDefinition MVLab-CylinderPanel0Mat
 
  setDefinition $mvMaterialDefinition
 
  addParam stdMatDiffCoef $green
 
end
 
  
materialDefinition MVLab-CylinderPanel1Mat
+
materialDefinition brokenLampFlash
   setDefinition $mvMaterialDefinition
+
   setDefinition StandardMaterial
   addParam stdMatDiffCoef $yellow
+
  addParam stdMatLayer 19
 +
  addParam stdMatLightingEnabled false
 +
  addParam stdMatAlphaBlendMode additive
 +
  addParam stdMatAlphaTestEnabled false
 +
  addParam stdMatAlphaMultiplier  3
 +
  addParam stdMatBaseTextureAlphaReplicate true
 +
   addParam stdMatDiffCoef (1, 1, 1)
 +
  addParam stdMatBaseTextureEnabled true
 +
  addParam stdMatBaseTextureName brokenlampflash-alpha
 +
  addParam stdMatEmissiveCoef (1, 1, 1)
 +
  addParam stdMatBaseTextureAddressingU clamp
 +
  addParam stdMatBaseTextureAddressingV clamp
 
end
 
end
  
materialDefinition MVLab-CylinderPanel2Mat
 
  setDefinition $mvMaterialDefinition
 
  addParam stdMatDiffCoef $purple
 
end
 
  
materialDefinition MVLab-CylinderPanel3Mat
+
materialDefinition brokenLampElectricalArcs
  setDefinition $mvMaterialDefinition
+
  addParam stdMatDiffCoef $red
+
end
+
 
+
 
+
 
+
 
+
##############################################################
+
# Render to texture stuff
+
#
+
set mvAspect 1
+
set mvOffset ((1 - $mvAspect) / 2)
+
 
+
define MVLab-RenderToTexture()
+
  material
+
      shader
+
        vertexFormatPred position 0 true
+
 
+
        pass -fixedFunction
+
            create LightingStatesNoStdLights()
+
            colorScalar (0.8, 0.8, 1, 1)
+
 
+
            stage
+
              texture "MVLab-RenderTargetTexture"
+
 
+
              textureFilterHint bilinear bilinear
+
              textureMIPFilterHint disabled
+
              textureAddressing clamp clamp clamp
+
           
+
              ffTextureMatrix -scalev (1, $mvAspect) -trans (0, $mvOffset)
+
              textureTransformType vector2
+
             
+
              textureBlend multiply(texture colorScalar) select(texture)
+
            end
+
        end
+
      end
+
  end
+
enddef
+
 
+
#
+
# Doesn't perform any reflection itself -- merely texture maps
+
# a screen-size texture onto geometry.
+
#
+
 
+
# TODO: we should set a script variable or predicate
+
# if hardware vertex shaders are not available.
+
 
+
define MVLab-RenderToTextureReflection()
+
  material
+
      shader
+
        vertexFormatPred position 0 true
+
 
+
        pass -fixedFunction
+
           
+
            colorScalar (0.8, 0.8, 1, 1)
+
           
+
            stage
+
              ffTextureCoordsSource fromPosition
+
              ffTextureMatrix -cameraToClip -scalev (-0.5, (0.5 * -$mvAspect)) -trans (0.5, 0.5)
+
              textureTransformType vector4 homogeneous
+
           
+
              texture  "MVLab-RenderTargetTexture"
+
              textureBlend multiply(texture colorScalar) select(texture)
+
            end
+
        end
+
      end
+
  end
+
enddef
+
 
+
 
+
#
+
# Used to clear the glow render target texture.
+
# by varying 'feedback', you control how much of
+
# the previous frame feeds through into the current.
+
#
+
setf feedback 0.5
+
define MVLab-Dimmer()
+
  material
+
      shader -layer -31
+
        vertexFormatPred position 0 true
+
 
+
+
        pass                       
+
            shaderProgram -target vertexProgram -method assemble
+
       
+
bindConstants 0 -bindingID immediateData -data (((1 - $mvAspect) / 2), $mvAspect, 1, 1)   
+
+
shaderSource
+
+
vs_1_1
+
dcl_position0 v0
+
dcl_texcoord0 v1
+
 
+
mov r0.x, -v0.x
+
mov r0.y, v0.z
+
mov r0.zw, c0
+
                                   
+
mov oPos, r0
+
 
+
mov oT0.x, v1.x
+
mul r0.y, v1.y, c0.y
+
add oT0.y, r0.y, c0.x
+
               
+
endShaderSource
+
+
            end
+
 
+
            colorScalar (0, 0, 0, (1 - $feedback))
+
            cullmode none
+
            depthTest false
+
           
+
            alphaBlend srcFactor(srcAlpha) add dstFactor(invSrcAlpha)
+
            stage
+
              textureBlend select(colorScalar) select(colorScalar)
+
            end
+
        end
+
      end
+
  end
+
enddef
+
 
+
set visualizationTexture "UVVisualization"
+
define MV-UVVisualization()
+
  material
+
      shader
+
        pass -fixedFunction
+
            stage
+
              texture $visualizationTexture
+
              textureBlend select(texture) select(texture)
+
            end
+
        end  # pass
+
      end  # shader
+
  end  # material
+
enddef
+
 
+
materialDefinition MVLab-RenderTargetMaterial
+
  setDefinition MVLab-RenderToTexture
+
end
+
 
+
materialDefinition MVLab-RenderTargetReflectionMaterial
+
  setDefinition MVLab-RenderToTextureReflection
+
end
+
 
+
materialDefinition MVLab-RenderTargetGlowMaterial
+
  setDefinition MVLab-Dimmer
+
  addParam feedback 0.8
+
end
+
 
+
materialDefinition MVLab-DimmerMaterial
+
  setDefinition MVLab-Dimmer
+
  addParam feedback 0.8
+
end
+
 
+
# Test of skybox compositing pass.
+
materialDefinition MVLab-CompositingPass0Material
+
  setDefinition SkyboxCompositionPassMaterial
+
  addParam skyboxCubeTexture reflectionoutdoorwater-envcube
+
end
+
 
+
materialDefinition MVLab-LightingTest
+
 
   setDefinition StandardMaterial
 
   setDefinition StandardMaterial
   addParam stdMatDiffCoef (0.5, 0.5, 0.5)
+
  addParam stdMatLayer 13
end
+
  addParam stdMatLightingEnabled false
 
+
  addParam stdMatAlphaBlendMode additive
materialDefinition MV-UVVisualizationMaterial
+
  addParam stdMatAlphaTestEnabled false
   setDefinition MV-UVVisualization
+
  addParam stdMatAlphaMultiplier  3
 +
  addParam stdMatBaseTextureAlphaReplicate true
 +
   addParam stdMatDiffCoef (1, 1, 1)
 +
  addParam stdMatBaseTextureEnabled true
 +
  addParam stdMatBaseTextureName brokenlampelectricalarcs
 +
  addParam stdMatEmissiveCoef (1, 1, 1)
 +
  addParam stdMatBaseTextureAddressingU clamp
 +
   addParam stdMatBaseTextureAddressingV clamp
 
end
 
end

Revision as of 04:39, 7 September 2007

  1. Materials used for lamps, mostly for broken states

materialDefinition brokenLampSparkFlash

  setDefinition StandardMaterial
  addParam stdMatLayer 5
  addParam stdMatLightingEnabled false
  addParam stdMatAlphaBlendMode additive
  addParam stdMatAlphaTestEnabled false
  addParam stdMatAlphaMultiplier  3
  addParam stdMatBaseTextureAlphaReplicate true
  addParam stdMatDiffCoef (1, 1, 1)
  addParam stdMatBaseTextureEnabled true
  addParam stdMatBaseTextureName fireflyParticle-alpha
  addParam stdMatEmissiveCoef (1, 1, 1)
  addParam stdMatBaseTextureAddressingU clamp
  addParam stdMatBaseTextureAddressingV clamp

end


materialDefinition sparks

  setDefinition StandardMaterial
  addParam stdMatLayer 5
  addParam stdMatLightingEnabled false
  addParam stdMatAlphaBlendMode additive
  addParam stdMatAlphaTestEnabled false
  addParam stdMatAlphaMultiplier  3
  addParam stdMatBaseTextureAlphaReplicate true
  addParam stdMatDiffCoef (0.85, 0.7, .46)
  addParam stdMatBaseTextureEnabled true
  addParam stdMatBaseTextureName fireflyParticle-alpha
  addParam stdMatEmissiveCoef (0.8,0.56, .46)
  addParam stdMatBaseTextureAddressingU clamp
  addParam stdMatBaseTextureAddressingV clamp

end


materialDefinition brokenLampSmoke2

  setDefinition StandardMaterial
  addParam stdMatLayer 9
  addParam stdMatLightingEnabled false
  addParam stdMatAlphaBlendMode blend
  addParam stdMatAlphaTestEnabled false
  addParam stdMatAlphaMultiplier  0.08
  addParam stdMatBaseTextureAlphaReplicate false
  addParam stdMatDiffCoef (0.85, 0.7, .46)
  addParam stdMatBaseTextureEnabled true
  addParam stdMatBaseTextureName brokenLampSmoke
  addParam stdMatEmissiveCoef (0.8,0.56, .46)
  addParam stdMatBaseTextureAddressingU clamp
  addParam stdMatBaseTextureAddressingV clamp

end


materialDefinition brokenLampSmoke

  setDefinition StandardMaterial
  addParam stdMatLayer 15
  addParam stdMatLightingEnabled false
  addParam stdMatAlphaBlendMode blend
  addParam stdMatAlphaTestEnabled false
  addParam stdMatAlphaMultiplier  0.1 
  addParam stdMatBaseTextureAlphaReplicate false
  addParam stdMatDiffCoef (.388, .312, .204)
  addParam stdMatBaseTextureEnabled true
  addParam stdMatBaseTextureName brokenLampSmoke
  addParam stdMatEmissiveCoef (388, .312, .204)
  addParam stdMatBaseTextureAddressingU clamp
  addParam stdMatBaseTextureAddressingV clamp

end


materialDefinition brokenLampFlash

  setDefinition StandardMaterial
  addParam stdMatLayer 19
  addParam stdMatLightingEnabled false
  addParam stdMatAlphaBlendMode additive
  addParam stdMatAlphaTestEnabled false
  addParam stdMatAlphaMultiplier  3
  addParam stdMatBaseTextureAlphaReplicate true
  addParam stdMatDiffCoef (1, 1, 1)
  addParam stdMatBaseTextureEnabled true
  addParam stdMatBaseTextureName brokenlampflash-alpha
  addParam stdMatEmissiveCoef (1, 1, 1)
  addParam stdMatBaseTextureAddressingU clamp
  addParam stdMatBaseTextureAddressingV clamp

end


materialDefinition brokenLampElectricalArcs

  setDefinition StandardMaterial
  addParam stdMatLayer 13
  addParam stdMatLightingEnabled false
  addParam stdMatAlphaBlendMode additive
  addParam stdMatAlphaTestEnabled false
  addParam stdMatAlphaMultiplier  3
  addParam stdMatBaseTextureAlphaReplicate true
  addParam stdMatDiffCoef (1, 1, 1)
  addParam stdMatBaseTextureEnabled true
  addParam stdMatBaseTextureName brokenlampelectricalarcs
  addParam stdMatEmissiveCoef (1, 1, 1)
  addParam stdMatBaseTextureAddressingU clamp
  addParam stdMatBaseTextureAddressingV clamp

end

Personal tools
Namespaces

Variants
Actions
Navigation
game select
Toolbox