Jump to content

heat, temperature -> which one for blackbody?


Recommended Posts

hi,

i am using pyro H17.5 to sim explosion, and guerilla render engine for rendering. my question: the render engine uses blackbody model for volumetrics, however, pyro heat and temperature fields look similiar and could be used for blackbody emission, so any idea if there is a preferred one? I still need to test, but wanted to get some initial thoughts :)

Thx

Link to comment
Share on other sites

//blackbody
v@temp = blackbody(chf("Temperature"),chf("Intensity"));

//CIE XYZ to sRGB (no white balance)
3@mat3 = { {3.24096994, -1.53738318, -0.49861076}, 
{-0.96924364, 1.7859675, 0.04155506}, 
{0.05563008, -0.20397696, 1.05697151} };

//Multiply Matrix
float red = (@temp.x * getcomp(@mat3,0,0)) + (@temp.y * getcomp(@mat3,0,1)) + (@temp.z * getcomp(@mat3,0,2));
float green = (@temp.x * getcomp(@mat3,1,0)) + (@temp.y * getcomp(@mat3,1,1)) + (@temp.z * getcomp(@mat3,1,2));
float blue = (@temp.x * getcomp(@mat3,2,0)) + (@temp.y * getcomp(@mat3,2,1)) + (@temp.z * getcomp(@mat3,2,2));

//set Color
@Cd = set(red,green,blue);
//Blackbody
float Temp = chf("Temperature");
float TempInt = chf("Intensity");

float tempX = 0;
float tempY = 0;
float tempZ = 0;

//x
if (Temp >= 1667 && Temp < 4000) {
    float xa = -0.2661239 * pow(10,9) / pow(Temp,3);
    float xb = -0.2343589 * pow(10,6) / pow(Temp,2);
    float xc = 0.8776956 * pow(10,3) / Temp;
    
    tempX = (xa + xb + xc) + 0.179910;
    
}else if (Temp >= 4000 && Temp <= 25000) {
    float xa = -3.0258469 * pow(10,9) / pow(Temp,3);
    float xb = 2.1070379 * pow(10,6) / pow(Temp,2);
    float xc = 0.2226347 * pow(10,3) / Temp;
    
    tempX = (xa + xb + xc) + 0.240390;
};

//y
if (Temp >= 1667 && Temp < 2222) {
    float ya = -1.1063814 * pow(tempX,3);
    float yb = -1.3481102 * pow(tempX,2);
    float yc = 2.18555823 * tempX;
    
    tempY = (ya + yb + yc) -0.20219683;
    
}else if (Temp >= 2222 && Temp < 4000) {
    float ya = -0.9549476 * pow(tempX,3);
    float yb = -1.3481102 * pow(tempX,2);
    float yc = 2.09137015 * tempX;
    
    tempY = (ya + yb + yc) -0.16748867;
    
}else if (Temp >= 4000 && Temp <= 25000) {
    float ya = 3.0817580 * pow(tempX,3);
    float yb = -5.8733867 * pow(tempX,2);
    float yc = 3.75112997 * tempX;
    
    tempY = (ya + yb + yc) -0.37001483;
};

float tempXn = (TempInt / tempY) * tempX;
float tempYn = (TempInt / tempY) * (1 - tempX - tempY);

v@Cd = set(tempXn,TempInt,tempYn);
//white point
float wpnX = chf("wpx") / chf("wpy");
float wpnY = chf("wpy") / chf("wpy");
float wpnZ = chf("wpz") / chf("wpy");
vector wpn = set(wpnX,wpnY,wpnZ);

//sort
vector mX = set(chf("priRx"), chf("priGx"), chf("priBx"));
vector mY = set(chf("priRy"), chf("priGy"), chf("priBy"));
vector mZ = set(chf("priRz"), chf("priGz"), chf("priBz"));

//matrix
matrix3 m = set(mX,mY,mZ);
matrix3 mI = invert(m);
matrix3 mW = set(wpnX,wpnX,wpnX, wpnY,wpnY,wpnY, wpnZ,wpnZ, wpnZ);
matrix3 mW2 = mI * mW;

//
vector vecX = set(getcomp(mW2,0,0), 0,0);
vector vecY = set(0, getcomp(mW2,1,1) ,0);
vector vecZ = set(0 ,0 ,getcomp(mW2,2,2));

matrix3 mVec = set(vecX,vecY,vecZ);
3@rgb2xyz = m * mVec;
3@rgb2xyz = invert(@rgb2xyz);


//Color Matrix
float red = (@Cd.r * getcomp(@rgb2xyz,0,0)) + (@Cd.g * getcomp(@rgb2xyz,0,1)) + (@Cd.b * getcomp(@rgb2xyz,0,2));
float green = (@Cd.r * getcomp(@rgb2xyz,1,0)) + (@Cd.g * getcomp(@rgb2xyz,1,1)) + (@Cd.b * getcomp(@rgb2xyz,1,2));
float blue = (@Cd.r * getcomp(@rgb2xyz,2,0)) + (@Cd.g * getcomp(@rgb2xyz,2,1)) + (@Cd.b * getcomp(@rgb2xyz,2,2));

@Cd = set(red,green,blue);
//blackbody
v@temp = blackbody(chf("Temperature"),chf("Intensity"));

//set Color
v@Cd = xyztorgb(@temp);

 

  • Like 1
Link to comment
Share on other sites

Thanks Tesan :) 

What is the difference between using vex blackbody function and your code above (e.g. would not blackbody vex function be enough?) Also: Is there any use for "heat" field coming from pyro?

Tx again for your help :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...