TraceColorDirect
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 17/11/2002 at 02:39, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 8.012
Platform: Windows ;
Language(s) : C.O.F.F.E.E ; C++ ;---------
I qwant to get the correct color of a pixel including all reflections, refractions , transparence , and everything.
if i do the following i just get the shaded material color , but the reflections are not there and transparence is also not there , so it looks pretty dull
vps->vd->GetRay(screenxpos,screenypos,&myray);
myray.pp[0]=myray.pp[1]=myray.pp[2]=SV(myray.p);// todo sort this loop out
myray.vv[0]=myray.vv[1]=myray.vv[2]=SV(myray.v);
VolumeData *cpy = VolumeData::Alloc();if (!cpy) return RAY_OK;
vps->vd->CopyTo(cpy); // copy vd settings to cpy
Vector Col=cpy->TraceColorDirect(&myray, 100000,cpy->raydepth+1,cpy->raybits|RAY_REFLECTION, cpy->lhit, &p,&n,&hit);
VolumeData::Free(cpy);
this produces a result but without reflections ,ect.
so id like to know how do i go about getting the complete pixel color !!!
cheers
Paul -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 17/11/2002 at 05:41, xxxxxxxx wrote:
Did you set SHADER_RAYTRACING/CHANNEL_RAYTRACING to initialize the Raytracer?
Like in COFFEE I guess it has to be used to work correctly. In COFFEE that would be SHADER_RAYTRACING in the GetInfo Method to use the Raytracer when using i.e. TraceGeometry.
Should be the same in C++.
Best
Samir -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 17/11/2002 at 06:10, xxxxxxxx wrote:
its not a shader.
im calling tracecolordirect from with a videopost plugin.
vps->vp==VP_INNER && vps->open
so before render even begins.
it works fine , just that reflections and transparence are not calculated.
just shaders seem to be evaluated. -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 17/11/2002 at 06:33, xxxxxxxx wrote:
I know, but it belongs to the volume data (that is available since VP_RENDER) and when the TraceColor, TraceColorDirect and the TraceGeometry functions need the raytracer to be initialized with SHADER_RAYTRACING I guess this would be the case even in Videopost to use these Methods.
--------------------
it works fine , just that reflections and transparence are not calculated.
--------------------
Yeah, That´s why the only thing I can think of why the TraceColorDirect will not return Reflection etc. Colors is that the raytracer doesn´t know that you need the RAYTRACING.
But I hope Mikael (or David O.) can tell you more (and better) about it.
Good Luck
Best
Samir -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 17/11/2002 at 09:25, xxxxxxxx wrote:
Did you set VIDEOPOST_RAYTRACING in GetRenderInfo()?
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 17/11/2002 at 22:29, xxxxxxxx wrote:
Did you set VIDEOPOST_RAYTRACING in GetRenderInfo()?
yes .
here is a little snippet, or bet ter still the entire vp plugin.
as you can see its not trying to do anything strange. but it just doesnt include reflection , transparence and a whol lot of other stuff.
its just giving the crude shaded color
#include "c4d.h"
class InvertData : public VideoPostData
{
public:
static NodeData *Alloc(void) { return gNew InvertData; }
virtual LONG Execute(PluginVideoPost *node, VideoPostStruct *vps);
virtual LONG GetRenderInfo(PluginVideoPost *node) { return VIDEOPOST_RAYTRACING; }
};
LONG InvertData::Execute(PluginVideoPost *node, VideoPostStruct *vps)
{if (vps->vp==VP_INNER && vps->open && *vps->error==RAY_OK && !vps->thread->TestBreak())
{
RayParameter *ray = vps->vd->GetRayParameter(); // only in VP_INNER & VP_RENDER
if (!ray) return RAY_NOMEM;
LONG x1,y1,x2,y2,x,y,cnt,i;x1 = ray->left; // you could try by just rendering the entire screen area
y1 = ray->top;
x2 = ray->right;
y2 = ray->bottom;
cnt = x2-x1+1;
Ray myray,myray1;
LONG px,py,l,ho,hit=0;
Vector no,po,p1,n1;
LVector p,n;
UWORD R,G,B,A;LONG sum=0,skip=0;
Real bmpw=globalmap->GetBw();
Real bmph=globalmap->GetBh();
Real c1=1.0/255.0;
Real Xfac=1.0/rw;
Real Yfac=1.0/rh;
Real XBfac=1.0/bmpw;
Real YBfac=1.0/bmph;
// be sure that "globalmap" is a bitmap big enough for the screen
// region_from and region_to define an area to be rendered
// rendering a specific area
while ( Allow_Render)
{
for (py=region_from.y-ct;py<region_to.y-ct;py++)
{
for (px=region_from.x;px<region_to.x;px++)
{
vps->vd->GetRay(px,py,&myray);
myray.pp[0]=myray.pp[1]=myray.pp[2]=SV(myray.p);// todo sort this loop out
myray.vv[0]=myray.vv[1]=myray.vv[2]=SV(myray.v);
VolumeData *cpy = VolumeData::Alloc();if (!cpy) return RAY_OK;
vps->vd->CopyTo(cpy); // copy vd settings into cpy
Vector Col=cpy->TraceColorDirect(&myray, 100000,cpy->raydepth+1,cpy->raybits,cpy->lhit, &p,&n,&hit);if (hit) sum++;
VolumeData::Free(cpy); // free copied data
// no reflections
globalmap->SetPixel(px,py,Clamp(0,255,Col.x*255.0),Clamp(0,255,Col.y*255),Clamp(0,255,Col.z*255));
}
}
}
}
return RAY_OK;
}
#define ID_SECRETVIDEOPOST ######## // a number
Bool RegisterVPsecret(void)
{
String name="Active Renderer";
return RegisterVideoPostPlugin(ID_SECRETVIDEOPOST,name,0,InvertData::Alloc,"",0,0);
}any ideas why tracecolordirect wont return a usefull color??
cheers
Paul -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 23/11/2002 at 03:01, xxxxxxxx wrote:
hi Paul,
this is from David O'Reilly about the same problem !
--------------------------------------------------------------------------------------------
TraceColor is designed to return the sampled color for the given ray at
its intersection, it does not recursively trace other rays, you need to do
that yourself. Maybe you are thinking of GetSurfaceData() this traces
shadows, transparency and reflections for you for a given ray and point.
--------------------------------------------------------------------------------------------
best regards,
JAY -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 23/11/2002 at 04:01, xxxxxxxx wrote:
thats it !!!
cheers jay