ShaderVertexAlpha

From SimsWiki
Jump to: navigation, search

EP5-SS
0xCD7FE87A
0x1C0532FA
0x4E1F3534
0xFFCB2BC3
# vertexalpha

#beginshader VertexAlpha
#description Untextured, solid color shader with opacity controlled through per vertex alpha
#description and color controlled through per vertex color
#extraparam int stdMatLayer 0 -32 32 ; layer for render order

define VertexAlpha()
      
      material

    
         shader -layer ($stdMatLayer * 18 + 17)
            validateRenderShaderContext -vertexFormat  position      0 required
            validateRenderShaderContext -vertexFormat color         0 required

			create DetermineHardwareSupport()
			create SetupCommonHWShaderVariablesAndPredicates()
         # since the DX8 path won't run here, I want the software VS  on DX7/dx8 cards to assume ubyte4.
         setb ubyte4Supported true
         
			pass
				
               alphaBlend srcFactor(srcAlpha) add dstFactor(invSrcAlpha)
               depthTest true -enableDepthWrite false

               shaderProgram -target vertexProgram -method link
					create BindsForHardwareVS2Transforms($doSkinning $doMorphing)
					create TransformFragments($doSkinning false false $doMorphing $numPosMorphs $numNormMorphs false 2_0)
					shaderFragment VertexAlphaSupport2_0
					
               end
                
               colorScalar (1,1,1) 1 -applyShapeColor 0
               
               stage
                  textureBlend select(diffuse colorScalar) select(diffuse colorScalar)
               end 
               
            end
         end
         
          
         
         # backup shader for materials without color in their vertices (bad case, but better than flashing red)
         shader -layer ($stdMatLayer * 18 + 17)
            validateRenderShaderContext -vertexFormat  position      0 required

            pass -fixedFunction
				
               create LightingStatesNoStdLights()

               colorScalar (1,1,1) 1
				
               stage
                  textureBlend select(colorScalar) select(colorScalar)
               end 
            end
						 
         end
         
      end
      
      
      
   enddef
#endshader VertexAlpha

Personal tools
Namespaces

Variants
Actions
Navigation
game select
Toolbox