Jump to content
  • entries
    17
  • comments
    37
  • views
    9,092

About this blog

A Leadwerks 4 shader blog

Entries in this blog

Geometry

So we went through a lot of fragment shaders. Did some vertex displacement. Went through tessellation. Now, some geometry. I don't have much to say about it. Just keep poking at it with a proverbial stick and eventually situations start to look familiar and you know what to do because it's similar to stuff you've encountered before. It does seem to me that there's not a lot of variety in geometry shaders. There's a bit, though. Enough to make it interesting. But grab these shaders and you'll hav

havenphillip

havenphillip in Shaders

Cool Ice Effect

Here's a cool effect I don't know why I didn't think of this sooner. This shader uses parallax occlusion and a trick similar to that in the weeper (22a_weeper). The idea is that you can get a cheap refraction effect by multiplying the texture coordinates of the diffuse texture with the normals (naturally you'd have to establish the diffuse "outcolor" after you establish the normals). It looks something like this: float amplitude = 0.1; vec4 outcolor = texture(texture0,ex_texcoords0 + normal.x

havenphillip

havenphillip in Shaders

Extras 2

Here's some more extra shaders. I had a lot of fun with these. Some playing with normals. Some post-effects. Some experimental stuff. Just a mixed batch of noob adventures.   This first shader is pretty simple and is a nice noob move to add more detail to any scene. You start with the base shader and simply mix it with another normal texture. You can easily see the effect it produces and this is useful if you want to add small details to a material - like for instance making skin or ro

havenphillip

havenphillip in Shaders

Some Extras

Hello, fellow noobs. Hope you're doing well. I have a few extra shaders I had wanted to get out to you earlier but couldn't because they weren't complete or they were a bit off-track. I have some more extras I want to add but here's a few for now. I had wanted to do a multiple lights + alpha shader but it turned out to be a little trickier than I anticipated. I finally got it, though. Haven't tried this out in various situations but I doubt there will be any problem using this for what

havenphillip

havenphillip in Shaders

Ground Fog with Parallax

Since I started doing shaders I've begun to stare a lot at things. I stare at the ground. I stare at walls. I stare at rocks...and when autumn hit I started staring at fog...puddles....mud... This week I've been working on puddles and fog in keeping with that spooky October/November vibe. I worked out a pretty good mud puddle shader which I'll post next but I figured this one is done and I've tweaked the **** out of it so I need to stop at some point and know when it's done. This shader is made

havenphillip

havenphillip in Shaders

Outroduction

Ok so I didn't quite do one shader a week but I got to 52. I wasn't sure I could pull it off but hopefully the shaders are diverse enough to give something to work with for most occasions. I tried to keep the language consistent throughout and organize them sort of from easy to hard. I threw in all kinds of links because I don't know a lot of the technical terminology. I don't know how Ultra is going to be but I get the impression it's not going to be too much different. From what I understand,

havenphillip

havenphillip in Shaders

PBR

According to learnopengl.com PBR - or physically based rendering - is "...a collection of render techniques that are more or less based on the same underlying theory that more closely matches that of the physical world...[it] aims to mimic light in a physically plausible way...[and] generally looks more realistic compared to our original lighting algorithms like Phong an Blinn-Phong...PBR is still nonetheless an approximation of reality...which is why it's not called physical shading, but physic

havenphillip

havenphillip in Shaders

Tessellation

If you liked vertex displacement, you're going to love tessellation. Tessellation is very similar, but incorporates the control and evaluation stages of the shader. The Leadwerks box brush creates a box that has two triangles per face. If you want to use some kind of vertex displacement on it you're going to have a bad time. With tessellation it's different because you are able to subdivide the faces with the shader, so you can use the shader to create more structurally complex models. The contr

havenphillip

havenphillip in Shaders

Depth Buffer

Note: In my last post shaders 36 and 37 weren't working correctly so I replaced them. If you got the old ones you can throw those out and re-download the new ones on the same links. These shaders are based on the Leadwerks soft  particle shader, which I was directed to by Marcousik, and which I noobalyzed into a model shader. What the soft particle shader does is create a soft falloff in opacity depending on how close objects are behind it. To clarify, imagine looking down at a water plane,

havenphillip

havenphillip in Shaders

Vertex Displacement

Simplistically speaking, you could think of the vertex stage of a shader as the "position" of the object, and the fragment stage as the "color." All you really need is position and color. Vertex displacement manipulates the position to warp or move the object. There are many ways to do it but the whole trick revolves around the ex_vertexposition. You may notice in every model shader you have these two lines in the vertex stage:    ex_vertexposition = entitymatrix_ * vec4(vertex_position,1.0

havenphillip

havenphillip in Shaders

Simplex Noise

I don't deal with noise shaders that much but there are a lot of examples on Shadertoy. It has a lot of uses depending on what you want, but very often I see noise being used with raymarching to create 3D scenes. I prefer using textures because I can get what I want out of them and noise is a lot of math (noise shaders can get very large very quickly), but I figured a good shader series ought to have a noise function somewhere.   I got this noise from iq of Shadertoy fame. Just a nice

havenphillip

havenphillip in Shaders

Parallax

Parallax is a cheap way to add a lot of 3D details to any scene. The less vertices on a mesh the better, because parallax doesn't actually add any geometric information. And it requires only the bare minimum number of vertices to work. That makes it fast. And the effect is believable. All you really need is a heightmap and a dream... It's a lot of fun trying different textures with it, and if I could I'd use it for everything. However, there are a few limitations to parallax. The first prob

havenphillip

havenphillip in Shaders

Masks and Texture Blending

Masking is pretty easy and useful for adding some variety to your shaders. Masks are usually just some greyscale image that is turned into a float. In shaders floats have a very broad utility because you can add them just about anywhere. Super useful. And they can be used to blend textures or define areas in your material. Adding a mask in code is the same as with any texture. The greyscale quality allows you to use a single channel of that greyscale as a representative of all the channels.

havenphillip

havenphillip in Shaders

Creek

One of those things I wanted to make - and a big reason I think many people get involved in shaders - is water.  If you've been following along and grabbing these shaders you have now almost all the parts you need to make a basic water plane. If you understand these parts then you can manipulate them to customize your water as you see fit. I'm going to spend a little time in explanation here. In making this shader I start with the base shader and add a texture scroll effect on the normals (

havenphillip

havenphillip in Shaders

Skybox Reflections

Another simple shader technique is the skybox (or cubemap) reflection. Cubemaps are useful for creating quick and easy reflective surfaces for objects and work particularly well on curved surfaces or objects with bumpy normals. You can create an impression of a metallic, wet, or polished look quite easily (provided you have a way to generate cubemaps). In code, they are about as easy as fresnel, which gives them something of a broad utiity. Once you have the technique, you can treat it as a "par

havenphillip

havenphillip in Shaders

Fresnel and Blinn-Phong

If you took a bowl full of water and looked straight down into the bowl, the water would be clear. But if you were to then move the bowl up to your eye and look from the side along the surface of the water, you'd see it becomes highly reflective. That's fresnel. It's a cool effect. And it's easy to code. You add a uniform vec3 cameraposition towards the top and a fresnel color, and then a fresnel effect is little more than this: vec3 eyevec = normalize(cameraposition - ex_vertexp

havenphillip

havenphillip in Shaders

Introduction

Leadwerks 4 is one of the best purchases I've ever made. I've spent thousands of hours on it and most of that time has been spent dinking around with shaders. I'm not great at modeling and animation. I'm ok with scripts. What seems to draw me the most is shaders. I love shaders. I guess in some way here I just want a place to show off my accomplishments, but I also want to feel like I benefit other people, so my philosophy here is that it's cool to be one guy who can write shaders, but it's cool

havenphillip

havenphillip in Shaders

×
×
  • Create New...