Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
A new release
06-19-2014, 08:11 AM
Post: #41
RE: A new release
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
Reply
06-19-2014, 06:09 PM
Post: #42
RE: A new release
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..
Reply
06-20-2014, 02:06 AM
Post: #43
RE: A new release
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.
Reply
06-21-2014, 02:06 AM
Post: #44
RE: A new release
@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)
Reply
06-23-2014, 05:07 AM (This post was last modified: 06-23-2014 05:08 AM by rattle.)
Post: #45
RE: A new release


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.
Reply
06-26-2014, 04:17 PM
Post: #46
RE: A new release
That looks really neat!
Reply
07-30-2014, 12:08 AM
Post: #47
RE: A new release
I have learned a lot from there information !!
Reply
01-30-2015, 05:48 AM
Post: #48
RE: A new release
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
Reply
01-31-2015, 09:23 PM
Post: #49
RE: A new release
very nice
Reply
08-06-2015, 05:32 PM
Post: #50
RE: A new release
undefined
Reply


Forum Jump:


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