scorpion007-zz / pixie

A Pixie fork from SourceForge.net with aims to provide robustness and user experience improvements.
http://www.renderpixie.com/
GNU Lesser General Public License v2.1
18 stars 9 forks source link

Message To Scorpion007. #1

Open AtomicPerception opened 12 years ago

AtomicPerception commented 12 years ago

Sorry for using an issue as a message system, but I am quite surprised to find that I can not just send you a message, user to user, via github?

I have been working on a Blender to Pixie exporter and it can be found here: http://blenderartists.org/forum/showthread.php?251446-PIXIE-Using-3Delight-Exporter-with-Pixie-2.2.6

I have a few questions related to the generation of RIB tokens for Pixie and wondered if you were interested in corresponding.

Thank You,

Atom

scorpion007-zz commented 12 years ago

Added my email to my profile.

Sure, fire away your questions, though I can't promise I have the answers :)

AtomicPerception commented 12 years ago

Alex,

I can not seem to get shadow () or* transmission() *to produce a transparent or colored shadows. I am new at shader writing so maybe I am doing things wrong in the shader. As I try out the various examples they just don't seem to work. One thing I tried today that did work was the Raytrace Shadows example posted on the Pixie site. http://www.renderpixie.com/pixiewiki/Tutorials/Raytraced_shadows

The trick that this example leverages seems to be the inclusion of "Cs" along with the polygon definition. My Pixie exporter is not outputting this value. I'm not sure how to calculate the value either. Does Pixie need "Cs" in a Polygon definition to produce transparent shadows?

Do you have any examples or tips on how to get transparent/colored shadows to work?

Thanks

Atom

On Mon, Jun 25, 2012 at 3:35 PM, Alex Budovski < reply@reply.github.com

wrote:

Added my email to my profile.

Sure, fire away your questions, though I can't promise I have the answers :)


Reply to this email directly or view it on GitHub: https://github.com/scorpion007/pixie/issues/1#issuecomment-6557375

scorpion007-zz commented 12 years ago

Hi Atom,

The tutorial you linked uses Os, not Cs. Is that what you meant?

If you specify

Attribute "shade" "transmissionhitmode" "shader"

Then the surface shader will be evaluated to determine the opacity at the shading point for the purposes of the transmission() function.

Without this, only the opacity attribute (i.e. RiOpacity) is used to determine this, which is constant throughout the surface.

Does the Pixie example you linked make sense now?

AtomicPerception commented 12 years ago

Yes, that is what I meant. After I posted and re-read my post I realized I types Cs where I meant to type Os.

Basically I am looking for a working raytraced transparent shadow example for Pixie that does not use shadow maps.

AtomicPerception commented 12 years ago

Yes, that is what I meant. After I posted and re-read my post I realized I types Cs where I meant to type Os.

Basically I am looking for a working raytraced transparent shadow example for Pixie that does not use shadow maps.

So I have a point light shadow with an illuminate loop like this.

[code] illuminate (from) { float shadow_mask, shadow_opacity; color Cshad; float dist = length(L); shadow_mask = shadow("raytrace",Ps,"blur",shadow_blur_size,"samples",shadow_ray_sample); if (shadow_mask == 1) { // This point is in shadow so it is time to calulcate the // shadow opacity based upon the intensity of the shadow color. shadow_opacity = 1-intensity(shadow_color); shadow_opacity = 0.1; Cshad = shadow_color * shadow_opacity; Cl = Cshad * energy * light_color; } else { // No shadow at all. Cl = energy * light_color; }

}

[/code] I have read that shadow returns a 1 or a 0, essentially a boolean value. I want to use that boolean value to determine when I should mix in shadow color. No matter what I multiply shadow_color by, I always get a hard black shadow. I want a grey or green shadow, whatever color I would like. I also want the shadow to be more transparent the brighter the shadow color. So if I set my shadow color to white I would get no shadow at all. If I drop my shadow color to light grey, I would get a slight shadow but still be able to see through the shadow to the surface color that the shadow is falling upon.

Is there some other variable I am not aware of...? Like Oi for shadows or something...?

scorpion007-zz commented 12 years ago

I'm pretty sure shadow() can return a float between 0 and 1 when used with raytrace shadows, as per the Pixie wiki example. Look in shadowdistant.sl.

AtomicPerception commented 12 years ago

I guess there are two versions of shadow() one returns a float and the other returns a color. The one that returns the color does not take any shadow color into consideration. By using the float version of shadow I can factor in another color (e.e. the shadow color) based upon the intensity of the shadow.

This illuminate loop gets me fairly close to what I wanted. Fetch the shadow_strength as a float then mix light and shadow color together based upon a smoothstep.

illuminate (from) {
    color vis;
    float shadow_strength;
    float dist = length(L);
    shadow_strength =  (1 - shadow("raytrace",Ps,"blur",shadow_blur_size,"samples",shadow_ray_sample));
    vis = mix(shadow_color, light_color, smoothstep(0.1,1.0,shadow_strength));
    if (falloff_type == 2) {
        // Inverse Square.
        Cl = vis * energy * light_color * 1/pow(dist,2);
    } else {
        if (falloff_type == 1) {
            // Inverse Linear.
            Cl = vis * energy * light_color * 1/pow(dist,1);
        } else {
            // Constant.
            Cl = vis * energy * light_color;
        }
    }
}
scorpion007-zz commented 12 years ago

Why don't you use the color version of shadow()? It does what the float one does and more. It actually takes into account the color opacity of the surface and lets you get stained-glass effects.

AtomicPerception commented 12 years ago

I am not using the color version because it seems to offers no control over the color of the shadow? It assumes all shadows are black. The stained glass effect example posted on the Pixie website leverages the transmission () function.

I am new to shader writing so if you have a working spotlight or pointlight that would allow me to set a shadow color and make it stained glass without using any maps (i.e. raytrace only) I would love to see it. I am trying to avoid a second pass so I am using raytrace, exclusively, to generate shadows.

scorpion007-zz commented 12 years ago

If you look at the shadowdistant.sl shader, you'll see that it uses color shadow(), not transmission.

(This is the one used in the Pixie sample [1])

[1] http://www.renderpixie.com/pixiewiki/Tutorials/Raytraced_shadows

AtomicPerception commented 12 years ago

Alex,

Thanks for the link. That page is what made me think I could have colored shadows. I have typed that example in and my rendered results matched what is displayed on that page. But the colored shadows on that page are the result of varying the "Os" of the object. Which I do not want to do, my objects are solid.

I am basically trying to emulate Blender lighting using Pixie. If you are familiar with Blender you know you can make a pointlight/distantlight have a colored shadow. [image: Inline image 1]

This attached image shows what I am trying to achieve in Pixie. But using the standard light shaders that come with Pixie there is no option to set the shadow color.

So a custom shader is needed. That is what I am trying to develop. I am taking the approach of a raytrace only solution for this. So no shadow maps are ever generated.

On Thu, Jun 28, 2012 at 2:44 PM, Alex Budovski < reply@reply.github.com

wrote:

If you look at the shadowdistant.sl shader, you'll see that it uses color shadow(), not transmission.

(This is the one used in the Pixie sample [1])

[1] http://www.renderpixie.com/pixiewiki/Tutorials/Raytraced_shadows


Reply to this email directly or view it on GitHub: https://github.com/scorpion007/pixie/issues/1#issuecomment-6637884

scorpion007-zz commented 12 years ago

I think there is a bit of a misunderstanding:

I am not discouraging you from writing your own shader. I am merely explaining that your shader can use the color shadow() function as a basis of generating raytraced translucent shadows; i.e. stained glass.

The examples uses Os for simplicity: this simply assigns a colored opacity to each vertex. For more control, the surface shader can set Oi arbitrarily, and with Attribute "shade" "transmissionhitmode" "shader"

the shader will be evaluated instead of Os and used as a basis for your colored, transparent shadows.

At least, this is what should happen. Let me know if it doesn't work.