--- /dev/null
+MaterialDef UnshadedNodes {\r
+\r
+ MaterialParameters {\r
+ Texture2D ColorMap\r
+ Texture2D LightMap\r
+ Color Color (Color)\r
+ Boolean VertexColor (UseVertexColor)\r
+ Boolean SeparateTexCoord\r
+ \r
+ //FOG parameters\r
+ Boolean UseFog\r
+ Float FogDensity :1\r
+ Color FogColor : 1 1 1 1\r
+ }\r
+\r
+ Technique {\r
+\r
+ WorldParameters {\r
+ WorldViewProjectionMatrix\r
+ //used for fog\r
+ WorldViewMatrix\r
+ }\r
+ \r
+ VertexShaderNodes{ \r
+ ShaderNode FogFactor{\r
+ Definition: FogFactor : Common/MatDefs/ShaderNodes/Fog/Fog.j3sn\r
+ Condition: UseFog\r
+ InputMapping{ \r
+ modelViewMatrix = WorldParam.WorldViewMatrix\r
+ modelPosition = Global.position\r
+ fogDensity = MatParam.FogDensity\r
+ } \r
+ } \r
+ ShaderNode UnshadedVert{\r
+ Definition: CommonVert : Common/MatDefs/ShaderNodes/Common/CommonVert.j3sn\r
+ InputMapping{\r
+ worldViewProjectionMatrix = WorldParam.WorldViewProjectionMatrix\r
+ modelPosition = Global.position.xyz\r
+ texCoord1 = Attr.inTexCoord: ColorMap || (LightMap && !SeparateTexCoord)\r
+ texCoord2 = Attr.inTexCoord2: SeparateTexCoord\r
+ vertColor = Attr.inColor: VertexColor\r
+ }\r
+ OutputMapping{\r
+ Global.position = projPosition\r
+ }\r
+ }\r
+ \r
+ \r
+ }\r
+ FragmentShaderNodes{\r
+ ShaderNode UnshadedFrag{\r
+ Definition: Unshaded : Common/MatDefs/ShaderNodes/Common/Unshaded.j3sn\r
+ InputMapping{\r
+ texCoord = UnshadedVert.texCoord1: ColorMap\r
+ vertColor = UnshadedVert.vertColor: VertexColor\r
+ matColor = MatParam.Color: Color\r
+ colorMap = MatParam.ColorMap: ColorMap\r
+ color = Global.outColor\r
+ }\r
+ OutputMapping{\r
+ Global.outColor = color\r
+ }\r
+ }\r
+ ShaderNode LightMap{\r
+ Definition: LightMapping : Common/MatDefs/ShaderNodes/LightMapping/LightMapping.j3sn\r
+ Condition: LightMap\r
+ InputMapping{\r
+ texCoord = UnshadedVert.texCoord1: !SeparateTexCoord \r
+ texCoord = UnshadedVert.texCoord2: SeparateTexCoord \r
+ lightMap = MatParam.LightMap \r
+ color = Global.outColor \r
+ }\r
+ OutputMapping{\r
+ Global.outColor = color\r
+ }\r
+ } \r
+ \r
+ ShaderNode FogOutput{\r
+ Definition: FogOutput : Common/MatDefs/ShaderNodes/Fog/Fog.j3sn\r
+ Condition: UseFog\r
+ InputMapping{ \r
+ fogFactor = FogFactor.fogFactor\r
+ color = Global.outColor\r
+ fogColor = MatParam.FogColor\r
+ }\r
+ OutputMapping{\r
+ Global.outColor = color\r
+ }\r
+ }\r
+ } \r
+\r
+ }\r
+\r
+ \r
+}
\ No newline at end of file
--- /dev/null
+ShaderNodeDefinitions{\r
+ ShaderNodeDefinition AttributeToVarying{\r
+ Type : Vertex \r
+ Shader GLSL100: Common/MatDefs/ShaderNodes/Basic/null.vert \r
+ Documentation{\r
+ This node can pass an attribute value to a varying value.\r
+ @input floatVariable a float attribute\r
+ @input vec2Variable a vec2 attribute \r
+ @input vec3Variable a vec3 attribute\r
+ @input vec4Variable a vec4 attribute\r
+ @output floatVariable a float varying\r
+ @output vec2Variable a vec2 varying \r
+ @output vec3Variable a vec3 varying\r
+ @output vec4Variable a vec4 varying\r
+ }\r
+ Input {\r
+ float floatVariable\r
+ vec2 vec2Variable \r
+ vec3 vec3Variable\r
+ vec4 vec4Variable\r
+ }\r
+ Output {\r
+ float floatVariable\r
+ vec2 vec2Variable \r
+ vec3 vec3Variable\r
+ vec4 vec4Variable\r
+ }\r
+ }\r
+}
\ No newline at end of file
--- /dev/null
+ShaderNodeDefinitions{\r
+ ShaderNodeDefinition ColorMix { \r
+ Type: Fragment\r
+ Shader GLSL100: Common/MatDefs/ShaderNodes/Basic/colorMix.frag\r
+ Documentation{\r
+ mixes two colors according to a mix factor \r
+ @input color1 the first color to mix\r
+ @input color2 the second color to mix\r
+ @input factor the mix factor (from 0.0 to 1.0) fpr more information see the gsls mix function\r
+ @output outColor the mixed color\r
+ }\r
+ Input {\r
+ vec4 color1\r
+ vec4 color2\r
+ float factor\r
+ }\r
+ Output {\r
+ vec4 outColor\r
+ }\r
+ }\r
+}
\ No newline at end of file
--- /dev/null
+ShaderNodeDefinitions{\r
+ ShaderNodeDefinition ColorMult { \r
+ Type: Fragment\r
+ Shader GLSL100: Common/MatDefs/ShaderNodes/Basic/colorMult.frag\r
+ Documentation{\r
+ Multiplies two colors\r
+ @input color1 the first color\r
+ @input color2 the second color \r
+ @output outColor the resulting color\r
+ }\r
+ Input {\r
+ vec4 color1\r
+ vec4 color2 \r
+ }\r
+ Output {\r
+ vec4 outColor\r
+ }\r
+ }\r
+}
\ No newline at end of file
--- /dev/null
+ShaderNodeDefinitions{\r
+ ShaderNodeDefinition TextureFetch { \r
+ Type: Fragment\r
+ Shader GLSL100: Common/MatDefs/ShaderNodes/Basic/texture.frag\r
+ Documentation{\r
+ Fetches a color value in the given texture acording to given texture coordinates\r
+ @input texture the texture to read\r
+ @input texCoord the texture coordinates\r
+ @output outColor the fetched color\r
+ }\r
+ Input {\r
+ sampler2D texture\r
+ vec2 texCoord \r
+ }\r
+ Output {\r
+ vec4 outColor\r
+ }\r
+ }\r
+}
\ No newline at end of file
--- /dev/null
+ShaderNodeDefinitions{\r
+ ShaderNodeDefinition TransformPosition{\r
+ Type: Vertex \r
+ Shader GLSL100: Common/MatDefs/ShaderNodes/Basic/transformPosition.vert\r
+ Documentation {\r
+ This node transforms a position according to the given matrix\r
+ @input inputPosition the position to transform\r
+ @input transformsMatrix the matrix to use for this transformation\r
+ @output outPosition the transformed position\r
+ } \r
+ Input {\r
+ vec3 inputPosition\r
+ mat4 transformsMatrix\r
+ }\r
+ Output {\r
+ vec4 outPosition\r
+ }\r
+ }\r
+}
\ No newline at end of file
--- /dev/null
+void main(){\r
+ outColor = mix(color1,color2,factor);\r
+}
\ No newline at end of file
--- /dev/null
+void main(){\r
+ outColor = color1 * color2;\r
+}
\ No newline at end of file
--- /dev/null
+void main(){\r
+ outColor = texture2D(texture,texCoord);\r
+}
\ No newline at end of file
--- /dev/null
+void main(){\r
+ outPosition = transformsMatrix * vec4(inputPosition, 1.0);\r
+}
\ No newline at end of file
--- /dev/null
+ShaderNodesDefinitions {\r
+ ShaderNodeDefinition CommonVert {\r
+ Type: Vertex\r
+ Shader GLSL100: Common/MatDefs/ShaderNodes/Common/commonVert.vert\r
+ Documentation {\r
+ This Node is responsible for computing vertex position in projection space.\r
+ It also can pass texture coordinates 1 & 2, and vertexColor to the frgment shader as varying (or inputs for glsl >=1.3) \r
+ @input modelPosition the vertex position in model space (usually assigned with Attr.inPosition or Global.position)\r
+ @input worldViewProjectionMatrix the World View Projection Matrix transforms model space to projection space.\r
+ @input texCoord1 The first texture coordinates of the vertex (usually assigned with Attr.inTexCoord)\r
+ @input texCoord2 The second texture coordinates of the vertex (usually assigned with Attr.inTexCoord2)\r
+ @input vertColor The color of the vertex (usually assigned with Attr.inColor) \r
+ @output projPosition Position of the vertex in projection space.(usually assigned to Global.position)\r
+ @output vec2 texCoord1 The first texture coordinates of the vertex (output as a varying)\r
+ @output vec2 texCoord2 The second texture coordinates of the vertex (output as a varying)\r
+ @output vec4 vertColor The color of the vertex (output as a varying)\r
+ } \r
+ Input{\r
+ vec3 modelPosition \r
+ mat4 worldViewProjectionMatrix \r
+ vec2 texCoord1\r
+ vec2 texCoord2\r
+ vec4 vertColor\r
+ }\r
+ Output{\r
+ vec4 projPosition\r
+ vec2 texCoord1\r
+ vec2 texCoord2\r
+ vec4 vertColor\r
+ }\r
+ }\r
+}
\ No newline at end of file
--- /dev/null
+ShaderNodeDefinitions{\r
+ ShaderNodeDefinition Unshaded{\r
+ Type: Fragment\r
+ Shader GLSL100: Common/MatDefs/ShaderNodes/Common/unshaded.frag\r
+ Documentation {\r
+ This Node is responsible for outputing the unshaded color of a fragment.\r
+ It can support texture mapping, an arbitrary input color and a vertex color \r
+ (all resulting colors will be multiplied) \r
+ @input texCoord the texture coordinates to use for texture mapping\r
+ @input vertColor the vertex color (often comming from a varrying)\r
+ @input matColor the material color (often comming from a material parameter) \r
+ @input colorMap the texture to use for texture mapping \r
+ @input color the color this node contribution will be multiplied to\r
+ @output outColor the color of the pixel (usually assigned to Global.color) \r
+ }\r
+ Input{ \r
+ vec2 texCoord \r
+ vec4 vertColor \r
+ vec4 matColor\r
+ sampler2D colorMap \r
+ vec4 color\r
+ }\r
+ Output{\r
+ vec4 color \r
+ }\r
+ }\r
+}
\ No newline at end of file
--- /dev/null
+void main(){\r
+ projPosition = worldViewProjectionMatrix * vec4(modelPosition, 1.0);\r
+}
\ No newline at end of file
--- /dev/null
+void main(){\r
+ #ifdef colorMap\r
+ color *= texture2D(colorMap, texCoord);\r
+ #endif\r
+\r
+ #ifdef vertColor\r
+ color *= vertColor;\r
+ #endif\r
+\r
+ #ifdef matColor\r
+ color *= matColor;\r
+ #endif\r
+\r
+}
\ No newline at end of file
--- /dev/null
+ShaderNodesDefinitions { \r
+ ShaderNodeDefinition FogFactor{\r
+ Type: Vertex\r
+ Shader GLSL100: Common/MatDefs/ShaderNodes/Fog/fogFactor.vert \r
+ Documentation {\r
+ This Node is responsible for computing the fog factor of a vertex in the vertex shader.\r
+ It computes the fogFactor according to view space z (distance from cam to vertex) and a fogDensity parameter.\r
+ This Node should be used with a FogOutput for the fragment shader to effectively output the fog color. \r
+ @input modelPostion the vertex position in model space\r
+ @input modelViewMatrix the model view matrix responsible to transform a vertex position from model space to view space. \r
+ @input fogDensity the fog density (usually assigned with a material parameter) \r
+ @output fogFactor the fog factor of the vertex output as a varying\r
+ }\r
+ Input{ \r
+ vec4 modelPosition \r
+ // Note here that the fog vertex shader will compute position of the vertex in view space\r
+ // This is a pretty common operation that could be used elsewhere.\r
+ // IMO I would split this in 2 ShaderNodes, so that the view space pos could be reused.\r
+ mat4 modelViewMatrix \r
+ float fogDensity\r
+ }\r
+ Output{\r
+ float fogFactor \r
+ }\r
+ }\r
+ ShaderNodeDefinition FogOutput{\r
+ Type: Fragment\r
+ Shader GLSL100: Common/MatDefs/ShaderNodes/Fog/fogOutput.frag\r
+ Documentation {\r
+ This Node is responsible for multiplying a fog contribution to a color according to a fogColor and a fogFactor.\r
+ This node should be used with a FogFactor node that will be responsible to compute the fogFactor in the vertex shader. \r
+ @input fogFactor the previously computed fog factor \r
+ @input fogColor the fog color\r
+ @input color the color the fog contribution will be multiplied to. \r
+ @output color the color with fog contribution (usually assigned to Global.color) \r
+ }\r
+ Input{ \r
+ float fogFactor\r
+ vec4 fogColor\r
+ vec4 color\r
+ }\r
+ Output{\r
+ vec4 color\r
+ }\r
+ }\r
+}
\ No newline at end of file
--- /dev/null
+const float LOG2 = 1.442695;\r
+void main(){ \r
+ vec4 viewSpacePos = modelViewMatrix * modelPosition;\r
+ fogFactor = exp2(-fogDensity * fogDensity * viewSpacePos.z * viewSpacePos.z * LOG2 );\r
+ fogFactor = clamp(fogFactor, 0.0, 1.0);\r
+}
\ No newline at end of file
--- /dev/null
+void main(){\r
+ color = mix(fogColor, color, fogFactor);\r
+}
\ No newline at end of file
--- /dev/null
+ShaderNodeDefinitions{\r
+ ShaderNodeDefinition LightMapping{\r
+ Type: Fragment\r
+ Shader GLSL100: Common/MatDefs/ShaderNodes/LightMapping/lightMap.frag\r
+ Documentation {\r
+ This Node is responsible for multiplying a light mapping contribution to a given color. \r
+ @input texCoord the texture coordinates to use for light mapping\r
+ @input lightMap the texture to use for light mapping \r
+ @input color the color the lightmap color will be multiplied to\r
+ @output color the resulting color \r
+ }\r
+ Input{ \r
+ vec2 texCoord\r
+ sampler2D lightMap \r
+ vec4 color \r
+ }\r
+ Output{\r
+ vec4 color\r
+ }\r
+ } \r
+}
\ No newline at end of file
--- /dev/null
+void main(){\r
+ color *= texture2D(lightMap, texCoord);\r
+}
\ No newline at end of file