Difference between revisions of "TEST-STRCMP4CODES"

From SimsWiki
Jump to: navigation, search
 
(52 intermediate revisions by one user not shown)
Line 1: Line 1:
EP0-TS2
+
define TransparentMirrorReflection()
0xCD7FE87A
+
0x1C0532FA
+
0x9149CD43
+
0xFF002DC8
+
# particles
+
 
+
#
+
# Various standard shaders for particle systems.
+
#
+
 
+
 
+
# StandardParticlesMaterial
+
#
+
# The standard shader for billboard-style particles.
+
# This is referenced from the effects manager.
+
 
+
setb stdPMDoAlphaMask  true
+
setb stdPMDoDepthWrite  false
+
setb stdPMDoDepthTest  true
+
setb stdPMAdditive      false
+
setb stdPMModulate      false
+
setb stdPMInvertDepth  false
+
setb stdPMDebugFill    false
+
 
+
set stdParticleCompositeTexture ""
+
+
define StandardParticlesMaterial()
+
 
   material
 
   material
      # put ourselves two layers above the standard, plus
+
       if (viewerRenderType = $kRenderTypeShadow)
      # transparent, because we don't write Z, and anything
+
        create StandardShaderShadow()
      # that renders after us will stomp on us.
+
       if (varExists(stdPMLayer))
+
      shader -layer $stdPMLayer
+
 
       else
 
       else
      shader -layer ($stdMatLayer * 8 + 7)   # 7 for alpha blend
+
        if (viewerRenderType = $kRenderTypeThumbnail)
 +
            create TransparentBlankMirrorMaterial($kRenderTypeThumbnail)
 +
        else           
 +
            if (not $mirrorReflectionsEnabled)
 +
              set currentType (viewerRenderType)
 +
              create TransparentBlankMirrorMaterial($currentType)
 +
            else
 +
              create TransparentMirrorReflectionMaterial()
 +
            endif           
 +
        endif       
 
       endif
 
       endif
     
+
  end
        vertexFormatPred position 0 true
+
enddef
        vertexFormatPred texcoord 0 true
+
 
        vertexFormatPred color    0 true
+
define TransparentBlankMirrorMaterial(renderType)
         vertexFormatPred blendindices 0 false
+
      shader
        vertexFormatPred targetindices 0 false
+
         validateRenderShaderContext -viewerRenderType &renderType
 
          
 
          
        numLightsPred environmentCube (numLightsOfType(environmentCube))
+
         pass             
 
+
             shaderProgram -target vertexProgram -method assemble
         pass -fixedFunction
+
               bindConstants 0 -bindingID geomToClip -constantCount 4
             create LightingStatesNoStdLights()
+
               shaderSource
             ffPerVertexColor -enable true -diff vertexDiffuse
+
                  vs_1_1
           
+
                  dcl_position v0
            if $stdPMDebugFill
+
                  m4x4 oPos, v0, c0
               alphaBlend srcFactor(one) add dstFactor(zero)
+
               endShaderSource
            elseif $stdPMAdditive
+
             end
              alphaBlend srcFactor(srcAlpha) add dstFactor(one)
+
            elseif $stdPMModulate
+
              alphaBlend srcFactor(destColor) add dstFactor(zero)
+
            else
+
              alphaBlend srcFactor(srcAlpha) add dstFactor(invSrcAlpha)
+
            endif
+
             
+
            depthTest $stdPMDoDepthTest -enableDepthWrite $stdPMDoDepthWrite
+
            if ($stdPMInvertDepth)
+
               depthTestFunction acceptIfGreater
+
            endif
+
           
+
            if (not $stdPMDebugFill)
+
              alphaTest $stdPMDoAlphaMask 1
+
              alphaTestFunction acceptIfGreaterOrEqual    # is this the default? remove if so...
+
            endif
+
 
+
            # the particle system takes care of whether lighting is applied,
+
            # by setting kGeomSkipIllumination appropriately.
+
            if (numLightsOfType(environmentCube) > 0)
+
               colorScalar (1, 1, 1, 1) -applyTextureLightColor 0 0
+
            endif
+
           
+
            fillmode $stdMatFillMode  # so we pick up on wireframe.
+
            cullmode none
+
 
+
             create LightingStatesNoStdLights()
+
 
              
 
              
 +
            colorScalar (0,0,0) 0.5
 
             stage
 
             stage
              texture $stdParticleTexture
+
               textureBlend select(colorScalar) select(colorScalar)
             
+
            end             
              textureAddressing clamp clamp
+
 
+
               textureBlend multiply(texture diffuse) multiply(texture diffuse)
+
            end
+
           
+
            if (strcmp("$stdParticleCompositeTexture", "()") != 0)
+
              # alpha composite over the top
+
              stage
+
                  texture $stdParticleCompositeTexture
+
                 
+
                  textureAddressing clamp clamp
+
                  ffTextureCoordsSource 0
+
 
+
                  textureBlend lerpTextureAlpha(texture outRegister) select(outRegister)
+
              end
+
            elseif (numLightsOfType(environmentCube) > 0)
+
              # multiply in environment tint.
+
              # We could do this more cheaply in the particle streaming code, where there
+
              # is already an overall colour multiplier for the per-vertex colour, but we
+
              # can't access the lights from there.
+
              # We don't (yet) support particle "lighting" with composite particles.
+
              stage
+
                  textureBlend multiply(colorScalar outRegister) multiply(colorScalar outRegister)
+
              end             
+
            endif
+
 
         end
 
         end
       end
+
       end    
     
+
     
+
     
+
      # since particles tend to be transparent, the fallback will be to not draw them.
+
      shader
+
     
+
      end #shader
+
     
+
     
+
     
+
     
+
  end
+
 
enddef
 
enddef
  
 +
define TransparentMirrorReflectionMaterial()
 +
     
 +
      shader -layer -9998  # this material must render first
 +
        validateRenderShaderContext -viewerRenderType $kRenderTypeMirror  # reflection render
  
 +
        pass -renderEachFrame
 +
            renderTarget $reflectionRenderTarget -setViewport viewportFromParentRenderContext
  
# StandardParticleModelMaterial
+
            depthTest true -enableDepthWrite true
#
+
# The standard shader for model (shape)-based particles.
+
# Respects a subset (basically phong-shaded textured) of the
+
# standard material parameters.
+
  
#aliasshader StandardParticleModelMaterial StandardMaterial
+
            applyStencilStateForOverlappingReflections
define StandardParticleModelMaterial()
+
  material
+
      # TODO: do ltScale properly; but we'll probably move this functionality into
+
      # standard material before we tackle that.
+
      set ltScale 2
+
     
+
      attributes
+
        attribute color float3
+
        attribute alpha float1
+
        attribute scale float1
+
      end
+
  
 +
            alphaBlend srcFactor(zero) add dstFactor(one)
  
      shader -layer ($stdMatLayer * 8 + 7)  # 7 for alpha blend
+
            cullmode none
        vertexFormatPred position 0 true
+
        vertexFormatPred texcoord 0 true
+
        vertexFormatPred blendindices  0 false
+
        vertexFormatPred targetindices 0 false
+
       
+
        create DetermineHardwareSupport()
+
  
        pass -fixedFunction
+
             shaderProgram -target vertexProgram -method assemble           
             ffMatCoef -amb ($stdMatDiffCoef * (1 / $ltScale).xxx) -ambAlpha $stdMatAlphaMultiplier -diff ($stdMatDiffCoef * (1 / $ltScale).xxx) -diffAlpha $stdMatAlphaMultiplier -emit ($stdMatEmissiveCoef * (1 / $ltScale).xxx) -emitAlpha $stdMatAlphaMultiplier -spec $stdMatSpecCoef -specPow $stdMatSpecPower
+
              bindConstants 0 -bindingID geomToClipFromParentView -constantCount 4
            addSpecular true
+
               shaderSource
           
+
                  vs_1_1
            # normalize normals because of scale
+
                   dcl_position v0
            create LightingStatesParam(true false)
+
                   def c5, 1,0,0,1
           
+
                   m4x4 r0,  v0,  c0
            # We should be able to call StandardShaderFBAlphaState here, but
+
                   mov oPos.x,  -r0
            # because this wasn't done originally, there are a bunch of existing
+
                   mov oPos.yzw, r0                 
            # materials that have blend set to "none" where they should be set to
+
               endShaderSource
            # "blend".
+
            if (strcmp("${stdMatAlphaBlendMode}", "additive") = 0)
+
              alphaBlend srcFactor(srcAlpha) add dstFactor(one)
+
              depthTest true -enableDepthWrite false
+
            else
+
              alphaBlend srcFactor(srcAlpha) add dstFactor(invSrcAlpha)
+
              depthTest true -enableDepthWrite true
+
            endif
+
           
+
            alphaTest $stdMatAlphaTestEnabled $stdMatAlphaRefValue
+
            alphaTestFunction acceptIfGreaterOrEqual             
+
 
+
            colorScalar @color @alpha
+
           
+
            ffScaleModelTransform @scale
+
           
+
            fillmode $stdMatFillMode
+
 
+
            stage             
+
               create StandardShaderTextureState(Base)
+
                             
+
              # outRegister is previous stage. For first stage, diffuse.
+
              if $stdMatBaseTextureAlphaReplicate
+
                   textureBlend multiplyScale${ltScale}(texture:alphaReplicate outRegister) multiply(texture outRegister)
+
              else
+
                   textureBlend multiplyScale${ltScale}(texture outRegister) multiply(texture outRegister)
+
              endif
+
            end                       
+
           
+
            stage
+
              textureBlend multiply(colorScalar outRegister) multiply(colorScalar outRegister)
+
            end
+
        end
+
       
+
        if (strcmp("${stdMatEnvCubeMode}", "reflection") = 0)
+
            pass -fixedFunction
+
              create LightingStatesParam(true false)
+
 
+
              alphaBlend srcFactor(one) add dstFactor(one)
+
              ffScaleModelTransform @scale
+
              colorScalar $stdMatEnvCubeCoef 1
+
              fillmode $stdMatFillMode
+
             
+
              stage
+
                   if ($cubeMapSupport)
+
                    create StandardShaderEnvCubeMapState(fromReflectionVector)
+
                    textureBlend multiply(texture colorScalar) select(texture)
+
                   else
+
                    textureBlend select(colorScalar) select(colorScalar)
+
                   endif
+
               end
+
 
             end
 
             end
        endif       
 
      end
 
     
 
     
 
      # non textured opaque fallback.
 
      shader -layer ($stdMatLayer * 8)
 
        pass -fixedFunction
 
            create LightingStatesParam(true false)
 
              ffScaleModelTransform @scale
 
              colorScalar @color @alpha
 
              ffMatCoef -amb ($stdMatDiffCoef * (0.5).xxx) -ambAlpha $stdMatAlphaMultiplier -diff ($stdMatDiffCoef * (0.5).xxx) -diffAlpha $stdMatAlphaMultiplier -emit ($stdMatEmissiveCoef * (0.5).xxx) -emitAlpha $stdMatAlphaMultiplier -spec $stdMatSpecCoef -specPow $stdMatSpecPower
 
 
 
            stage
 
              textureBlend multiplyScale2(diffuse colorScalar) select(colorScalar)
 
            end
 
           
 
 
         end
 
         end
     
 
 
       end
 
       end
     
 
      # do-nothing fallback
 
   
 
      shader
 
      end
 
     
 
  end
 
enddef
 
  
 +
      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)
# Various standard shaders for particle systems.
+
            depthTest true -enableDepthWrite false
#
+
            colorScalar (0,0,0) 0.25
  
 
# StandardParticlesMaterial
 
#
 
# The standard shader for billboard-style particles.
 
# This is referenced from the effects manager.
 
 
setb stdPMDoAlphaMask  true
 
setb stdPMDoDepthWrite  false
 
setb stdPMDoDepthTest  true
 
setb stdPMAdditive      false
 
setb stdPMModulate      false
 
setb stdPMInvertDepth  false
 
setb stdPMDebugFill    false
 
 
set stdParticleCompositeTexture ""
 
 
define StandardParticlesMaterial()
 
  material
 
      # put ourselves two layers above the standard, plus
 
      # transparent, because we don't write Z, and anything
 
      # that renders after us will stomp on us.
 
      if (varExists(stdPMLayer))
 
      shader -layer $stdPMLayer
 
      else
 
      shader -layer ($stdMatLayer * 8 + 7)  # 7 for alpha blend
 
      endif
 
     
 
        vertexFormatPred position 0 true
 
        vertexFormatPred texcoord 0 true
 
        vertexFormatPred color    0 true
 
        vertexFormatPred blendindices  0 false
 
        vertexFormatPred targetindices 0 false
 
       
 
        numLightsPred environmentCube (numLightsOfType(environmentCube))
 
 
        pass -fixedFunction
 
            create LightingStatesNoStdLights()
 
            ffPerVertexColor -enable true -diff vertexDiffuse
 
           
 
            if $stdPMDebugFill
 
              alphaBlend srcFactor(one) add dstFactor(zero)
 
            elseif $stdPMAdditive
 
              alphaBlend srcFactor(srcAlpha) add dstFactor(one)
 
            elseif $stdPMModulate
 
              alphaBlend srcFactor(destColor) add dstFactor(zero)
 
            else
 
              alphaBlend srcFactor(srcAlpha) add dstFactor(invSrcAlpha)
 
            endif
 
             
 
            depthTest $stdPMDoDepthTest -enableDepthWrite $stdPMDoDepthWrite
 
            if ($stdPMInvertDepth)
 
              depthTestFunction acceptIfGreater
 
            endif
 
           
 
            if (not $stdPMDebugFill)
 
              alphaTest $stdPMDoAlphaMask 1
 
              alphaTestFunction acceptIfGreaterOrEqual    # is this the default? remove if so...
 
            endif
 
 
            # the particle system takes care of whether lighting is applied,
 
            # by setting kGeomSkipIllumination appropriately.
 
            if (numLightsOfType(environmentCube) > 0)
 
              colorScalar (1, 1, 1, 1) -applyTextureLightColor 0 0
 
            endif
 
           
 
            fillmode $stdMatFillMode  # so we pick up on wireframe.
 
            cullmode none
 
 
            create LightingStatesNoStdLights()
 
           
 
 
             stage
 
             stage
               texture $stdParticleTexture
+
               textureTransformType vector3 homogeneous
             
+
 
               textureAddressing clamp clamp
 
               textureAddressing clamp clamp
 
+
              texture $reflectionRenderTarget
               textureBlend multiply(texture diffuse) multiply(texture diffuse)
+
               textureBlend select(texture) select(colorScalar)
 
             end
 
             end
           
+
                     
            if (strcmp("$stdParticleCompositeTexture", "()") != 0)
+
              # alpha composite over the top
+
              stage
+
                  texture $stdParticleCompositeTexture
+
                 
+
                  textureAddressing clamp clamp
+
                  ffTextureCoordsSource 0
+
 
+
                  textureBlend lerpTextureAlpha(texture outRegister) select(outRegister)
+
              end
+
            elseif (numLightsOfType(environmentCube) > 0)
+
              # multiply in environment tint.
+
              # We could do this more cheaply in the particle streaming code, where there
+
              # is already an overall colour multiplier for the per-vertex colour, but we
+
              # can't access the lights from there.
+
              # We don't (yet) support particle "lighting" with composite particles.
+
              stage
+
                  textureBlend multiply(colorScalar outRegister) multiply(colorScalar outRegister)
+
              end           
+
            endif
+
 
         end
 
         end
 
       end
 
       end
 
        
 
        
        
+
       shader -layer 6     
     
+
        validateRenderShaderContext -viewerRenderType $kRenderTypeNormal
      # since particles tend to be transparent, the fallback will be to not draw them.
+
        pass -modifiedEachFrameHint
      shader
+
            shaderProgram -target vertexProgram -method assemble           
     
+
              bindConstants 0 -bindingID geomToClip -constantCount 4
      end #shader
+
              bindConstants 4 -bindingID clipToViewTarget -constantCount 4
     
+
              shaderSource
     
+
                  vs_1_1
     
+
                  dcl_position v0
     
+
                  def c8,   -0.5, -0.5, 1, 1
  end
+
                  def c9,    0.5,  0.5, 0, 0
enddef
+
                  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
  
 
# StandardParticleModelMaterial
 
#
 
# The standard shader for model (shape)-based particles.
 
# Respects a subset (basically phong-shaded textured) of the
 
# standard material parameters.
 
 
#aliasshader StandardParticleModelMaterial StandardMaterial
 
define StandardParticleModelMaterial()
 
  material
 
      # TODO: do ltScale properly; but we'll probably move this functionality into
 
      # standard material before we tackle that.
 
      set ltScale 2
 
     
 
      attributes
 
        attribute color float3
 
        attribute alpha float1
 
        attribute scale float1
 
      end
 
 
 
      shader -layer ($stdMatLayer * 8 + 7)  # 7 for alpha blend
 
        vertexFormatPred position 0 true
 
        vertexFormatPred texcoord 0 true
 
        vertexFormatPred blendindices  0 false
 
        vertexFormatPred targetindices 0 false
 
       
 
        create DetermineHardwareSupport()
 
 
        pass -fixedFunction
 
            ffMatCoef -amb ($stdMatDiffCoef * (1 / $ltScale).xxx) -ambAlpha $stdMatAlphaMultiplier -diff ($stdMatDiffCoef * (1 / $ltScale).xxx) -diffAlpha $stdMatAlphaMultiplier -emit ($stdMatEmissiveCoef * (1 / $ltScale).xxx) -emitAlpha $stdMatAlphaMultiplier -spec $stdMatSpecCoef -specPow $stdMatSpecPower
 
            addSpecular true
 
           
 
            # normalize normals because of scale
 
            create LightingStatesParam(true false)
 
           
 
            # We should be able to call StandardShaderFBAlphaState here, but
 
            # because this wasn't done originally, there are a bunch of existing
 
            # materials that have blend set to "none" where they should be set to
 
            # "blend".
 
            if (strcmp("${stdMatAlphaBlendMode}", "additive") = 0)
 
              alphaBlend srcFactor(srcAlpha) add dstFactor(one)
 
              depthTest true -enableDepthWrite false
 
            else
 
              alphaBlend srcFactor(srcAlpha) add dstFactor(invSrcAlpha)
 
              depthTest true -enableDepthWrite true
 
            endif
 
           
 
            alphaTest $stdMatAlphaTestEnabled $stdMatAlphaRefValue
 
            alphaTestFunction acceptIfGreaterOrEqual             
 
 
            colorScalar @color @alpha
 
           
 
            ffScaleModelTransform @scale
 
           
 
            fillmode $stdMatFillMode
 
 
            stage             
 
              create StandardShaderTextureState(Base)
 
                             
 
              # outRegister is previous stage. For first stage, diffuse.
 
              if $stdMatBaseTextureAlphaReplicate
 
                  textureBlend multiplyScale${ltScale}(texture:alphaReplicate outRegister) multiply(texture outRegister)
 
              else
 
                  textureBlend multiplyScale${ltScale}(texture outRegister) multiply(texture outRegister)
 
              endif
 
            end                       
 
           
 
 
             stage
 
             stage
               textureBlend multiply(colorScalar outRegister) multiply(colorScalar outRegister)
+
               textureAddressing clamp clamp
            end
+
               texture $reflectionRenderTarget
        end
+
               textureBlend select(texture) select(colorScalar)
       
+
        if (strcmp("${stdMatEnvCubeMode}", "reflection") = 0)
+
            pass -fixedFunction
+
               create LightingStatesParam(true false)
+
 
+
              alphaBlend srcFactor(one) add dstFactor(one)
+
              ffScaleModelTransform @scale
+
              colorScalar $stdMatEnvCubeCoef 1
+
               fillmode $stdMatFillMode
+
             
+
              stage
+
                  if ($cubeMapSupport)
+
                    create StandardShaderEnvCubeMapState(fromReflectionVector)
+
                    textureBlend multiply(texture colorScalar) select(texture)
+
                  else
+
                    textureBlend select(colorScalar) select(colorScalar)
+
                  endif
+
              end
+
            end
+
        endif       
+
      end
+
     
+
     
+
      # non textured opaque fallback.
+
      shader -layer ($stdMatLayer * 8)
+
        pass -fixedFunction
+
            create LightingStatesParam(true false)
+
              ffScaleModelTransform @scale
+
              colorScalar @color @alpha
+
              ffMatCoef -amb ($stdMatDiffCoef * (0.5).xxx) -ambAlpha $stdMatAlphaMultiplier -diff ($stdMatDiffCoef * (0.5).xxx) -diffAlpha $stdMatAlphaMultiplier -emit ($stdMatEmissiveCoef * (0.5).xxx) -emitAlpha $stdMatAlphaMultiplier -spec $stdMatSpecCoef -specPow $stdMatSpecPower
+
 
+
            stage
+
              textureBlend multiplyScale2(diffuse colorScalar) select(colorScalar)
+
 
             end
 
             end
 
              
 
              
 
         end
 
         end
     
 
 
       end
 
       end
     
 
      # do-nothing fallback
 
   
 
      shader
 
      end
 
     
 
  end
 
 
enddef
 
enddef
 +
 +
#---------------------------------------------------------------------------------------------------------------#
 +
 +
materialDefinition transparent_mirror_reflection
 +
  setDefinition TransparentMirrorReflection
 +
end

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