Shaders

Questions about the content creation procedure go here, including using Forge, Anvil, or other editors, or operating emulators like Basilisk II.

Post Feb 21st '11, 05:03

DADDY Z3RO wrote:Should does not mean will.

AND never boldface my own words for self-emphasis again.


You've really got to put yourself in perspective.

Nobody here is really any different, in any practical sense, but you're pissing everyone off.

Think about it, it's not just because they're assholes, or even if they are to whatever extent, that's non-relevant to the causation of your issue.

You also didn't do anything for MPDX in the last 11 days. Disappointing, to say the least, after all of your talk. That simply won't do, so you're not on the Dropbox anymore. It's nothing personal, since I don't blame you for your lack of sense, but your motives weren't quite so good to begin with.

No merit or shame shall come to you save for that which stems from your own actions. When you say 'fair', that's the best anyone could ever hope for, and you're lucky if you live in a world where such is true. Figure yourself out, and don't cause trouble for other people.
Image
Kurinn

Post Feb 22nd '11, 07:02

Okay, I've got it working now. Apparently bump mapping was the culprit (it seems to work fine with bloom).

I munged together treellama's code with the default shaders, which served as a decent do-it-yourself introduction to how some of this works. These shaders add the point light in the middle of King of Pain on top of the game's regular lighting, instead of replacing it. I'm posting this in hopes of saving other experimenters some times, since they'd probably want to do it themselves anyway.

wall.frag:
Code: Select all
uniform sampler2D texture0;
uniform float wobble;
uniform float glow;
uniform float flare;
varying vec3 viewXY;
varying vec3 viewDir;
varying vec4 vertexColor;
varying float FDxLOG2E;
varying float MLxLOG2E;

varying vec3 normal, direction;
varying float distance;

void main (void) {
    // point light contribution
    // point light diffuse color
    vec4 p1_diffuse = vec4(1.0, 1.0, 1.0, 0.0);
    // point light ambient color
    vec4 p1_ambient = vec4(0.1, 0.1, 0.1, 0.0);
    // global ambient color (unnecessary with default lighting intact)
    vec4 p1_color = vec4(0.0, 0.0, 0.0, 0.0);

    float constantFalloff = 0.2;
    float linearFalloff = 0.1;
    float quadraticFalloff = 0.05;

    vec3 n = normalize(normal);

    float NdotL = max(dot(n, normalize(direction)), 0.0);

    if (NdotL > 0.0) {
        float attenuation = 1.0 / (constantFalloff + linearFalloff * distance + quadraticFalloff * distance * distance);
        p1_color += attenuation * (p1_diffuse * NdotL + p1_ambient);
    }

    // default contribution
    vec3 texCoords = vec3(gl_TexCoord[0].xy, 0.0);
    texCoords += vec3(normalize(viewXY).yx * wobble, 0.0);
    float flash = exp2((flare - 1.0) * 2.0);
    float mlFactor = exp2(MLxLOG2E * dot(viewDir, viewDir) / flash + 1.0);
    mlFactor = clamp(mlFactor, 0.0, flare - 0.5) * 0.5;
    vec3 viewv = normalize(viewDir);
    vec3 norm = vec3(0.0, 0.0, 1.0);
    float diffuse = 0.5 + abs(dot(norm, viewv))*0.5;
   if (glow > 0.001) {
       diffuse = 1.0;
   }
    vec4 color = texture2D(texture0, texCoords.xy);
    vec3 intensity = color.rgb * clamp((vertexColor.rgb + mlFactor) * diffuse, glow, 1.0);
    float fogFactor = clamp(exp2(FDxLOG2E * dot(viewDir, viewDir)), 0.0, 1.0);
    // combined result
    gl_FragColor = vec4(mix(gl_Fog.color.rgb, intensity, fogFactor), vertexColor.a * color.a) + p1_color * texture2D(texture0, gl_TexCoord[0].xy);
}


wall.vert:
Code: Select all
uniform float depth;
varying vec3 viewXY;
varying vec3 viewDir;
varying vec4 vertexColor;
varying float FDxLOG2E;
varying float MLxLOG2E;

varying vec3 normal, direction;
varying float distance;

void main(void) {
    // point light contribution
    // point light location in WU
    vec3 locationWorld = vec3(0.0, 0.0, 2.0) * 1024.0;

    vec4 locationEye = gl_ModelViewMatrix * vec4(locationWorld, 1.0);
    vec4 vertexEye = gl_ModelViewMatrix * gl_Vertex;
    vec3 segment = vec3(locationEye - vertexEye);

    direction = normalize(segment);
    distance = length(segment) / 1024.0;

    normal = normalize(gl_NormalMatrix * gl_Normal);

    // default contribution
    gl_Position  = gl_ModelViewProjectionMatrix * gl_Vertex;
    gl_Position.z = gl_Position.z + depth*gl_Position.z/65536.0;
    gl_ClipVertex = gl_ModelViewMatrix * gl_Vertex;
    gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
    /* SETUP TBN MATRIX in normal matrix coords, gl_MultiTexCoord1 = tangent vector */
    vec3 n = normalize(gl_NormalMatrix * gl_Normal);
    vec3 t = normalize(gl_NormalMatrix * gl_MultiTexCoord1.xyz);
    vec3 b = normalize(cross(n, t) * gl_MultiTexCoord1.w);
    /* (column wise) */
    mat3 tbnMatrix = mat3(t.x, b.x, n.x, t.y, b.y, n.y, t.z, b.z, n.z);
    
    /* SETUP VIEW DIRECTION in unprojected local coords */
    viewDir = tbnMatrix * (gl_ModelViewMatrix * gl_Vertex).xyz;
    viewXY = -(gl_TextureMatrix[0] * vec4(viewDir.xyz, 1.0)).xyz;
    viewDir = -viewDir;
    vertexColor = gl_Color;
    FDxLOG2E = -gl_Fog.density * gl_Fog.density * 1.442695;
    MLxLOG2E = -0.0000003 * 1.442695;
}

[edit] set global ambient to 0 since regular lighting is now intact (I thought I'd turned it off; thanks for catching it treellama)
Last edited by Crater Creator on Feb 22nd '11, 20:50, edited 1 time in total.
User avatar

Crater Creator

Post Feb 22nd '11, 13:56

Those combined shaders are using the old Default Shaders plugin, for 0.23.2. I'll post a new Default Shaders plugin for 1.0b1 when I have a chance.

You probably don't need global ambient when you're using the built-in lighting.
User avatar

treellama
Pittsburgh

Post Feb 22nd '11, 21:22

Kurinn wrote:You've really got to put yourself in perspective.

Nobody here is really any different, in any practical sense, but you're pissing everyone off.

Think about it, it's not just because they're assholes, or even if they are to whatever extent, that's non-relevant to the causation of your issue.

You also didn't do anything for MPDX in the last 11 days. Disappointing, to say the least, after all of your talk. That simply won't do, so you're not on the Dropbox anymore. It's nothing personal, since I don't blame you for your lack of sense, but your motives weren't quite so good to begin with.

No merit or shame shall come to you save for that which stems from your own actions. When you say 'fair', that's the best anyone could ever hope for, and you're lucky if you live in a world where such is true. Figure yourself out, and don't cause trouble for other people.


I feel like trash. You have all accomplished your personal goals, good day gentlemen.
"Escape will make me God"
User avatar

zero
Tau Ceti or bust!

Post Feb 22nd '11, 21:33

Treellama wrote:I'll post a new Default Shaders plugin for 1.0b1 when I have a chance.

Here it is: Default Shaders for 1.0b1
Aleph One:  Download 1.2.1         Plugins:  Vasara  ·  more
User avatar

Hopper

Post Feb 22nd '11, 21:38

Crater Creator wrote:Apparently bump mapping was the culprit

When bump mapping is on, the renderer uses "bump.frag" and "bump.vert" instead of "wall.frag" and "wall.vert". If you wanted to make this work regardless of the bump map setting, you'd have to update both pairs of shaders.
Aleph One:  Download 1.2.1         Plugins:  Vasara  ·  more
User avatar

Hopper

Post Feb 23rd '11, 00:32

DADDY Z3RO wrote:I feel like trash. You have all accomplished your personal goals, good day gentlemen.

Too bad Fishman isn't still around, you guys could start a support group or something.
Last edited by Dis on Feb 23rd '11, 00:34, edited 1 time in total.
Image
function rate() { x = document.getElementsByClassName('current-rating'); for (var i in x) { x[i].style.cssText = "width: 25px"; x[i].innerHTML = "Currently 1/5 Stars."; } }

if (document.URL != "http://www.simplici7y.com/reviews") window.onload = rate;
Dis

Post Feb 23rd '11, 00:51

Dis wrote:Too bad Fishman isn't still around, you guys could start a support group or something.

hee hee hee.

I'm gonna stop before I end up being the new targetface.

i vow never to post in this thread again, in fact, act like i had no involvement. IN FACT, if $lave is seeing this, he ought to remove all of my posts and quoted posts in this thread to put it back on track.
"Escape will make me God"
User avatar

zero
Tau Ceti or bust!

Post Feb 23rd '11, 21:27

DADDY Z3RO wrote:act like i had no involvement.

DADDY Z3RO wrote:FACT

DADDY Z3RO wrote:back on track.


Find the right way down through the subcategories, to the posts, then find the reply. Push the reply button. If the post is awful, don't eat it, go back and try another way.

they want a path, just like you. but which one counts? Your post, their post, my post. Or are the posts all the same, defined by the limits of their shitty replies?
User avatar

Traverse

Post Feb 23rd '11, 22:06

Traverse wrote:Find the right way down through the subcategories, to the posts, then find the reply. Push the reply button. If the post is awful, don't eat it, go back and try another way.

they want a path, just like you. but which one counts? Your post, their post, my post. Or are the posts all the same, defined by the limits of their shitty replies?

is there treasure in the heart
how can we tell when it's time to go
international transglobal corporate scintillation
can sail a ship along the ivory coast

enjoy your coca-cola in my spine
golden hordes will always roam
trillions of chinese communists have no aim
the moon is the only place they know

skilled craftsmen in your books
even christ was a carpenter they say
your filthy methods need scrubbers in their stacks
preserving cats in tar each day

ultimate lessons abound in man
love your brother love your enemy
don't love yourself because no one loves you
depths spawn hate for free
underworld : simple fun netmaps // prahblum peack : simple rejected netmaps
azure dreams : simple horrible netmaps // v6.0!!!: thomas mann's greatest hits : simple simple netmaps
User avatar

irons
(.Y.)

Post Feb 23rd '11, 23:20

irons wrote:
preserving cats in tar each day


I prefer formaldehyde when preserving my Felis catus
User avatar

Traverse

Post Feb 24th '11, 01:42

Anyway, I see that you guys can make some interesting things with shaders!
"Escape will make me God"
User avatar

zero
Tau Ceti or bust!

Post Feb 24th '11, 06:32

DADDY Z3RO wrote:i vow never to post in this thread again

DADDY Z3RO wrote:Anyway, I see that you guys can make some interesting things with shaders!
User avatar

Ares Ex Machina

Post Feb 24th '11, 14:58

err.... starting now!
"Escape will make me God"
User avatar

zero
Tau Ceti or bust!

Post Feb 24th '11, 21:52

Traverse wrote:I prefer formaldehyde when preserving my Felis catus

OH GOD WHAT THE HELL IS THAT
User avatar

TectonInd

Post Jan 26th '20, 08:46

I Bump this topic I guess?
User avatar

Meerjel01

Previous

Return to Editors, Emulation, Etcetera



Who is online

Users browsing this forum: No registered users

cron