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: Shader Model 2 Glass Shader
View page
Source of version: 9
(current)
Shader Model 2 Glass Shader !!Description This shader is based on one that I found at http://ogre3d.org/forums/viewtopic.php?f=2&t=48790. It is a glass shader that can contain entities that use the wiki Diffuse/Normal/Specular hardware skinning shader posted to http://www.ogre3d.org/tikiwiki/Normal+Mapping+with+Hardware+Skinning+and+Specular&structure=Cookbook, as is shown in the screenshot below. It should work with gpu's that support shader model 2 and above. A live ogre scene is posted to: [http://www.ifam.net/openspace/glassdemo/web/index.html|http://www.ifam.net/openspace/glassdemo/web/index.html]. You need win os and the scol voyager plugin (from openspace.com) 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. {IMG(src="http://www.scolring.org/files/divers/forum/Capture-h_glassdemo.png")}{IMG} Todo: add more screen shots maybe early tomorrow morning and move this page to the Shaders section, something I have not figured out. !!Usage just add the material {MONO()}model_2_glassshader{MONO} to your object. It is a bit unpredictable with materials that are contained within it. Entities with multiple materials tend not to display some submeshes. Why? I don't know. Perhaps I should become a shader programmer if I ever have time. Advantages: one pass, perhaps it saves CPU resources? Disadvantages: don't try to apply this material to an entity that has hardware skinning shaders used on it as well. Many wacky things can happen. Todo or more like a plea: if someone can get this material to incorporate hardware skinning, go for it! Then it could be used for spacesuit visors, robot turrets, monster eyeball glasses, etc. !!Material file {CODE(wrap="1", colors="c++")} vertex_program test5_vs cg { source forumglass.cg entry_point main_vs profiles vs_1_1 arbvp1 } fragment_program test5_ps cg { source forumglass.cg entry_point main_ps profiles ps_2_0 arbfp1 } material model_2_glassshader { technique { pass { scene_blend alpha_blend depth_write on //alpha_rejection greater 128 vertex_program_ref test5_vs { param_named_auto world world_matrix param_named_auto viewProj viewproj_matrix param_named_auto eyePositionWorld camera_position } fragment_program_ref test5_ps { } texture_unit { cubic_texture Mars.dds combinedUVW alpha_op_ex source1 src_manual src_current 0.01 colour_op modulate tex_address_mode clamp } } } } {CODE} !!forumglass.cg {CODE(wrap="1", colors="c++")} void main_vs( float4 inPosition: POSITION, float3 inNormal: NORMAL, out float4 outPosition: POSITION, out float3 outNormal: TEXCOORD0, out float3 outViewVec: TEXCOORD1, uniform float4x4 world, uniform float4x4 viewProj, uniform float3 eyePositionWorld ){ float4 worldPosition = mul(world,inPosition); outPosition = mul(viewProj, worldPosition); outNormal = normalize(mul(world,float4(inNormal,0)).xyz); outViewVec = normalize(eyePositionWorld - worldPosition); } void main_ps( float3 inNormal: TEXCOORD0, float3 inViewVec: TEXCOORD1, out float4 outColor : COLOR, uniform samplerCUBE ReflectTex ){ float v = dot(inViewVec, inNormal); float3 reflectionVec = reflect(-inViewVec, inNormal); float3 reflection = texCUBE(ReflectTex, reflectionVec*2); outColor = float4(reflection, 1.2 - v); } {CODE} To make the material transparent, play with the float number in the last line of the .cg file, i.e. .9-v, or .5-v, etc. I'm sure you can get other cool effects by playing around with other parameters. --- Alias: (alias(Shader Model 2 Glass Shader))
Search by Tags
Search Wiki by Freetags
Latest Changes
IDE Eclipse
FMOD SoundManager
HDRlib
Building Ogre V2 with CMake
Ogre 2.1 FAQ
Minimal Ogre Collision
Artifex Terra
OpenMB
Advanced Mogre Framework
MogreSocks
...more
Search
Find
Advanced
Search Help
Online Users
133 online users