Wings 3D Development Forum
Normal colors of "Face normal shader" - Printable Version

+- Wings 3D Development Forum (https://www.wings3d.com/forum)
+-- Forum: Wings 3D (https://www.wings3d.com/forum/forumdisplay.php?fid=1)
+--- Forum: Interface & Usage (https://www.wings3d.com/forum/forumdisplay.php?fid=3)
+--- Thread: Normal colors of "Face normal shader" (/showthread.php?tid=2190)

Pages: 1 2


RE: Normal colors of "Face normal shader" - micheus - 10-21-2016

ShaderFrog (http://shaderfrog.com/app/) is a nice place to play with shaders. They offer us an online editor with sinta checking and runtime preview.

I use to experiment the code on it and then adapt to work with Wings3d.
My two tests for this subject:
- Normalmap Color I
- Normalmap Color II
just click in the Source button to see the verteX shader and fragment shader code.


RE: Normal colors of "Face normal shader" - linkoboy - 10-23-2016

Hi,

I finally succeeded to have the same result like in this picture ("wish.png")

I'm still using Wings 3D v1.5.4. I put some objects, a torus a sphere and a cone on the [X-Z] ground. For me, the up axis is [Y].
Test scene : ("test_normal.wings")

I've taken the shaders : vextex_colors.vs and vertex_colors.fs and modified them just a little to have this result (see "result.png")

Here is the shaders :

Vertex Shader : vertex_color.vs
Code:
varying vec3 VertexColor;
uniform int  Flag;

void main()
{
    VertexColor = gl_Normal;
    gl_Position = gl_ProjectionMatrix * gl_ModelViewMatrix * gl_Vertex;
}

Fragment shader : vertex_color.fs
Code:
varying vec3 VertexColor;

void main()
{
    bool flipX = false;
    bool flipZ = true;
    
    vec4 color = vec4((1.0 + VertexColor) / 2.0, 1.0);
    
    gl_FragColor.r = flipX ? 1.0 - color.r : color.r;
    gl_FragColor.g = flipZ ? 1.0 - color.b : color.b;
    gl_FragColor.b = color.g;
}

If you want flip the colors in X or Z axis, you can just trick the boolean to have the desired result.

I'll share that into the Auto UV shaders forum too.

Regards,


RE: Normal colors of "Face normal shader" - micheus - 10-23-2016

Thanks for sharing it linkoboy.
I've tried to achieve this effect correctly before, but no success. It can be useful for extract normal map of almost flat objects like sci panels, relief and similar.Smile


RE: Normal colors of "Face normal shader" - micheus - 10-24-2016

Here a test I did capturing the screenshot from the top view (in Orthographic mode) of a smoothed model (not so hi-poly) and applied to an simple block:
[Image: panel-sample_zps9xsqw1zc.png]

If I had been able to port it to AutoUV shaders it would be easier to "extract a map" from a high-poly just by unwrapping it from the top view (I believe). Sad


RE: Normal colors of "Face normal shader" - 3DGeek46 - 11-01-2016

I couldn't fully understand, how you made those changingsSad Is it possible to record a video?