Created
March 4, 2012 13:30
-
-
Save cecilemuller/1972985 to your computer and use it in GitHub Desktop.
Three ways to embed an HLSL shader in VRML/X3D
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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{} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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{} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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