Volume Shader/GI
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 10/12/2002 at 13:13, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 7. - 8.
Platform: Windows ;
Language(s) : C++ ;---------
Do you have to do any extra coding to accommodate global illumination when writing a volume shader. I noticed both the standard materials and bhodi shaders include global illumination and caustic controls. I didn't see anything obvious in the API docs on this.
Any help would be greatly appreciated. -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 10/12/2002 at 21:07, xxxxxxxx wrote:
The enumerations in v7 are:
MAT_GI_RECEIVE
MAT_GI_GENERATE
MAT_GI_RECEIVESTRENGTH
MAT_CS_RECEIVE
MAT_CS_GENERATE
MAT_CS_SAMPLERADIUS
MAT_CS_ACCURACY
MAT_GI_GENERATESTRENGTH
MAT_CS_GENERATESTRENGTH
MAT_CS_RECEIVESTRENGTH
As for what they are or how they are implemented into v8 I would be very interested. I did implement the parameters into SLA 2.5 and it was kind of crazy. Any ideas Mikael?
darf -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 11/12/2002 at 13:03, xxxxxxxx wrote:
Hi...Thanks for the info.
Sorry for my ignorance, but how would I use these id numbers? Are they received as messages or something like that? I didn't see anything in the API docs that explains what to do about GI.
BTW, great work on SLA.
-- Skyler -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 11/12/2002 at 15:22, xxxxxxxx wrote:
Hey Skyler,
The enumerations were used to set BaseContainer items in the material's data ( you would set this data when the corresponding shader parameters were changed ). Unfortunately it does not look like these enumerations are declared in the v8 SDK leading me to believe that it changed but the information is not available in the SDK documentation. I currently have some pretty cool stuff I would like to add GI/Caustic parameters to but I am stuck in the same situation. No info yet...
Have you been sent to solve the mysteries of C4D/DarkTree? If you ever need any help you can post on the general boards over at 'forum.bhodinut.com'. Shaders are a passion for me. For some reason ( probably childhood trauma ) I do it for fun.
darf -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 11/12/2002 at 23:38, xxxxxxxx wrote:
The constants have moved in R8 and are now found in Mmaterial:
MATERIAL_GLOBALILLUM_GENERATE = 1101, MATERIAL_GLOBALILLUM_GENERATE_STRENGTH= 1112, MATERIAL_GLOBALILLUM_RECEIVE = 1100, MATERIAL_GLOBALILLUM_RECEIVE_STRENGTH = 1102, MATERIAL_GLOBALILLUM_SATURATION = 1115, MATERIAL_CAUSTICS_GENERATE = 1109, MATERIAL_CAUSTICS_GENERATE_STRENGTH = 1113, MATERIAL_CAUSTICS_RECEIVE = 1108, MATERIAL_CAUSTICS_RECEIVE_STRENGTH = 1114, MATERIAL_CAUSTICS_SAMPLERADIUS = 1110, MATERIAL_CAUSTICS_SAMPLES = 1111,
Here are the necessary steps in R8:
1.) Add these constants (with a different name though) to your material (*.res, *.h and *.str). Here's a sample for the simple material example:.h: SIMPLEMATERIAL_CAUSTICS_GENERATE = 1109, SIMPLEMATERIAL_CAUSTICS_GENERATE_STRENGTH = 1113, SIMPLEMATERIAL_CAUSTICS_RECEIVE = 1108, SIMPLEMATERIAL_CAUSTICS_RECEIVE_STRENGTH = 1114, SIMPLEMATERIAL_CAUSTICS_SAMPLERADIUS = 1110, SIMPLEMATERIAL_CAUSTICS_SAMPLES = 1111, ID_SIMPLEMATERIALGROUP_ILLUMINATION = 2000 // virtual ID .str: ID_SIMPLEMATERIALGROUP_ILLUMINATION "Illumination"; SIMPLEMATERIAL_GLOBALILLUM_GENERATE "GI Generate" "Generate GI"; SIMPLEMATERIAL_GLOBALILLUM_GENERATE_STRENGTH "GI Generate Strength" "Strength"; SIMPLEMATERIAL_GLOBALILLUM_RECEIVE "GI Receive" "Receive GI"; SIMPLEMATERIAL_GLOBALILLUM_RECEIVE_STRENGTH "GI Receive Strength" "Strength"; SIMPLEMATERIAL_GLOBALILLUM_SATURATION "GI Saturation" "Saturation"; SIMPLEMATERIAL_CAUSTICS_GENERATE "Caustics Generate" "Generate Caustics"; SIMPLEMATERIAL_CAUSTICS_GENERATE_STRENGTH "Caustics Generate Strength" "Strength"; SIMPLEMATERIAL_CAUSTICS_RECEIVE "Caustics Receive" "Receive Caustics"; SIMPLEMATERIAL_CAUSTICS_RECEIVE_STRENGTH "Caustics Receive Strength" "Strength"; SIMPLEMATERIAL_CAUSTICS_SAMPLERADIUS "Caustics Sample Radius" "Radius"; SIMPLEMATERIAL_CAUSTICS_SAMPLES "Caustics Samples" "Samples"; .res: GROUP ID_SIMPLEMATERIALGROUP_ILLUMINATION { COLUMNS 2; BOOL SIMPLEMATERIAL_GLOBALILLUM_GENERATE {} REAL SIMPLEMATERIAL_GLOBALILLUM_GENERATE_STRENGTH { UNIT PERCENT; MIN 0.0; MAX 10000.0; } BOOL SIMPLEMATERIAL_GLOBALILLUM_RECEIVE {} REAL SIMPLEMATERIAL_GLOBALILLUM_RECEIVE_STRENGTH { UNIT PERCENT; MIN 0.0; MAX 10000.0; } SEPARATOR { } REAL SIMPLEMATERIAL_GLOBALILLUM_SATURATION { UNIT PERCENT; MIN 0.0; MAX 1000.0; } SEPARATOR { } SEPARATOR { } BOOL SIMPLEMATERIAL_CAUSTICS_GENERATE {} REAL SIMPLEMATERIAL_CAUSTICS_GENERATE_STRENGTH { UNIT PERCENT; MIN 0.0; MAX 10000.0; } BOOL SIMPLEMATERIAL_CAUSTICS_RECEIVE {} REAL SIMPLEMATERIAL_CAUSTICS_RECEIVE_STRENGTH { UNIT PERCENT; MIN 0.0; MAX 10000.0; } SEPARATOR { } REAL SIMPLEMATERIAL_CAUSTICS_SAMPLERADIUS { UNIT METER; MIN 0.0; } SEPARATOR { } LONG SIMPLEMATERIAL_CAUSTICS_SAMPLES { MIN 1; MAX 10000; } }
After that C4D will look at these values and sample your material accordingly. You shouldn't need to change anything in the shader part of the code.
2.) To implement the ghosting on the illumination page add the following lines of code (SimpleMaterial example as well) :Bool SimpleMaterial::GetDEnabling(GeListNode *node, const DescID &id,GeData &t_data,LONG flags,const BaseContainer *itemdesc) { BaseContainer *dat = ((BaseMaterial* )node)->GetDataInstance(); Bool gi_available = C4DOS.Ra->ComputeDiffuseIllumination!=NULL; switch (id[0].id) { case MATERIAL_GLOBALILLUM_GENERATE: case MATERIAL_GLOBALILLUM_RECEIVE: case MATERIAL_CAUSTICS_GENERATE: case MATERIAL_CAUSTICS_RECEIVE: return gi_available; case MATERIAL_GLOBALILLUM_GENERATE_STRENGTH: return gi_available && dat->GetBool(MATERIAL_GLOBALILLUM_GENERATE); case MATERIAL_GLOBALILLUM_RECEIVE_STRENGTH: case MATERIAL_GLOBALILLUM_SATURATION: return gi_available && dat->GetBool(MATERIAL_GLOBALILLUM_RECEIVE); case MATERIAL_CAUSTICS_GENERATE_STRENGTH: return gi_available && dat->GetBool(MATERIAL_CAUSTICS_GENERATE); case MATERIAL_CAUSTICS_RECEIVE_STRENGTH: return gi_available && dat->GetBool(MATERIAL_CAUSTICS_RECEIVE); case MATERIAL_CAUSTICS_SAMPLERADIUS: case MATERIAL_CAUSTICS_SAMPLES: return (dat->GetBool(MATERIAL_CAUSTICS_RECEIVE) || dat->GetBool(MATERIAL_CAUSTICS_GENERATE)) && gi_available; } return SUPER::GetDEnabling(node,id,t_data,flags,itemdesc); }
That's it!