Shader Creation thread

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
Old 08 August 2003   #1
Shader Creation thread

Just wanted to start the shader creation thread mentioned by Lyle on the Yahoo boards.

Previously ....
****************************
FX_SHADERINITINPUTS & FX_SHADEREVALUATE are macros you'd use to define your
shader callbacks. When you call:

fxShaderCallback(shader,FX_SHADERFUNC_INITINPUTS,s hader_init);

you're registering the shader_init callback that will be used to initialize
data for your plugin. Then you have to define the function. You'd do it
like so:

FX_SHADERINITINPUTS(shader_init)
{
//initialize your shader inputs...
return;
}

I'll try to give more info over on CGTalk later tonight. It will be a
perfect opportunity to provide the FogBasic shader along with other info.

-lyle

*****************************
Yep, knew all that! Rather than ask more questions now, I'll wait for the FogBasic shader to be posted. That should clear up most of my questions.

Thanks Lyle!

Daniel
 
Old 08 August 2003   #2
I'm putting the FogBasic shader together right now. I'll post it on the yahoo group when I'm done, and we can discuss it here.

Stay tuned...
 
Old 08 August 2003   #3
I got the shader. Just don't know how to use it.

Thanks for the source
 
Old 08 August 2003   #4
FogBasic

I just uploaded the FogBasic shader and sample code to the messiah yahoo group: http://groups.yahoo.com/group/pmGme...iles/pmG_Files/

The FogBasic shader is just that: a basic fog shader. Here is a simple example of its output:



This should be a good starting point in understanding how to write shaders. I'll try to make myself available to participate in this thread... should it blossom, so feel free to ask questions.

-lyle
 
Old 08 August 2003   #5
Quote:
I got the shader. Just don't know how to use it.


Red, Green, Blue = color of fog
Fog Min Depth = minimum fog depth (how close to camera)
Fog Max Depth = maximum fog depth (how far from camera)
Fog Density = the "thinkness" of fog
Fog Function = fog falloff type... try it out
Ground Fog = fog "eminates" from ground

You'd connect this shader (fog_radiance) to the Atmosphere "material" (color) if you want global fog. You can, however, apply it to any material to affect specific surfaces/objects.

Let me know if this makes sense.
 
Old 08 August 2003   #6
cool. I can't get it to effect the backround or Environment when its used with Atmosphere.

Why are some of the outputs connectable and some not? What I mean is, to get it to work, you just hook up the Radiance to the colour channel, so why are the Opacity and Depth available also yet not the colour.

Is this just a decision you have made or is there particular qualities about this data that means it automatically gets included.

Mark
PS. I can't see the image you posted.
 
Old 08 August 2003   #7
Quote:
Originally posted by markpassion
cool. I can't get it to effect the backround or Environment when its used with Atmosphere.

Why are some of the outputs connectable and some not? What I mean is, to get it to work, you just hook up the Radiance to the colour channel, so why are the Opacity and Depth available also yet not the colour.

Is this just a decision you have made or is there particular qualities about this data that means it automatically gets included.

Mark
PS. I can't see the image you posted.


Not quite sure I understand the problem. You can connect any outputs you like to anything input you like. This goes for any shader.

I'm seeing the image fine right here on CGTalk. Did you try getting it from yahoo?

-lyle
 
Old 08 August 2003   #8
The first is a problem ie the background and environment not being affected.

My second point wasn't a problem, I'm just curious what governs what data is presented where on the node, but looks like the coder has full control over that which is cool. So ignore me.

Mark
 
Old 08 August 2003   #9
Hi,
I've put the .mp file in the shaders directory of the messiah installation but it didn't show up in the shader list - how do I install it?

Thanks,

Thomas Helzle

Last edited by ThomasHelzle : 08 August 2003 at 12:04 PM.
 
Old 08 August 2003   #10
I have sent a reply to the yahoo groups as well, but basically the file is a .mp which is Messiah Plugin, which means it should live in the plugins folder.

Mark
 
Old 08 August 2003   #11
Quote:
Originally posted by markpassion
The first is a problem ie the background and environment not being affected.

My second point wasn't a problem, I'm just curious what governs what data is presented where on the node, but looks like the coder has full control over that which is cool. So ignore me.

Mark


The first problem isn't a problem, either Fog should never affect the background or environment.

-lyle
 
Old 08 August 2003   #12
Quote:
Originally posted by markpassion
The first is a problem ie the background and environment not being affected.

My second point wasn't a problem, I'm just curious what governs what data is presented where on the node, but looks like the coder has full control over that which is cool. So ignore me.

Mark


For those of you that are still wondering about Mark's second "problem", yes it's true that the developer has full control over inputs/outputs that appear on the shader node.

When you receive the (requested) O_CREATE entry, it's up to you to create the inputs & outputs. Here's a snippet of the code from FogBasic:

//#4. Create Inputs------------------------------------------------------------
IN_FOG_COLOR = fxShaderCreateInput(shader, "Color", FX_IOTYPE_COLOR, 0);
IN_FOG_MIN_DEPTH = fxShaderCreateInput(shader, "Min_Depth", FX_IOTYPE_FLOAT, 0);
IN_FOG_MAX_DEPTH = fxShaderCreateInput(shader, "Max_Depth", FX_IOTYPE_FLOAT, 0);
IN_FOG_DENSITY = fxShaderCreateInput(shader, "Density", FX_IOTYPE_FLOAT, 0);
//```````````````````````````````````````````

//#5. Create Outputs-----------------------------------------------------------
OUT_FOG_RADIANCE = fxShaderCreateOutput(shader, "Fog_Radiance", FX_IOTYPE_COLOR, 0);
OUT_FOG_DEPTH = fxShaderCreateOutput(shader, "Fog_Depth", FX_IOTYPE_FLOAT, 0);
//```````````````````````````````````````````

So, you'd use fxShaderCreateInput to create inputs & fxShaderCreateOutput to create outputs

You should consult messiah_shader.h for the relevant i/o types.

-lyle
 
Old 08 August 2003   #13
Quote:
The first problem isn't a problem, either Fog should never affect the background or environment.


May I ask why you think so? Often exactly that is needed, at least as an option - or am I misunderstanding something? (wouldn't be the first time :-)

Regards,

Thomas Helzle
 
Old 08 August 2003   #14
Quote:
Originally posted by Thomas_Helzle
May I ask why you think so? Often exactly that is needed, at least as an option - or am I misunderstanding something (wouldn't be the first time :-)

Regards,

Thomas Helzle


While it would be cool to mimic the behavior of LW, there are going to be some trade offs for the added power.

Keeping this all in context, remember that the fog shader is a surface shader; it can only shade what it "hits". Since there can be no background or environment hit, they can't be shaded by fog.

The Atmosphere, Enviroment, & Background camera surface [read: layers] are separate to allow you to maximum control. They function as surfaces in that you can apply any number of shaders to them, but are really special render layers.

However, you should be able to apply the Atmosphere "material" to the Background & Environment camera surfaces. I haven't tried this myself, but it shoud work.

-lyle
 
Old 08 August 2003   #15
Quote:
However, you should be able to apply the Atmosphere "material" to the Background & Environment camera surfaces. I haven't tried this myself, but it shoud work.


I just tried it and it doesn't work for me. The background renders black instead of fog-white...

If it would work the way you said, I would be a happy camper ;-)

Thank you also for the "Depth" output of the Shader - connected to Atmosphere-Color it is perfect for creating a depth-buffer to use for DOF in AfterEffects!

As soon as I have time I will dive into shader coding...

Thanks a lot!
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 05:28 PM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.