Difference between revisions of "ShaderRoof"

From SimsWiki
Jump to: navigation, search
Line 1: Line 1:
 
<pre>
 
<pre>
−
EP4-Pets
+
EP5-SS
 
0xCD7FE87A
 
0xCD7FE87A
 
0x1C0532FA
 
0x1C0532FA
 
0x9B41704F
 
0x9B41704F
 
0xFF5D60B5
 
0xFF5D60B5
 +
# roof
  
 
#
 
#
Line 152: Line 153:
 
   end
 
   end
 
enddef
 
enddef
−
 
−
define RoofBumps()
 
−
  material
 
−
      shader -layer 0
 
−
        validateRenderShaderContext -vertexFormat position 0 required
 
−
        validateRenderShaderContext -vertexFormat normal 0 required
 
−
        validateRenderShaderContext -vertexFormat texcoord 0 required
 
−
                         
 
−
        pass
 
−
            shaderProgram -target vertexProgram -method compile -version 2_0
 
−
              bindConstants 0 -bindingID  geomToClip    -constantCount 4
 
−
      bindConstants 4 -bindingID  geomToCamera  -constantCount 3
 
−
      bindConstants 7 -bindingID  cameraToGeom  -constantCount 3      
 
−
      bindConstants 10 -bindingID allStandardLightData -constantCount 4 -constantType float
 
−
      bindConstants 14 -bindingID immediateData -data $stdMatDiffCoef
 
−
      bindConstants 15 -bindingID ambientLight -constantCount 1 -constantType float      
 
−
      bindConstants 18 -bindingID allStandardLightData2 -constantCount 32
 
−
     
 
−
      shaderSource
 
−
        float4x4 modelviewproj : register(c0);
 
−
      float4x3 modelview : register(c4);
 
−
      float4x3 modelviewInv : register(c7);            
 
−
     
 
−
      // light direction
 
−
      float4 lightDir0 : register(c18);      
 
−
      float4 lightDir1 : register(c19);
 
−
      float4 lightDir2 : register(c20);
 
−
     
 
−
      // light colors
 
−
      float4 lightCol0 : register(c26);
 
−
      float4 lightCol1 : register(c27);
 
−
      float4 lightCol2 : register(c28);
 
−
           
 
−
      float4 color : register(c14);      
 
−
      float4 ambient : register(c15);
 
−
     
 
−
      struct a2v
 
−
                  {
 
−
                    float4 pos : POSITION;                   
 
−
                    float3 normal : NORMAL;
 
−
                    float2 txcoord : TEXCOORD0;
 
−
                    float2 tangent : TEXCOORD1;                   
 
−
                  };
 
−
 
−
                  struct v2f
 
−
                  {
 
−
                    float4 hpos : POSITION;
 
−
                    float4 color    : COLOR0;                                   
 
−
                    float4 ambient  : COLOR1;
 
−
                    float2 txcoord : TEXCOORD0;
 
−
                  float3 lightDir0: TEXCOORD1;
 
−
                  float3 lightDir1: TEXCOORD2;
 
−
                  float3 lightDir2: TEXCOORD3;
 
−
                  float3 lightCol0: TEXCOORD4;
 
−
                  float3 lightCol1: TEXCOORD5;
 
−
                  float3 lightCol2: TEXCOORD6;
 
−
                  float3 normal : TEXCOORD7;
 
−
                  };
 
−
                 
 
−
                  v2f VertexMain(a2v IN)
 
−
                  {
 
−
                  v2f OUT;
 
−
 
−
                  // vertex position in object space
 
−
                  float4 pos = float4(IN.pos.x,IN.pos.y,IN.pos.z,1.0);                                    
 
−
                 
 
−
                  // vertex position in clip space
 
−
                  OUT.hpos = mul(pos, modelviewproj);                            
 
−
                 
 
−
                  float3 tangent = float3(IN.tangent.x, IN.tangent.y, 0);
 
−
                                   
 
−
                  // compute binormal
 
−
                  float3 binormal = normalize(cross(IN.normal, tangent));
 
−
                 
 
−
                  // tangent space matrix
 
−
                  float3x3 tbn = float3x3(tangent, binormal, IN.normal);
 
−
                 
 
−
                  // light direction in object space                  
 
−
                  float3 lt0 = mul(lightDir0, (float3x3)modelviewInv);
 
−
                  float3 lt1 = mul(lightDir1, (float3x3)modelviewInv);
 
−
                  float3 lt2 = mul(lightDir2, (float3x3)modelviewInv);
 
−
                 
 
−
                  // light 0 direction in tangent space                                    
 
−
                  OUT.lightDir0 = normalize(mul(tbn, lt0));                                  
 
−
                  OUT.lightDir1 = normalize(mul(tbn, lt1));
 
−
                  OUT.lightDir2 = normalize(mul(tbn, lt2));
 
−
                 
 
−
                  OUT.lightCol0 = lightCol0;
 
−
                  OUT.lightCol1 = lightCol1;
 
−
                  OUT.lightCol2 = lightCol2;
 
−
                 
 
−
                  // copy texture coordinates                  
 
−
                  OUT.txcoord=IN.txcoord.xy;
 
−
                  OUT.color = color;
 
−
                  OUT.color.a = 1;
 
−
                 
 
−
                  OUT.ambient = ambient;
 
−
                  OUT.normal = IN.normal;
 
−
 
−
                  return OUT;
 
−
                  }
 
−
                         
 
−
      endShaderSource
 
−
            end # end shader program
 
−
           
 
−
              shaderProgram -target pixelProgram -method compile -version 1_4  -disassemble "c:\sims2ep3\hlslPS.txt"           
 
−
             
 
−
                  shaderSource   
 
−
                    sampler texmap;
 
−
                    sampler normmap;
 
−
                    sampler roofnoise;
 
−
                   
 
−
                    struct v2f
 
−
                    {
 
−
                        float4 hpos : POSITION;  
 
−
                        float4 color    : COLOR0;                                                 
 
−
                        float4 ambient  : COLOR1;
 
−
                        float2 txcoord : TEXCOORD0;                                               
 
−
                        float3 lightDir0: TEXCOORD1;
 
−
                    float3 lightDir1: TEXCOORD2;
 
−
                    float3 lightDir2: TEXCOORD3;
 
−
                    float3 lightCol0: TEXCOORD4;
 
−
                    float3 lightCol1: TEXCOORD5;
 
−
                    //float3 lightCol2: TEXCOORD6;
 
−
                    //float3 normal : TEXCOORD7;
 
−
                    };
 
−
 
−
                    float4 PixelMain(v2f pi) : COLOR
 
−
                    { 
 
−
                        // normal map
 
−
                        float4 normal = tex2D(normmap, pi.txcoord);                                     
 
−
                               
 
−
                        //bump.xyz = 4.0 * (bump.xyz - (0.5).xxx);                           
 
−
//                        bump.z = pi.normal.z;
 
−
                        //float3 normal = normalize(bump);                                               
 
−
                       
 
−
                        // color map
 
−
                        float4 color = tex2D(texmap, pi.txcoord);             
 
−
                                                                                               
 
−
                        float diff0 = saturate(dot(pi.lightDir0, normal.xyz));                       
 
−
                        //float diff1 = saturate(dot(pi.lightDir1, normal.xyz));
 
−
                        //float diff2 = saturate(dot(pi.lightDir2, normal.xyz));
 
−
                                             
 
−
                        float4 finalColor;
 
−
                        finalColor.rgb = diff0;//(diff0*pi.lightCol0 + diff1*pi.lightCol1 + diff2 + pi.ambient)*pi.color.rgb*color.rgb;
 
−
                       
 
−
                        finalColor.a = 1.0;                       
 
−
                        return finalColor;                                                                                                                   
 
−
                    }
 
−
                  endShaderSource
 
−
              end                                                   
 
−
                             
 
−
             
 
−
              sampler normmap
 
−
                  texture "roof-manor-test-bump"#$stdMatNormalMapTextureName               
 
−
                  textureAddressing clamp clamp clamp
 
−
              end
 
−
             
 
−
              sampler 1#texmap
 
−
                  texture $stdMatBaseTextureName               
 
−
                  textureAddressing clamp clamp clamp
 
−
              end
 
−
        end # end pass
 
−
       
 
−
      end #end shader
 
−
  end # end material
 
−
enddef
 
  
 
materialDefinition RoofPreview
 
materialDefinition RoofPreview
Line 354: Line 188:
 
# texture, lit, normal mappedm, no specular
 
# texture, lit, normal mappedm, no specular
 
materialDefinition RoofTop
 
materialDefinition RoofTop
−
   setDefinition StandardMaterial #RoofBumps
+
   setDefinition StandardMaterial
 
   addParam  stdMatSpecPower 0
 
   addParam  stdMatSpecPower 0
 
   addParam  stdMatDiffCoef (0.4, 0.385, 0.38)
 
   addParam  stdMatDiffCoef (0.4, 0.385, 0.38)
Line 449: Line 283:
 
   setDefinition RoofMaterialFF
 
   setDefinition RoofMaterialFF
 
end
 
end
 +
 
</pre>
 
</pre>
 +
[[User:Niol|niol]] 03:14, 5 March 2007 (CST)

Revision as of 11:14, 5 March 2007

EP5-SS
0xCD7FE87A
0x1C0532FA
0x9B41704F
0xFF5D60B5
# roof

#
# roof material definitions.
#

# material for roof preview when they're displayed
define RoofPreviewMaterial()
   material
      shader -layer 9999
         vertexFormatPred position      0 true
         vertexFormatPred normal        0 true
         vertexFormatPred blendindices  0 false
         vertexFormatPred targetindices 0 false
         
         pass -fixedFunction         
            colorScalar (0.5, 0.4, 0.4, 1.0)         
            create LightingStatesNoStdLights()
            depthTest true -enableDepthWrite true

	    alphaBlend srcFactor(srcAlpha) add dstFactor(invSrcAlpha)		

            stage
               textureBlend select(colorScalar) select(colorScalar)
            end 
         end

	pass -fixedFunction        
            create LightingStatesNoStdLights()
            fillmode wireframe
	    cullmode none
            depthTest true -enableDepthWrite false
            colorScalar (0, 0, 0)

            stage
               textureBlend select(colorScalar) select(colorScalar)
            end 
         end

      end
   end
enddef

define RoofPreviewMaterialBack()
   material
      shader -layer 9999
         vertexFormatPred position      0 true
         vertexFormatPred normal        0 true
         vertexFormatPred blendindices  0 false
         vertexFormatPred targetindices 0 false
         
         pass -fixedFunction         
            colorScalar (0.25, 0.1, 0.1, 1.0)         
            create LightingStatesNoStdLights()

            depthTest true -enableDepthWrite true

	    alphaBlend srcFactor(srcAlpha) add dstFactor(invSrcAlpha)		

            stage
               textureBlend select(colorScalar) select(colorScalar)
            end 
         end

      end
   end
enddef

define RoofPreviewMaterialStrip()
   material
      shader -layer 9999
         vertexFormatPred position      0 true
         vertexFormatPred blendindices  0 false
         vertexFormatPred targetindices 0 false
         
         pass -fixedFunction         
            colorScalar (1.0, 1.0, 1.0, 1.0)         
            create LightingStatesNoStdLights()

            depthTest true -enableDepthWrite false	    

            stage
               textureBlend select(colorScalar) select(colorScalar)
            end 
         end

      end
   end
enddef

define RoofPreviewMaterialUpperStrip()
   material
      shader -layer 9999
         vertexFormatPred position      0 true
         vertexFormatPred blendindices  0 false
         vertexFormatPred targetindices 0 false
         
         pass -fixedFunction         
            colorScalar (1.0, 0.0, 0.0, 1.0)         
            create LightingStatesNoStdLights()

            depthTest true -enableDepthWrite false

            stage
               textureBlend select(colorScalar) select(colorScalar)
            end 
         end

      end
   end
enddef

define RoofPreviewMaterialTopBoundary()
   material
      shader -layer 9999
         vertexFormatPred position      0 true
         vertexFormatPred normal        0 true
         vertexFormatPred blendindices  0 false
         vertexFormatPred targetindices 0 false
         
         pass -fixedFunction         
            colorScalar (0.4, 0, 0.1, 1.0)         
            create LightingStatesNoStdLights()

            depthTest true -enableDepthWrite true

	    alphaBlend srcFactor(srcAlpha) add dstFactor(invSrcAlpha)		

            stage
               textureBlend select(colorScalar) select(colorScalar)
            end 
         end

	pass -fixedFunction        
            create LightingStatesNoStdLights()
            fillmode wireframe
            depthTest true -enableDepthWrite false
            colorScalar (0, 0, 0)

            stage
               textureBlend select(colorScalar) select(colorScalar)
            end 
         end


      end
   end
enddef

materialDefinition RoofPreview
   setDefinition StandardMaterial
   addParam   stdMatSpecPower 0
   addParam   stdMatDiffCoef (0.4, 0.385, 0.38)
   addParam   stdMatBaseTextureName roof-manor
   addParam   stdMatBaseTextureEnabled true
   addParam   stdMatCullMode none
end


materialDefinition RoofUnder
   setDefinition StandardMaterial
   addParam   stdMatSpecPower 0
   addParam   stdMatDiffCoef (0.8, 0.8, 0.8)
   addParam   stdMatBaseTextureName roof-manor-under
   addParam   stdMatBaseTextureEnabled true
   addParam   stdMatCullMode none
end

materialDefinition RoofTrim
   setDefinition StandardMaterial
   addParam   stdMatSpecPower 0
   addParam   stdMatDiffCoef (0.8, 0.8, 0.8)
   addParam   stdMatBaseTextureName roof-manor-trim
   addParam   stdMatBaseTextureEnabled true
   addParam   stdMatCullMode none
end

materialDefinition RoofPreviewTopBoundary
   setDefinition RoofPreviewMaterialTopBoundary
end

# texture, lit, normal mappedm, no specular
materialDefinition RoofTop
   setDefinition StandardMaterial
   addParam   stdMatSpecPower 0
   addParam   stdMatDiffCoef (0.4, 0.385, 0.38)
   addParam   stdMatBaseTextureName roof-manor
   addParam   stdMatBaseTextureEnabled true
   addParam   stdMatNormalMapTextureName roof-manor-bump
   addParam   stdMatNormalMapTextureEnabled true
   addParam   stdMatBaseTextureAddressingU clamp
   addParam   stdMatBaseTextureAddressingV clamp
   addParam   stdMatBaseTextureAddressingW clamp
   addParam   stdMatNormalMapTextureAddressingU clamp
   addParam   stdMatNormalMapTextureAddressingV clamp
   addParam   stdMatNormalMapTextureAddressingW clamp
   addParam   stdMatCullMode none
end


materialDefinition RoofEdges
   setDefinition StandardMaterial
   addParam   stdMatSpecPower 0
   addParam   stdMatDiffCoef (0.8, 0.8, 0.8)
   addParam   stdMatBaseTextureName roof-manor-edges
   addParam   stdMatBaseTextureEnabled true
   addParam   stdMatCullMode none
end

# texture, lit, normal mappedm, no specular
materialDefinition RoofTopThumbnail
   setDefinition StandardMaterial
   addParam   stdMatSpecPower 0
   addParam   stdMatDiffCoef (0.8, 0.75, 0.75)
   addParam   stdMatBaseTextureName roof-manor
   addParam   stdMatBaseTextureEnabled true
   addParam   stdMatNormalMapTextureName roof-manor-bump
   addParam   stdMatNormalMapTextureEnabled true
end

# texture, lit, normal mappedm, no specular
# modify this material for roof highlights
materialDefinition RoofTopHighlight
   setDefinition StandardMaterial
   addParam   stdMatSpecPower 0
   addParam   stdMatDiffCoef (0.4, 0.385, 0.38)
   addParam   stdMatBaseTextureName roof-redtile
   addParam   stdMatBaseTextureEnabled true
   addParam   stdMatNormalMapTextureName roof-redtile-bump
   addParam   stdMatNormalMapTextureEnabled true
   addParam   stdMatBaseTextureAddressingU clamp
   addParam   stdMatBaseTextureAddressingV clamp
   addParam   stdMatBaseTextureAddressingW clamp
   addParam   stdMatNormalMapTextureAddressingU clamp
   addParam   stdMatNormalMapTextureAddressingV clamp
   addParam   stdMatNormalMapTextureAddressingW clamp
end

##############################################################
# Roofs custom
#


define RoofMaterialFF()
   material
      shader -layer $roofLayer

            pass -fixedFunction
         
            create LightingStates() 
            create AttenuatedMatCoef(1)                                           
                              
            ffDepthOffset 2            
            
            depthTest true -enableDepthWrite false
                        
            stage
               texture $stdMatBaseTextureName
               textureAddressing clamp clamp
               ffTextureCoordsSource 0					
					textureBlend multiply(texture diffuse) select(texture)
            end #end stage               

                        
         end #pass      
      end #end shader   
   end #end material 
enddef

materialDefinition RoofMaterialStrips
   addParam stdMatBaseTextureName roof-manor   
   addParam stdMatDiffCoef (0.4, 0.385, 0.38)
   addParam stdMatSpecPower 0
   addParam stdMatEmissiveCoef 0,0,0
   addParam stdMatSpecCoef 0,0,0   
   addParam roofLayer 2
   setDefinition RoofMaterialFF
end

niol 03:14, 5 March 2007 (CST)

Personal tools
Namespaces

Variants
Actions
Navigation
game select
Toolbox