레이블이 RenderMan인 게시물을 표시합니다. 모든 게시물 표시
레이블이 RenderMan인 게시물을 표시합니다. 모든 게시물 표시

2011년 12월 6일 화요일

Python Rif Layer - 3

import prman
import sys

class myRif(prman.Rif):
    def __init__(self, ri, shadingrate):
        prman.Rif.__init__(self, ri)
        self.m_shadingrate = int(shadingrate)

    def ShadingRate(self, size):
        self.m_ri.ShadingRate(self.m_shadingrate)

if len(sys.argv) == 4:
    infile = sys.argv[1]
    outfile = sys.argv[2]
    shadingrate = sys.argv[3]
    prman.Init(["-catrib", outfile, "-progress"])
    ri = prman.Ri()
    rif1 = myRif(ri, shadingrate)
    prman.RifInit([rif1])
    ri.Option("rib", {"string asciistyle": "indented"})
    ri.Begin(ri.RENDER)
    prman.ParseFile(infile)
    ri.End()

Python Rif Layer - 2

import prman
import sys

class myRif(prman.Rif):
    def __init__(self, ri):
        prman.Rif.__init__(self, ri)

    def Option(self, name, plist):
        if name == 'user':
            if 'uniform float linearize' in plist:
                self.m_ri.Option('user', {'uniform float linearize': 0})
            else:
                self.m_ri.Option('user', plist)
        else:
            self.m_ri.Option(name, plist)

if len(sys.argv) == 3:
    infile = sys.argv[1]
    outfile = sys.argv[2]
    prman.Init(["-catrib", outfile, "-progress"])
    ri = prman.Ri()
    rif1 = myRif(ri)
    prman.RifInit([rif1])
    ri.Option("rib", {"string asciistyle": "indented"})
    ri.Begin(ri.RENDER)
    prman.ParseFile(infile)
    ri.End()

Python Rif Layer - 1

import prman
import sys

class myRif(prman.Rif):
    def __init__(self, ri):
        prman.Rif.__init__(self, ri)
        self.m_nsubdivs = 0
    def HierarchicalSubdivisionMesh(self, mask, nverts, verts, tags, nargs, intargs, floatargs, stringargs, plist):
        nloops = [1 for i in range(len(nverts))]
        self.m_ri.PointsGeneralPolygons(nloops, nverts, verts, plist)
        self.m_nsubdivs += 1

if len(sys.argv) == 3:
    infile = sys.argv[1]
    outfile = sys.argv[2]
    prman.Init(["-catrib", outfile, "-progress"])
    ri = prman.Ri()
    rif1 = myRif(ri)
    prman.RifInit([rif1])
    ri.Begin(ri.RENDER)
    prman.ParseFile(infile)
    ri.End()
    print ("Converted %d subdivs to polys from %s into %s" % (rif1.m_nsubdivs, infile, outfile))
else:
    print ("usage: %s infile.rib outfile.rib" % sys.argv[0])

2011년 8월 18일 목요일

PointCloud Bake

bake3d에서 P, N의 값과 texture3d에서 P, N의 값이 같아야한다.

Deform되는 mesh라고 하더라도....

2011년 7월 9일 토요일

varying Normal vs facevarying Normal

varying Normal
: per vertex normal in polymesh

facevarying Normal
: per vertex normal in polyface

varying normal의 경우 normal soften edge, harden edge 를 표현할수 없다.
interpolation에 의해 항상 soft하게 랜더된다.

2011년 7월 2일 토요일

Field of View

def fov(filmaperture, focallength):
    rad_fov = 2.8 * math.atan((filmaperture*25.4) / (focallength*2.0))
    return math.degrees(rad_fov)

filmaperture는 screenwindow를 어떻게 설정하느냐에 따라
horizontal 또는 vertical 값을 사용한다.

2011년 6월 14일 화요일

Slim Tcl Expression for color, vector, point


Color and Point Functions
rgb(r,g,b), rgbi(ir,ig,ib)
Allow the specification of color (vector) parameters. r,g,b in the range [0,1], ir,ig,ib in the range [0,255].

hsv(h,s,v), hsvi(ih,is,iv)
Allow the specification of color (vector) parameters in the HSV color space. h,s,v in the range [0,1], ih,is,iv in the range [0,255]. Note that this will immediately convert the hsv values to rgb values.

xyz(x,y,z)
Allow the specification of point (vector) parameters.

2011년 6월 9일 목요일

Slim co-shader attach Bug!


Add slim.ini
SetPref SlimAttachableMap(class) {surface coshader}

2011년 3월 6일 일요일

Slim.ini 설정팁 1

slim.ini파일에서
RMS_SCRIPT_PATHS를 환경변수로 가져올때 OS에 따라 설정이 다르다.

# 예제
set getenvpath [GetEnv RMS_SCRIPT_PATHS]
if {$pf(platform) == "windows"} {
set extpath [string map {"\\" "/"} $getenvpath]
} else {
set extpath $getenvpath
}

2010년 7월 13일 화요일

[RSL] Mathematical Functions 중에서.... v.1

float floor ( float x )
float ceil ( float x )
float round ( float x )

floor returns the largest integer (expressed as a float) not greater than x. ceil returns the smallest integer (expressed as a float) not smaller than x. round returns the integer closest to x.

integer값을 float 타입으로 반환받기 위한 방법이다.
floor : 내림, ceil : 올림, round : 반올림 으로 생각하면 간단할것 같다.

object index id를 aov로 출력할때 이 방법을 사용하였다.
ex.

output varying color objid[100] = {};

float index = 0;
attribute("identifier:id", index);
float color_array = floor(index / 3);
setcomp(objid[color_array], index - 3 * color_array, 1);

2010년 6월 6일 일요일

Motion Vector를 랜더해야할 경우...

Hider "hidden" "float samplemotion" 0
옵션을 붙여야한다.

2010년 5월 31일 월요일

Explicit Light Cache Control

illuminance("category", ..., "lightcache", "reuse") 이건 default set
illuminance("category", ..., "lightcache", "refresh")
이것때문에 상당한 삽질했다.

2010년 5월 25일 화요일

[RSL] string 만들기...

uniform float i = 0;
string ic;

ic = format("%d", i);
txfile = concat("filename", "_u", ic, ".tex");

이렇게하면 txfile = filename_u0.tex 가 된다.

2010년 5월 11일 화요일

Message Passing v.2(srf to lgt)

surface shader에서의 연산된 color 값을 light shader로 보내려고하는 목적은 bake light을 만들기위함이다.
해서 illuminance loop의 결과 값(diffuse)을 특정 light shader로 보내야한다.

앞에서 언급한바에 의하면 illuminance loop이전에 extern value를 설정하여야 한다.
이를 해결하기위해 light category를 이용하기로 한다.

2010년 5월 9일 일요일

Message Passing v.1(srf to lgt)

Message Passing을 충분히 이해했다고 생각했는데, 상당히 부족한 수준인것 같다.
최근 문제가 생긴부분이 Surface Shader의 특정 color 값을 Light Shader로 보내는 부분이다. 이해도가 떨어지다보니 글을 쓰기도 힘들다.

surface shader :
    output varying color __mycolor = 0;

light shader:
    color mycolor = 0;
    surface("__mycolor", mycolor);

이런식을 기본적으로 생각했었는데, 몇일전 사무실에서 시도하다 실패했다.
color 값이 light shader로 넘어가지 않았다.

여러가지 방법을 시도해본 결과,
surface shader 에서의 illuminance loop과 light shade 에서의 illuminate, solar 등에 대한 이해부족으로 인한 당연한 결과가 아닌가싶다.
참고로 illuminance loop이 돌기전 extern value를 설정하면 아무런 문제가 되지 않는다.

ex. 1
surface
base_srf(
float Kd = 1;
color lgtcolor = color(1);
output varying color __surfcolor = 0;)
{
normal Nn = normalize(N);
vector Nf = faceforward(Nn, I);

__surfcolor = lgtcolor;

color df = diffuse(Nf);

Ci = df;
}


light
base_lgt(
float intensity = 1;)
{
color lgtcolor = 1;
surface("__surfcolor", lgtcolor);
printf("%f, %f, %f\n", lgtcolor[0], lgtcolor[1], lgtcolor[2]);

point from = point "shader" (0,0,0);
vector dir = (0,0,1);

illuminate(from, dir, PI/2) {
Cl = intensity * lgtcolor;
}
}


위에서 언급했던 방법으로 간단하게 shader를 만들었다.

ex. 2
surface
base_srf(
float Kd = 1;
color lgtcolor = color(1);)
{
normal Nn = normalize(N);
color df = 0;

illuminance(P, Nn, PI/2, "send:light:__surfcolor", lgtcolor)
{
float k = Nn.normalize(L);
df += k * Cl;
}
Ci = df;
}


light
base_lgt(
float intensity = 1;
output varying color __surfcolor = 0;)
{
point from = point "shader" (0,0,0);
vector dir = (0,0,1);

illuminate(from, dir, PI/2) {
Cl = intensity * __surfcolor;
}
}


결과는 위의 방법과 같으나 이와 같은 방법으로도 message passing이 가능하다.
RMS 1.0에서는이와 같은 방법을 사용하고 있다.

2010년 5월 4일 화요일

RSL Information Function - option

float option( string name; output type variable )
Table 15.5 Data names known to the option function

















NameType Description
"Format"uniform float[3]The resolution (x, y) and pixel aspect ratio.
"DeviceResolution"uniform float[3] The resolution (x, y) and pixel aspect ratio.  These are usually the three numbers passed to RiFormat, but may be different when RiFrameAspectRatioor RiScreenWindow are non-square.
"FrameAspectRatio"uniform floatFrame aspect ratio.
"CropWindow"uniform float[4]Boundaries of the crop window.
"DepthOfField"uniform float[3]fstop, focallength, focaldistance.
"Shutter"uniform float[2]Shutter open and close time.
"Hider"uniform stringThe name of the active hider.
"Clipping"uniform float[2]Near and far clip depths.

RSL Information Function - attribute

float attribute( string name, output type variable )

Table 15.4 Data names known to the attribute function
   Name                                                    Type
"ShadingRate"uniform float
"Sides"uniform float
"matte"uniform float
"GeometricApproximation:motionfactor"uniform float
"displacementbound:sphere" *uniform float
"displacementbound:coordinatesystem" *uniform string
"identifier:name" *uniform string
* note that "displacementbound:sphere' does not return the value exactly as specified in the RIB file, but rather returns its length in the coordinate system returned by "displacementbound:coordinatesystem".


ex. 본인이 제일 많이 쓰는 스타일은...
string rayblur;
if (attribute("user:rayblur", rayblur) == 1) {
    ... ... ... ...
}

2009년 11월 27일 금요일

rman ctxGetObject

RMS에서 preshapemel를 만들때 object shapename을 찾아주는 명령

2009년 11월 20일 금요일

Conditional RenderMan PASS

`rman getvar PASSCLASS` == pass_class
`rman getvar PASSID` == pass_id

Linear Color WorkFlow


sample image

sRGB -> linear