Beispiel #1
0
void MyBaseBSDF::traceForward(VRayContext &rc, int doDiffuse) {
	rc.mtlresult.clear();

	RenderElementsResults renderElements;
	renderElements.makeZero();

	if (computeRenderElements) {
		renderElements.diffuseLighting=finalElements.diffuseLighting;
		renderElements.specularLighting=finalElements.specularLighting;
		renderElements.finalShadow=finalElements.shadow;
	}

	float reflectTransp=1.0f;
	int reflectOpaque=false;
	if (2!=doDiffuse && !dontTrace && reflectSamples!=0) {
		renderElements.reflection=computeReflections(rc, reflectTransp, renderElements.reflectionFilter);
		rc.mtlresult.color+=renderElements.reflection;
		reflectOpaque=(reflectTransp<1e-6f);
	}

	if (!reflectOpaque) {
		renderElements.diffuseFilter=params.diffuse*reflectTransp;
		if (doDiffuse) {
			renderElements.rawGI=rc.evalDiffuse()*(1.0f-params.sssMix);
			renderElements.gi=renderElements.rawGI*renderElements.diffuseFilter;
			rc.mtlresult.color+=renderElements.gi;
		}

		if (params.sssMix>1e-6f && renderElements.diffuseFilter.sum()>1e-6f) {
			renderElements.rawSSS=computeRawSSS(rc, renderElements.diffuseFilter)*params.sssMix;
			renderElements.sss=renderElements.rawSSS*renderElements.diffuseFilter;
			rc.mtlresult.color+=renderElements.sss;
		}
	}

	rc.mtlresult.transp=params.transparency;
	rc.mtlresult.alpha=params.transparency.whiteComplement();
	rc.mtlresult.alphaTransp=params.transparency;

	Fragment *f=(Fragment*) rc.mtlresult.fragment;
	if (f) {
		renderElements.finalColor=finalElements.color+rc.mtlresult.color;
		writeRenderElements(f, renderElements);
	}
}
Beispiel #2
0
//NOTE(Vidar): Called whenever a reflection ray is to be calculated
void MyBaseBSDF::traceForward(VRayContext &rc, int doDiffuse) {
	BRDFSampler::traceForward(rc, doDiffuse);
	if (doDiffuse) rc.mtlresult.color+=rc.evalDiffuse()*diffuse_color;
}