Shader Transparency

The place for artists, modellers, level designers et al to discuss their approaches for creating content for OGRE.
Post Reply
Rixeh
Greenskin
Posts: 135
Joined: Sat Nov 20, 2004 8:36 am

Shader Transparency

Post by Rixeh »

Hey all, I need to jump into shaders a bit for the project I'm in, and Ive hit a bump. ;) Been messing around with the Ocean shader nfz posted from Rendermonkey, and was wondering -- how exactly does one go about adding transparency to it? Apparently you can't just tack on a "scene_blend alpha_blend" into the material {pass}, unless I'm doing it wrong..

Hints? 8) Thanks!
nfz
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 1263
Joined: Wed Sep 24, 2003 4:00 pm
Location: Halifax, Nova Scotia, Canada

Post by nfz »

your halfway there. You also have to modify the alpha channel of the fragment shader output. It is currently set to 1.0 so its always opaque so if you want transparence then make it less than 1.0. I did make a modified version that stores fx values ie alpha in a second uv set for each vertex so you could have areas close to shore that are more transparent than deep water. You could also use a second texture as a location map that defines what areas are trasnparent and have foam.

I am not able to get access to all my dev stuff (MB,cpu,ram got cooked due to bad electrolytic capacitors) for the next few weeks to be able to upload an updated demo.
Rixeh
Greenskin
Posts: 135
Joined: Sat Nov 20, 2004 8:36 am

Post by Rixeh »

SWEET, nfz you are the OGRE shader god. I'll try it out tonite and post the code changes if I can get it to work. ;)
Rixeh
Greenskin
Posts: 135
Joined: Sat Nov 20, 2004 8:36 am

Post by Rixeh »

One more thing too dude: is it also possible to write a variable colour change over time into the shader, or is that more of a material script? (Say I want it to fade from transparent to white, down to dark blue, then back transparent again).
Crashy
Google Summer of Code Student
Google Summer of Code Student
Posts: 1005
Joined: Wed Jan 08, 2003 9:15 pm
Location: Lyon, France
x 49
Contact:

Post by Crashy »

You have many solutions.
The easiest will be to give a float4 parameter that contains the color+the alpha channel, and in your main program(not in the shader), change the value of the parameter.
Follow la Moustache on Twitter or on Facebook
Image
Rixeh
Greenskin
Posts: 135
Joined: Sat Nov 20, 2004 8:36 am

Post by Rixeh »

Awesome, thanks for the tips 8)
Lshink
Halfling
Posts: 69
Joined: Sun Mar 05, 2006 6:08 pm

Post by Lshink »

Sorry, I'm really really new to shaders -- how does one go about modifying the alpha channel of the fragment shader output?
Post Reply