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
Home
Tutorials
Tutorials Home
Basic Tutorials
Intermediate Tutorials
Mad Marx Tutorials
In Depth Tutorials
Older Tutorials
External Tutorials
Cookbook
Cookbook Home
CodeBank
Snippets
Experiences
Ogre Articles
Libraries
Libraries Home
Alternative Languages
Assembling A Toolset
Development Tools
OGRE Libraries
List of Libraries
Tools
Tools Home
DCC Tools
DCC Tutorials
DCC Articles
DCC Resources
Assembling a production pipeline
Development
Development Home
Roadmap
Building Ogre
Installing the Ogre SDK
Setting Up An Application
Ogre Wiki Tutorial Framework
Frequently Asked Questions
Google Summer Of Code
Help Requested
Ogre Core Articles
Community
Community Home
Projects Using Ogre
Recommended Reading
Contractors
Wiki
Immediate Wiki Tasklist
Wiki Ideas
Wiki Guidelines
Article Writing Guidelines
Wiki Styles
Wiki Page Tracker
Ogre Wiki Help
Ogre Wiki Help Overview
Help - Basic Syntax
Help - Images
Help - Pages and Structures
Help - Wiki Plugins
Toolbox
Freetags
Categories
List Pages
Structures
Trackers
Statistics
Rankings
List Galleries
Ogre Lexicon
Comments
History: Holographe Shader
View page
Source of version: 5
(current)
{maketoc} !!Description As they are many holo... hologram... and holographic shaders, this one is called "holographe". This shader contains several effects: * one __color gradient__ from the center vertical axis of the object to the border. (In my example: dark when pixel is near the center and brighter when away). * one __transparency gradient__ from the center vertical axis of the object to the border. (In my example: transparent when pixel is near the center). * __noise__: dark bands, light bands, transparent bands scolling along the object. I have tried several ways to do it: with a fixed colour, or with a palette file, or with custom parameters... Finally I think that the pictures files offer more flexibility. As this is one of my first shader creation, feel free to make it better, or to give remarks in the discussion page. {img src="img/wiki_up/Holographe.jpg" alt="Holographe.jpg"} !!Usage * You need to pass the __object radius__ as a __custom parameter__ to the shader, for every object that will use this material. * You need to have 2 TGA files (RGB+A) : one for the color gradient, and one for the noise. * The __holoColour texture__: the picture size is 1 x 256 for instance. The right pixels are the color/transparency at the center of the object, and the rightest pixel at the border of the object. * The __holoNoise texture__: the picture size is 1 x 256. This picture is filled with noise. Black dots will give a dark line, white dots a bright line, and alpha dots a transparent line. !!Material {CODE(wrap="1", colors="c++")} vertex_program shader/holographeVP cg { source holographe3.cg entry_point main_vp profiles vs_1_1 default_params { param_named_auto worldViewProj worldviewproj_matrix } } fragment_program shader/holographeFP cg { source holographe3.cg entry_point main_fp profiles ps_2_x } material shader/hologram { technique { pass { scene_blend alpha_blend vertex_program_ref shader/holographeVP { param_named_auto customParamRadius custom 0 } fragment_program_ref shader/holographeFP { param_named_auto Time time } texture_unit holoColour { texture holoColour1D.tga 1d } texture_unit holoNoise { texture holographe1D.tga 1d tex_address_mode wrap } } } } {CODE} !!Vertex Program {CODE(wrap="1", colors="c++")} // -------------------------------------------------------------------- // ''Author : David de Lorenzo'' // ''Holographe Shader - Vertex Program'' // ----------------------------------------------------------------- void main_vp( in float4 position : POSITION, uniform float4x4 worldViewProj, uniform float4 customParamRadius, out float4 oPosition : POSITION, out float4 oMisc : TEXCOORD0 ) { // ''calculate output position'' oPosition = mul(worldViewProj, position); // ''we pass the vertex position to the fragment shader'' oMisc = position; oMisc.w = customParamRadius.x; } {CODE} !!Fragment Program {CODE(wrap="1", colors="c++")} // ----------------------------------------------------------------- // ''Author : David de Lorenzo'' // ''Holographe Shader - Fragment Program'' // ''Effect #1: Area near the center of the object are more transparent'' // ''Effect #2: Light and dark bands are moving upwards on the object surface'' // ''param iPos : the position of the fragment, supplied by the VP'' // ''param Time : the time in [0....]'' // ''param hologNoise : a RGBA file (1x256 pixels) with little noise'' // ''param hologColour : a RGBA file (1x256 pixels) with a color and transparency gradient'' // ----------------------------------------------------------------- float4 main_fp( in float4 iPos : TEXCOORD0, uniform float Time, uniform sampler1D holoNoise, uniform sampler1D holoColour ) : COLOR0 { float4 oColor; float objectradius = iPos.w; // ''Cylinder type hologram'' // ''Distance from actual Vertex to center'' float Vdist = (iPos.x*iPos.x) + (iPos.z*iPos.z); // ''Normalize distance to [0..1]'' float ratio = Vdist / (objectradius*objectradius); oColor = tex1D(holoColour, ratio); float index = (iPos.y-Time) * 0.05; float4 colorBand = tex1D(holoNoise,index); // ''We add light bands and dark bands'' oColor.rgb = oColor.rgb * colorBand.rgb; // ''We add bands with transparency'' oColor.a = oColor.a * colorBand.a; return (oColor); } {CODE} Enjoy! --- Alias: (alias(Holographe_Shader))
Search by Tags
Search Wiki by Freetags
Latest Changes
Minimal Ogre Collision
Artifex Terra
OpenMB
Advanced Mogre Framework
MogreSocks
Critter AI
Mogre Add-ons
MOGRE
Mogre MyGUI wrapper
MOGRE Editable Terrain Manager
...more
Search
Find
Advanced
Search Help
Online Users
44 online users