trying to perfect a pixel shader effect

Started by
8 comments, last by yckx 13 years, 9 months ago
I'm messing around with shaders, pretty much for the first time. I have a visual effect in my head, but I don't know if how possible it is to implement, and I've reached the limit of my experimentation, documentation reading and google-fu for the night, so I thought I'd post to see if other people had any ideas.

Observe this torus:

See that nice bright shine/glow oriented toward the camera?

Now observe it from an angle:

The brightness only works when the torus surface is orthogonal to the view. Which is what I expect with the approach I've taken, but it's not what I want. I want something akin to a neon tube effect, so that the color gradient remains the same regardless of the view angle of the torus. (I hope I've explained what I'd like to achieve well enough--it's past 3am local ;) )

Ultimately I'd like to apply this effect to pipes with arbitrary bends, which I'm generating from a line strip fed through a geometry shader. I'm using HLSL/Direct3D 10, but I figure this is more of a theory question.

Thanks for any help you can give.

Advertisement
The fact that the first picture looks somewhat like a neon glow is just a byproduct of the lighting approximation function.

For "real" glow, you could try some post-processing bloom. First, render a thinner torus with bright colors to a render target texture. Then, blur it and combine it additively with the non-blurred image.

The following image is a mockup of the process made with Photoshop, but it is relatively easy to get the same results by using a pixel shader made for the purpose.



It is possible to tweak the results greatly by, for example, setting a brightness treshold for the blurred image or scaling the blur's result values to simulate more scattered light transfer and/or brighter source light. This all depends on the artistic effect that you want to achieve.

Niko Suni

Quote:
I want something akin to a neon tube effect, so that the color gradient remains the same regardless of the view angle of the torus.

Try a inverse fresnel-like term and add a fake light:
float fresnel_like = 1-dot(normal,view);fresnel_like *= fresnel_like;fresnel_like *= fresnel_like;vec3 fake_light = light_color * (1.0-fresnel_like);color = ... + fake_light;
Quote:Original post by Nik02
The fact that the first picture looks somewhat like a neon glow is just a byproduct of the lighting approximation function.


I understand that. But it's not the neon glow I'm looking for--it's the neon tube. I'm currently experimenting with volumetric lines, but I'm unsure how well it will look at the bends.

Quote:Original post by Ashaman73
Try a inverse fresnel-like term and add a fake light

I've seen the term fresnel term, but I didn't realize what it meant. I'm doing just that in the above screenshots, basing the color on dot(normal, view). But, as you see, it only when the pipe is orthogonal to the view vector.

Thanks for the replies.
Quote:Original post by yckx
so that the color gradient remains the same regardless of the view angle of the torus.
Can you just replace the view-angle variable with a constant?
It looks like this method of volumetric lines is what I've been looking for. Specifically, method B, with a suitable gradient texture. I still need to modify the technique so that line strips won't additively blend at the interstitial vertices, but hopefully that won't be too difficult.
So you want dp3 lighting constant and particularly specular :
Maybe it's not what you want because it is really simple , but why don't take your Normal in object space and consider that your view vector is constantly looking downward to your torus ?

ie V ( 0,-1,0) in object space hardcoded in the shader.
One possible approach to this that is similar in a way to the link a couple posts above is to take your torus and render a depth map from the cameras point of view with the cull-mode reversed so you're rendering the back faces. Then you can render it normally, getting the depth of the front face, subtracting it from the depth of the backface and using that thickness to adjust the glow or alpha value of the output.

I did something similar for a water shader recently and it worked quite well. As soon as the object starts overlapping itself though it can lead to some trouble when using it for the alpha value as you won't be able to get the depth of the piece of the object behind the piece in front. If you just use it for the glow value then that's not a problem though.
Portfolio & Blog:http://scgamedev.tumblr.com/
Hi guys, although i'm not massively knowledgeable about shaders i think i know what you want.

The neon glow in a tube, possibly with some neon glow leaking out as well.

What about having 2 meshes, 1 big and one smaller that fits inside the bigger one.

you do the neon glow like that shown above in a previous post for the smaller mesh.

Then with the bigger mesh have a texture with an alpha channel so it looks like a neon light in a tube.

I presume that you would have to render the inner ring before the outer, but i think it should give you the desired effect.

Hope that helped.

PureBlackSin
For Games, Articles and Custom High End Computers, come visit.Myndoko
Thanks for all the responses. I'd have taken a good look at them today, but I spent all afternoon at the medical center to find out I have an arthritic sternum(!), which ate up all my free time tonight. I'll read the responses tomorrow and possibly provide an update.

Now I'm off to bed.

This topic is closed to new replies.

Advertisement