Skip to content

Instantly share code, notes, and snippets.

@cecilemuller
Created March 4, 2012 13:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cecilemuller/1972985 to your computer and use it in GitHub Desktop.
Save cecilemuller/1972985 to your computer and use it in GitHub Desktop.
Three ways to embed an HLSL shader in VRML/X3D
#VRML V2.0 utf8
Transform {
translation -4 2 0
children Shape {
appearance Appearance{
material Material{
diffuseColor 0 0 0
emissiveColor 1 1 1
}
}
geometry Text{
string "FragmentShader (inline)"
fontStyle FontStyle{
justify "MIDDLE"
family "Arial"
size 0.3
}
}
}
}
Transform {
translation -4 0 0
children Shape {
appearance ShaderAppearance {
textureTransform TextureTransform {scale 5 5}
fragmentShader FragmentShader {
exposedField SFNode png ImageTexture {url "example.png"}
url "hlsl:
sampler2D png: register(s0);
float4 main( float2 tex0: TEXCOORD0 ): COLOR {
return tex2D(png, tex0);
}
"
}
}
geometry Box{}
}
}
#VRML V2.0 utf8
Transform {
translation 4 2 0
children Shape {
appearance Appearance {
material Material {
diffuseColor 0 0 0
emissiveColor 1 1 1
}
}
geometry Text{
string "PackagedShader (.fx)"
fontStyle FontStyle{
justify "MIDDLE"
family "Arial"
size 0.3
}
}
}
}
Transform {
translation 4 0 0
children Shape {
appearance Appearance {
textureTransform TextureTransform {scale 5 5}
shaders PackagedShader {
language "HLSL"
exposedField SFNode png ImageTexture {url "example.png"}
url "example.fx"
}
}
geometry Box{}
}
}
#VRML V2.0 utf8
Transform {
translation 0 2 0
children Shape {
appearance Appearance {
material Material {
diffuseColor 0 0 0
emissiveColor 1 1 1
}
}
geometry Text{
string "VertexShader (.fx)"
fontStyle FontStyle{
justify "MIDDLE"
family "Arial"
size 0.3
}
}
}
}
Transform {
translation 0 0 0
children Shape {
appearance ShaderAppearance {
textureTransform TextureTransform {scale 5 5}
vertexShader VertexShader {
exposedField SFNode png ImageTexture {url "example.png"}
url "example.fx"
}
}
geometry Box{}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment