Skip to main content
History: Shader Model 2 Plastic
View published page
Source of version: 7
(current)
Shader Model 2 Plastic Shader !!Description This shader is exported from rendermonkey 1.61 with one change to one line of code in the .material file as noted below. Can't find the rm exporter on the web? It's posted to the bottom of this page. It should work with gpu's that support shader model 2 and above. A live Openspace scene (that uses Ogre for 3d, Newton for physics, OpenAL for sound) is posted to: [http://www.ifam.net/openspace/rmplastic2/web/|http://www.ifam.net/openspace/rmplastic2/web/]. You need win os or linux running wine and the scol voyager plugin (from http://scolring.org/index.php/logiciels ) to view the scene. If the plugin is not installed on your system you will be prompted for an install. Openspace like Ogre is opensource. The upside to this shader like any of the rendermonkey shaders is that you can fool around with the variables in rendermonkey and preview them instantly in that app. I think there is a bug in the rendermonkey exporter. With some help of one of the developers of openspace, I found that you should change the line: {CODE(wrap="1", colors="c++")} param_named_auto 0 world_viewProj viewproj_matrix {CODE} to {CODE(wrap="1", colors="c++")} param_indexed_auto 0 worldviewproj_matrix {CODE} otherwise if you transform the object that is painted with the shader, the shader won't move or scale along with the node that holds the entity on which the shader is painted. colleagues: feel free to remove my commented out code, -h Here is one of my monsters painted in red plastic: {IMG(src="http://www.ifam.net/openspace/rmplastic2/rmplastic.png")}{IMG} !!Usage Just add the material __rmplastic__ to your object.I have not modified it to work with hardware skinnig. Anyone who wants to do that go ahead and edit this page an add the hardware skinning version below mine. !!Material file {CODE(wrap="1", colors="c++")} //DirectX 9.0 HLSL Vertex Shader vs_1_1 vertex_program plasticvertex hlsl { source plasticvertex.hlsl target vs_1_1 entry_point main } //DirectX 9.0 HLSL Pixel Shader ps_2_0 fragment_program plasticpixel hlsl { source plasticpixel.hlsl target ps_2_0 entry_point main } //Effect: Plastic material rmplastic { technique { //Rendering Pass: Single Pass (pass index: #0 ) pass { //DirectX 9.0 HLSL Pixel Shader ps_2_0 fragment_program_ref plasticpixel { //Shader Constant: color param_indexed 0 float4 1.000000 0.300752 0.000000 1.000000 } //DirectX 9.0 HLSL Vertex Shader vs_1_1 vertex_program_ref plasticvertex { //Shader Constant: view_position //param_named_auto eyePositionWorld camera_position param_indexed_auto 4 camera_position_object_space param_indexed_auto 0 worldviewproj_matrix } } } } {CODE} !!plasticvertex.hlsl {CODE(wrap="1", colors="c++")} float4x4 viewproj_matrix : register(c0); float4 view_position: register(c4); struct VS_OUTPUT { float4 Pos: POSITION; float3 normal: TEXCOORD0; float3 viewVec: TEXCOORD1; }; VS_OUTPUT main(float4 Pos: POSITION, float3 normal: NORMAL){ VS_OUTPUT Out; Out.Pos = mul(viewproj_matrix, Pos); // World-space lighting Out.normal = normal; Out.viewVec = view_position - Pos; return Out; } {CODE} !!plasticpixel.hlsl {CODE(wrap="1", colors="c++")} float4 color: register(c0); float4 main(float3 normal: TEXCOORD0, float3 viewVec: TEXCOORD1) : COLOR { // Simple lighting lighting model for a dull plastic appearance. float v = 0.5 * (1 + dot(normalize(viewVec), normal)); return v * color; } {CODE} --- Alias: (alias(Shader Model 2 Plastic))
Search by Tags
Search Wiki by Freetags
Latest Changes
Compiled API Reference
Overlay Editor
Introduction - JaJDoo Shader Guide - Basics
RT Shader System
RapidXML Dotscene Loader
One Function Ogre
One Function Ogre
...more
Search
Find
Online Users
314 online users
OGRE Wiki
Support and community documentation for Ogre3D
Ogre Forums
ogre3d.org
Log in
Username
Password
CapsLock is on.
Remember me (for 1 year)
Log in