2 Replies Latest reply on May 24, 2009 12:06 PM by extremeseos0007

    Shaders in DirectX 9.0

    dragon32078
      How do I setup a multi-pass shader in DX 9.0

      I know how to create a shader in Rendermonkey and load it into DirectX, but I am uncertain how to utilize a shader with multiple passes. I have located various websites which I know cover this topic like msdn.microsoft.com/DirectX but I have failed to come up with the proper key words to searching for this specific topic.

      Any help would be much appreciated.

      Thank you,

      Kevin

        • Shaders in DirectX 9.0
          arindam.0000

          Cortona VRML Client 5.0 supports DirectX 9.0c. The latest version of DirectX is available at



          Please make sure you have a DirectX 9.0 compatible graphics adapter with hardware shader support.

          The implementation of programmable shaders corresponds to the X3D Programmable Shader Proposal. The supported shader languages are High Level Shader Language (HLSL) and nVidia Cg shading language. DirectX 9.0 FX format is supported.

          Three new nodes were added to Cortona VRML Client for shader support: ShaderAppearance, VertexShader and FragmentShader.

           

          ShaderAppearance

           

          EXTERNPROTO ShaderAppearance [
          exposedField SFNode fillProperties NULL
          exposedField SFNode fragmentShader NULL
          exposedField SFNode lineProperties NULL
          exposedField SFNode material NULL
          exposedField SFNode texture NULL
          exposedField SFNode textureTransform NULL
          exposedField SFNode vertexShader NULL
          ]
          [
          "urn:inetarallelgraphics.com:cortona:ShaderAppearance"
          "http://www.parallelgraphics.com/vrml/proto/Cortona/extensions.wrl

          VertexShader

           

          VertexShader { exposedField MFString url #any number of field fieldType fieldName eventIn fieldType fieldName eventOut fieldType fieldName exposedField fieldType fieldName }

          VertexShader node defines a vertex shader for modifying geometry's vertex values. Url field specifies shader programming language code. The prefix in the beginning of the url's field value shows the browser what shader language is used. Hlsl prefix means that High Level Shader Language is used, cg prefix means that nVidia Cg shading language is used.

          This example demonstrates the vertex shader written in the HLSL:

           

          VertexShader { url ["hlsl: ..."] }

          Multiple valued url field could contain several different shader programs simultaneously. A description of order of preference for multiple valued URL fields may be found in the following document:

          In addition to the url field, any number of different fields could be declared in the VertexShader node. These fields receive and process events of the scene.

           

          FragmentShader

           

          FragmentShader {
          exposedField MFString url
          #any number of
          field fieldType fieldName
          eventIn fieldType fieldName
          eventOut fieldType fieldName
          exposedField fieldType fieldName
          }

          FragmentShader node (more often it is known as a pixel shader) defines a pixel shader for modifying geometry's pixel values. All the fields of the FragmentShader have the same syntax as VertexShader's fields.

          More detailed information about shaders can be found in the following documents:

           
          Microsoft DirectX 9 SDK:
          Programmable HLSL Shaders

           
          X3D Specification, programmable shaders component, Microsoft High Level Shading Language (HLSL) Binding: J.3. Interaction other nodes and components,
          ( J.3.1, Vertex Shader J.3.2, Fragment Shader J.3.4, Vertex Attributes );
          J.4. Data Types and Parameter Mappings

           
          X3D Specification, programmable shaders component, nVidia Cg shading language binding: K.4. Interaction other nodes and components,
          ( K.4.1, Vertex Shader K.4.2, Fragment Shader K.4.4, Vertex Attributes );
          K.5. Data Types and Parameter Mappings

          #ShaderAppearance"
          ]

          ShaderAppearance node is used instead of Appearance node. The vertexShader field contains VertexShader node. The fragmentShader field contains FragmentShader node. Detaialed description of VertexShader and FragmentShader nodes is placed below. The material, texture and textureTransform fields work as in the Appearance node. They define the visual properties of geometry only in the following cases:

           
          The DirectX9 renderer is not activated.

           
          Your hardware has no shader support.

           
          Vertex or Fragment shaders are not specified or written in the language which is not supported by the browser.

          FillProperties and lineProperties are not yet implemented. If these fields exist, they are ignored by the browser.

          Edit: Removed advertising from signature