ParallelGraphics
Home  »  Developer Zone  »  Products  »  Cortona3D Viewer  »  VRML Extensions  »  DirectX 9.0 Shaders
Up to VRML Extensions

AdvancedAppearance 

Animated GIF 

BumpMap 

Collision Detection 

CompositeTexture 

CortonaExtrusion 

CubeEnvironment 

DirectX 9.0 Shaders 

Drag & Drop 

EventUtilities 

Flash animations 

FlashMovie 

FontStyle 

Inline Extension 

Interpolator Nodes 

GradientBackground 

Keyboard Input 

Layers and 2D Nodes 

MipMap 

NavigationInfo 

NURBS 

OrderedGroup 

Panel and HTMLText 

QuickTime 

SFVec2f Interpolator 

SphereEnvironment 

Splines 

Three-Dimensional Text 

TextureTransform3 

TransformSensor 

ViewportSensor 

ZGroup 


Subscribe to Newsletter
 


Google Searchsite search:

 

%(domain)s %(domain)s
Install Cortona3D Viewer

Outline3D


DirectX 9.0 Shaders

Cortona3D Viewer supports DirectX 9.0c. The latest version of DirectX is available at
http://www.microsoft.com/downloads/en/resultsForCategory.aspx?displaylang=en&categoryid=2

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 Cortona3D Viewer 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:inet:parallelgraphics.com:cortona:ShaderAppearance"
  "http://www.parallelgraphics.com/vrml/proto/Cortona/extensions.wrl
  #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.

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:

X3D Specification, 9.2.1, URLs

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



Example
scene size: 2.3KB
resources size: 170KB
archive size: 124KB
view online download

Last updated: Thu, 09 Feb 2012
© 2000-2011 ParallelGraphics. All rights reserved. Terms of use.