#include <SlrShadingContext.h>
Public Member Functions | |
SlrShadingContext () | |
Default ctor leaves junk in most vars, sets pointers to null. | |
void | set (const SlrShadingContext ¤tStx, const ndk::RayContext &Rtx) |
Copies currentStx and params and updates the srcRtx. | |
void | set (const SlrShadingContext ¤tStx, const fdk::Vec3f &Rdir, double tMin, double tMax, const ndk::RayContext::TypeMask &Rtype, uint32_t sides_mode) |
Copies currentStx and params and updates the srcRtx. | |
fdk::TimeValue | time () const |
Absolute time of the context. | |
SlrThreadContext * | sttx () const |
SlrThreadContext which 'owns' this shading context. | |
uint32_t | threadIdx () const |
Thread index from current SlrThreadContext. | |
const SlrShadingContext * | previousStx () const |
Previous SlrShadingContext, normally the last surface intersected/shaded. | |
bool | blendBackToFront () const |
Blending Z order is back-to-front (true) or front-to-back (false) | |
bool | enableColorChannels () const |
Shaders should output color layers + alphas. | |
bool | enableDataChannels () const |
Shaders should output any data channels (Z, etc) | |
bool | textureSamplingEnabled () const |
void | setTextureSampling (bool enabled) |
void | enableTextureSampling () |
void | disableTextureSampling () |
DD::Image::TextureFilter * | textureFilter () const |
Texture filter to use. | |
bool | lightingEnabled () const |
If true, even if no lights the surface shaders should do illum calcs. | |
bool | directLightingEnabled () const |
If true do direct-illumination calculations. | |
bool | indirectLightingEnabled () const |
If true handle indirect-illumation calculations. | |
bool | shadowingEnabled () const |
If true do shadow occlusion for direct-illumination. | |
bool | useHeroCamForSpec () const |
If enabled getViewVector() uses camHeroP() instead of camP(). | |
const SlrTriangle * | rprim () const |
const fdk::Mat4d * | l2w () const |
Local-to-world matrix for current primitive. If null assume xform is identity. | |
const fdk::Mat4d * | w2l () const |
World-to-local matrix for current primitive. If null assume xform is identity. | |
const fdk::Mat4d & | camWorld2Eye () const |
Render camera world-to-eye xform (world-space coords to camera local-space) | |
const fdk::Mat4d & | camEye2World () const |
Render camera eye-to-world xform (camera local-space coords to world-space) | |
const fdk::Vec3d & | camP () const |
const fdk::Vec3d & | camHeroP () const |
Hero-view camera origin in world space - for specular copying. | |
const SlrLightInfoList & | lights () const |
List of active lights. If lightingEnabled is false an empty list is returned. | |
fdk::Vec3d | getViewVector () const |
bool | shadeBothSides () const |
Shade both sides of surface (front and back) ignoring surface normal to camera. | |
bool | shadeFrontOnly () const |
Shade only front side of surface. | |
bool | shadeBackOnly () const |
Shade only front side of surface. | |
void | enableBothSidesMode () |
void | enableFrontSideMode () |
void | enableBackSideMode () |
const fdk::Vec3f & | ambientLightingBias () const |
bool | intersect (const ndk::RayContext &Rtx) const |
bool | getNearestIntersection (const ndk::RayContext &Rtx, SlrShadingContext &hitStx) const |
float | getPolygonEdgeDistance (float minDist) const |
const fdk::Vec2i & | pxy () const |
Current output screen coords. | |
const fdk::Vec2f & | sxy () const |
Current output subpixel screen coords. | |
int32_t | si () const |
Current subsample index. | |
bool | isDebugPixel () const |
bool | isPixel (int32_t px, int32_t py) const |
bool | isPixelX (int32_t px) const |
bool | isPixelY (int32_t py) const |
const fdk::Vec3f & | Ps () const |
Displaced shading point in common shading space where lighting is queried. | |
const fdk::Vec3f & | P () const |
Geometric point (intersection) in common shading space. | |
const fdk::Vec3f & | dPdx () const |
P differential for dyDir ray direction. ('dx' is the ray cone x-axis, not screen-space 'x') | |
const fdk::Vec3f & | dPdy () const |
P differential for dyDir ray direction. ('dy' is the ray cone y-axis, not screen-space 'y') | |
const fdk::Vec3f & | dPdu () const |
P surface u-space partial derivative, not normalized. | |
const fdk::Vec3f & | dPdv () const |
P surface v-space partial derivative, not normalized. | |
const fdk::Vec3f & | triUvw () const |
const fdk::Vec2f | uv () const |
Surface 2D parametric coordinates of P. | |
const fdk::Vec2f | dUVdx () const |
Parametric-uv differential for dxDir ray direction. | |
const fdk::Vec2f | dUVdy () const |
Parametric-uv differential for dyDir ray direction. | |
float | uvw () const |
Surface Z parametric coordinate of P (for volumes) | |
float | dUVWdx () const |
Parametric-w differential for dxDir ray direction. | |
float | dUVWdy () const |
Parametric-w differential for dyDir ray direction. | |
const fdk::Vec2f & | st () const |
Surface texture st(uv) coordinate. st is assumed to have already been divided by any w. | |
const fdk::Vec2f & | dStdx () const |
Texture coord st differential for dxDir ray direction. ('dx' is the ray cone x-axis, not screen-space 'x') | |
const fdk::Vec2f & | dStdy () const |
Texture coord st differential for dyDir ray direction. ('dy' is the ray cone y-axis, not screen-space 'y') | |
const fdk::Vec2f & | dStdu () const |
St surface u-space partial derivative, not normalized. | |
const fdk::Vec2f & | dStdv () const |
St surface v-space partial derivative, not normalized. | |
const fdk::Vec3f & | N () const |
Shading normal, normalized. | |
const fdk::Vec3f & | Ng () const |
Geometric surface normal, normalized. | |
const fdk::Vec3f & | T () const |
Shading tangent, normalized. | |
const fdk::Vec4f & | Cf () const |
Interpolated vertex color + opacity. | |
const fdk::Vec4f & | rgba () const |
const fdk::Vec3f & | rgb () const |
float | r () const |
float | g () const |
float | b () const |
float | a () const |
float | opacity () const |
void | sample (DD::Image::Sampler *sampler, DD::Image::Pixel &out) const |
void | sample (DD::Image::Sampler *sampler, const Dual2Vec2f &v, DD::Image::Pixel &out) const |
Same as sample(Sampler*) but with overrides for st & derivatives currently in context. | |
void | sample (DD::Image::Iop *texture, DD::Image::Pixel &out) const |
Slower version using a raw Iop. | |
void | sample (DD::Image::Iop *texture, const Dual2Vec2f &v, DD::Image::Pixel &out) const |
Same as sample(Iop*) but with overrides for st & derivatives currently in context. | |
DD::Image::Pixel & | textureColor () const |
For sampling texture map Iops - defaults to RGBA. | |
DD::Image::Pixel & | bindingColor () const |
For Connection sampling calls - defaults to RGBA. | |
DD::Image::Pixel & | illumColor () const |
For LightShader evaluation - defaults to RGB. | |
DD::Image::Pixel & | shadowColor () const |
For LightShader shadow transmission evaluation - defaults to RGB (no depth!) | |
DD::Image::Pixel & | volumeColor () const |
For VolumeShader color evaluation - defaults to RGB. | |
Protected Attributes | |
SlrThreadContext * | _sttx |
const SlrShadingContext * | _previousStx |
Previous SlrShadingContext, normally the last surface intersected/shaded. | |
int32_t | _sidesMode |
Which sides to intersect against and shade (use methods to query) | |
bool | _textureSampling |
Whether shaders should sample their textures. | |
DD::Image::TextureFilter * | _textureFilter |
Global texture filter to use. | |
const SlrObjectIntersection * | _If |
Intersection info. | |
SlrTriangle * | _rPrim |
Current render triangle being evaluated. | |
fdk::Mat4d * | _l2w |
Local-to-world object matrix for current primitive. | |
fdk::Mat4d * | _w2l |
World-to-local object matrix for current primitive. | |
Friends | |
class | SlrThreadContext |
class | RenderEngine |
class | RenderSpan |
class | IntersectedSurfaces |
This class is intended to be passed up a SlrShader tree.
|
inline |
Should textures sample? This may be disabled for camera rays when shading a pre-rendered scene with pixel containing the surface albedo.
|
inline |
Render triangle currently being shaded. This can be tested against the rprim() in previousStx() to prevent self-intersection.
const Vec3d & slr::SlrShadingContext::camP | ( | ) | const |
Render camera origin (camera rays originate here). Same as camEye2World().getTranslation(), but cached for speed.
References slr::SlrThreadContext::camP().
Referenced by getViewVector().
fdk::Vec3d slr::SlrShadingContext::getViewVector | ( | ) | const |
Returns a 'fake' stereo view vector built from the camHeroP, or the negated ray direction depending on context's stereo mode. By using the camHeroP camera-ray specular calculations are identical for all stereo cameras, 'flattening' the specular onto the surface.
References camHeroP(), camP(), depth, P(), and useHeroCamForSpec().
const Vec3f & slr::SlrShadingContext::ambientLightingBias | ( | ) | const |
Adds light globally to the diffuse (albedo) surface response of surface shaders which respect this shading global.
bool slr::SlrShadingContext::intersect | ( | const ndk::RayContext & | Rtx | ) | const |
Returns true if anything is occluding the ray, including transparent objects. Does not call shaders or return information about the hit object.
References slr::SlrThreadContext::_objectsBvh.
bool slr::SlrShadingContext::getNearestIntersection | ( | const ndk::RayContext & | Rtx, |
SlrShadingContext & | hitStx | ||
) | const |
Intersect the scene with the RayContext Rtx, returning true if there was a hit within Rtx's distance range, and filling in hitStx with the information about the hit surface.
References _If, slr::SlrThreadContext::_intersectionInfo, slr::SlrThreadContext::_objectsBvh, and depth.
float slr::SlrShadingContext::getPolygonEdgeDistance | ( | float | minDist | ) | const |
Distance from P to the nearest not-occluded polygon edge in screen-space for the current primitive. All triangles generated from the tessellation of the original SlrPrimInfo are tested, so the method checks all polygon edges. Returns when the first edge distance is under minDist.
References _If, slr::SlrThreadContext::_lensContext, slr::SlrThreadContext::_lensFunc, _rPrim, _vP, P(), and params.
|
inline |
Barycentric triangle uvw coordinates at srcRtx intersection. For a triangle with corners (p0 p1 p2) w=1 is along edge p0->p1, u=1 is along edge p1->p2, and v=1 is along edge p0->p2. If v or w are outside 0..1 then P is outside the bounds of the triangle and w in invalid. This happens when uvw is calculated for ray offsets dxDir & dyDir. They will always intersect the triangle plane but can often be outside the triangle's perimeter.
void slr::SlrShadingContext::sample | ( | DD::Image::Sampler * | sampler, |
DD::Image::Pixel & | out | ||
) | const |
Use st() and the derivatives of st() to sample the incoming image. The st coord 0,0 is mapped to the lower-left corner of the image's format, and 1,1 is mapped to the upper-right corner.
For texture sampling it's much faster to provide a DD::Image::Sampler rather than a raw Iop so Tile caching is properly leveraged.
References dStdu(), dStdv(), sample(), and st().
Referenced by sample().
©2024 The Foundry Visionmongers, Ltd. All Rights Reserved. |