• Website
  • Search
  • Member List
  • Help
  • Old Forum
  • Social Media
    •   @Wings3dOfficial
    •   @Wings3dOfficial
    •   Wings3dOfficial
    •   Wings3dOfficial
  • Register
  • Login
  • Website
  • Search
  • Member List
  • Help
  • Old Forum
  • Register
  • Login
Wings 3D Development Forum Wings 3D Design & Development v
« Previous 1 4 5 6 7 8 … 11 Next »
A new release

 
  • 1 Vote(s) - 5 Average
A new release

Pages (6): « Previous 1 2 3 4 5 6 Next »
rattle
Offline

Junior Member

Posts: 5
Threads: 1
Joined: Jun 2014
#41
06-18-2014, 10:11 PM
I figured that much after porting the shader to be GLSL 4.2+ compliant to remap the texture units using the layout keyword. I've found the diffuse, normal and environment map.

I have some understanding of coding.. maybe I'll take a look when I've got some spare time.

Would be neat to have a realtime preview in Wings too Wink
dgud
Offline

Grumpy Dev
Posts: 692
Threads: 37
Joined: Nov 2012
#42
06-19-2014, 08:09 AM
I would prefer if you modified the default shader, which I used for bump maps.

The current way the shaders work are an ugly hack and should be rewritten, sigh..

But in the mean time I would like a "uber shader" that handles everything possible,
like I did with normal maps. But I GLSL 4.2+ is a little high for our users...
more like GLSL 1.0 :-(

But maybe we should change that..
Nova
Offline

Member

Posts: 164
Threads: 22
Joined: Nov 2012
#43
06-19-2014, 04:06 PM
Would porting it to 4.2+ make wings require 4.2 compliant hardware across the board? or only for using "advanced" shader features?

4.2 is almost 3 years old, and while many probably still have hardware older than that, it'll only decrease over time.
Arg Arg
Offline

Member

Posts: 54
Threads: 11
Joined: Dec 2013
#44
06-20-2014, 04:06 PM
@Nova
when you choose HELP / OpenGL Info
...you can see it is possible to check what the user is using.
...another option is to let the user choose what is supported from the hardware

so, it is possible to program a support for some target hardware at the same time (support for old and new)
rattle
Offline

Junior Member

Posts: 5
Threads: 1
Joined: Jun 2014
#45
06-22-2014, 07:07 PM (This post was last modified: 06-22-2014, 07:08 PM by rattle.)
[Image: f8MV5c.png]

hemilight.vs
Code:
// $Id$
//
// Vertex shader for hemispherical lighting
//
// Author: Randi Rost
//
// Copyright (C) 2005 3Dlabs, Inc.
//
// See 3Dlabs-License.txt for license information
//
// modified by rattle 2014-06-22

const int LIGHT_COUNT = 2;
attribute vec4 wings_tangent;

varying vec3 normal;
varying vec3 lightVec[LIGHT_COUNT];
varying vec3 eyeVec;
varying vec4 color;
varying vec4 tangent;

void main(void)
{
    vec3 viewPos = vec3(gl_ModelViewMatrix * gl_Vertex);
    eyeVec = normalize(-viewPos);
    for (int i = 0; i < LIGHT_COUNT; ++i) {
        lightVec[i] = normalize(gl_LightSource[i].position.xyz - viewPos);
    }
    color    = gl_FrontMaterial.diffuse * gl_Color;
    normal    = gl_NormalMatrix * gl_Normal;
    tangent.xyz = gl_NormalMatrix * wings_tangent.xyz;
    tangent.w = wings_tangent.w;
    gl_TexCoord[0]    = gl_MultiTexCoord0;
#ifdef __GLSL_CG_DATA_TYPES // Fix clipping for Nvidia and ATI
    gl_ClipVertex   = gl_ModelViewMatrix * gl_Vertex;
#endif
    gl_Position     = ftransform();
}

hemilight.fs
Code:
// $Id$
//
// Fragment shader for hemispherical lighting
//
// Author: Dan Gudmundsson
//
// modified by rattle 2014-06-22

const int LIGHT_COUNT = 2;

uniform int UseDiffuseMap;
uniform int UseNormalMap;

uniform sampler2D DiffuseMap;
uniform sampler2D NormalMap;

varying vec3 normal;
varying vec3 lightVec[LIGHT_COUNT];
varying vec3 eyeVec;
varying vec4 color;
varying vec4 tangent;

vec3 get_normal(vec3 T, vec3 N, float W, sampler2D M, vec2 C) {
    N = normalize(N);
    T = normalize(T);
    T = normalize(T - dot(T, N) * N);
    vec3 B = cross(T, N) * W;
    mat3 TBN = mat3(T, B, N);
    return normalize(TBN * (2.0 * texture2D(M, C).xyz - 1.0));
}

void main(void)
{
    vec3 N = UseNormalMap>0?get_normal(tangent.xyz, normal, tangent.w, NormalMap, gl_TexCoord[0].xy):normalize(normal);
    vec4 diffuseColor = UseDiffuseMap>0?texture2D(DiffuseMap, gl_TexCoord[0].xy):color;
    vec4 diffuse, specular;
    
    for (int i = 0; i < LIGHT_COUNT; ++i) {
        gl_LightSource[i].diffuse = vec4(1.0);
        gl_LightSource[i].ambient = vec4(1.0);
        gl_LightSource[i].specular = vec4(1.0);

        vec3 E = eyeVec;
        vec3 L = lightVec[i];
        float NdotL = dot(N, L);
        if (NdotL > 0.0) {
            vec3 R = normalize(reflect(-L, N));
            diffuse += gl_FrontLightProduct[i].diffuse * NdotL;
            specular += gl_FrontLightProduct[i].specular * pow(max(dot(R, E), 0.0), clamp(gl_FrontMaterial.shininess, 1.0, 128.0));
        }
    }
    gl_FragColor = gl_FrontLightModelProduct.sceneColor + diffuseColor * diffuse + specular;
}

Okay, I've changed your shader so it takes specularity into account, which can be controlled by the shininess material property and spec color.

In the fragment shader change LIGHT_COUNT to 1 or 2, it uses either one or two hardcoded lights. Somehow gl_FrontLightProduct[].ambient always appears as black... gl_FrontLightModelProduct.sceneColor has the ambient/emissive color in it though, so it should be fine as viewport shader.
Nova
Offline

Member

Posts: 164
Threads: 22
Joined: Nov 2012
#46
06-26-2014, 06:17 AM
That looks really neat!
Epowerplus13
Offline

Junior Member

Posts: 1
Threads: 0
Joined: Jul 2014
#47
07-29-2014, 02:08 PM
I have learned a lot from there information !!
joysonriad
Offline

Junior Member

Posts: 1
Threads: 0
Joined: Jan 2015
#48
01-29-2015, 07:48 PM
That's really looking great.
I think this is one of the most significant ways for me to learn wings3d. And I’m satisfied to be a member of this site. However I want to remark on some basic things. This website is really wonderful.

Take a look on my site Kino3
royal52
Offline

Junior Member

Posts: 1
Threads: 0
Joined: Jan 2015
#49
01-31-2015, 11:23 AM
very nice
imbrecostel
Offline

Junior Member

Posts: 1
Threads: 0
Joined: Aug 2015
#50
08-06-2015, 07:32 AM
undefined
« Next Oldest | Next Newest »

Users browsing this thread: 1 Guest(s)

Pages (6): « Previous 1 2 3 4 5 6 Next »


  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Designed by D&D - Powered by MyBB

Linear Mode
Threaded Mode