Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 
Share Thread:
Reddit Facebook Twitter
AutoUV shaders [updated: 05/13/2020]
10-23-2016, 11:23 AM (This post was last modified: 10-23-2016 02:04 PM by linkoboy.)
Post: #42
RE: AutoUV shaders [updated: 10/29/2015]
Hi everybody,

If you are interesting to have a shader that show normal like in this picture :



I'll share to you this two files that I've modified from wings 3d 1.5.4 :
vertex_color.vs and vertex_color.fs.

I put some objects, a torus a sphere and a cone on the [X-Z] ground.
Link to the test scene : test_norlmal.wings

For me, the up axis is [Y]. I'm still using Wings 3D v1.5.4.

I've taken this shaders : vextex_colors.vs and vertex_colors.fs and just modified a little to have this result (see attached 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.

Best regards


Attached File(s) Thumbnail(s)
   

.fs  vertex_color.fs (Size: 394 bytes / Downloads: 3)
.vs  vertex_color.vs (Size: 226 bytes / Downloads: 3)
.wings  test_normal.wings (Size: 46.59 KB / Downloads: 4)
Reply


Messages In This Thread
RE: AutoUV shaders - tkbd - 10-25-2015, 02:18 AM
RE: AutoUV shaders - micheus - 10-25-2015, 01:14 PM
RE: AutoUV shaders - dgud - 10-26-2015, 10:43 AM
RE: AutoUV shaders - micheus - 10-26-2015, 03:47 PM
RE: AutoUV shaders - dgud - 10-26-2015, 06:59 PM
RE: AutoUV shaders - tkbd - 10-27-2015, 12:59 PM
RE: AutoUV shaders - Nova - 10-27-2015, 09:21 PM
RE: AutoUV shaders - micheus - 10-28-2015, 12:46 AM
RE: AutoUV shaders [updated: 10/29/2015] - linkoboy - 10-23-2016 11:23 AM
New texture shader: Image Mixer - micheus - 05-13-2020, 10:31 PM

Forum Jump:


User(s) browsing this thread: 1 Guest(s)