Volumetric Flare Shader

Hello!

A simple flare inside a volumetric domain:


float rand(int seed, float ray) {
    return mod(sin(float(seed)*
                263.5346+ray*374.2454)
                    *3743.4365, 1.0);
}
shader Flare01(
    float Size = -1.9,
    float Angle = 0.9,
    float Fact = 0.9,
    output closure color CL = holdout()
){
    float pi = M_PI;
    vector position = P*1.9;
    float ang = atan2(dot(position[0],position[1])*log(length(P)),dot(position[1],position[2])*log(length(P)));
    float dist = length(position);
    vector rgb = vector(0.5, 0.4, 0.35) * 
                    (pow(dist, Size) * 0.03);
    for (float ray = 0.0; ray < 2.0; ray += 0.085) {
        float rayang = rand(100, ray)*15.2+(1.0*0.03)*3.0*
            (rand(1546, ray)-rand(1785, ray))-
                (rand(3545, ray)-rand(6167, ray)) -
                cos(ray/M_PI)*Angle*sin(M_PI/ray);
        rayang = mod(rayang, pi*2.0);
        if (rayang < ang - pi) {rayang += pi*2.0;}
        if (rayang > ang + pi) {rayang -= pi*2.0;}
        float brite = .28 - abs(ang - rayang);
        brite -= dist * 0.12;
        if (brite > 0.0) {
            rgb += vector(0.3+0.4*
                rand(1644, ray), 0.45+0.4*
                    rand(1567, ray), 0.3+0.4*
                        rand(7354, ray)) * 
                            brite * 0.92 * noise(ray) ;
                               
        }
    } 
    CL =  emission()*pow(color(rgb)*Fact,1.1);   
    return;
}

And an example:


Have fun!

Can you post a screenshot of a node tree and world settings? I can’t get anything other than a white background.

Sure!

Here are some screens of my current code and settings:



The important bit is to place your domain exactly on the center of the world since it depends on the P global variable for placement!

Don’t work in my pc. What is the material setting?

Hello xaedro!

The screenshots on top of your post pretty much sum the whole thing! Now, it may still not work, almost anything that i post it’s very brain stormy, very experimental so it might not be compatible or stable for everyone!