Jump to content

Light Emission in PBR VEX Shader


goldleaf

Recommended Posts

post-3767-133425017588_thumb.png

I've been trying my hand at writing VEX shaders by hand, and I can't get emission to work in my shader. I've read in a couple of threads here on odForce to put a value in Ce, but I'm getting an undefined variable error, saying Ce doesn't exist. Is it not a global variable, like F or Cf?

#pragma opname test_1
#pragma oplabel "crydalch bsdf tests"
#pragma opmininputs 0
#pragma opmaxinputs 0
#pragma label   diff    "Diffuse Color"
#pragma hint    diff    color
#pragma label   diff2   "Other Diffuse"
#pragma hint    diff2   color


#include <voptype.h>
#include <voplib.h>

#include <voptype.h>
#include <voplib.h>

surface
test_1( vector diff = { 1, 1, 1 }, diff2 = { 1, 0, 0 };
        float bi = 0.5, rgh = 1, atte = 1;
        int tur = 1)
{
    bsdf f;
    bsdf f1;
    bsdf tmp;
    bsdf illum;
    float noiseAmnt;
    vector transformedP;

    // You need to transform P into object space, to pick up transformations
    transformedP = ptransform("space:object", P);

    noiseAmnt = snoise(transformedP,tur,rgh,atte);

    f = 1 * lerp(diff,diff2,noiseAmnt) * bsdf(diffuse(N));
    //f = 0.5 * diff * bsdf(diffuse(N));
    f1 = 0.05 * bsdf(specular(N));
    illum = emission_bsdf(f * 2);

    tmp = f + f1;

    Cf = diff;
    Ce = illum;
    F = tmp;
}

Obviously, I'm not understanding how emission works in the shader, so any advice would be greatly appreciated. Thank you!

Thanks!

Edited by goldleaf
Link to comment
Share on other sites

test_1( vector diff = { 1, 1, 1 }, diff2 = { 1, 0, 0 };
        float bi = 0.5, rgh = 1, atte = 1;
        int tur = 1; export vector Ce={0,0,0})
(...)

Hey goldleaf,

you just need to declare it as an export variable.

Cheers!

skk.

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...