Jump to content

havenphillip

Members
  • Posts

    550
  • Joined

  • Last visited

Everything posted by havenphillip

  1. I tried to reproduce it. I'm not getting the same outcome. It seems to be working correctly for me: When you zoom in and out on the object does it adjust itself? If it works correctly in-game then it might just be the material editor or have something to do with using the "player_pos". Otherwise sometimes I've noticed if I restart my computer it will fix some of these weird things. Does this work?: #version 400 #define MAX_INSTANCES 256 //Uniforms uniform instancematrices { mat4 matrix[MAX_INSTANCES];} entity; uniform mat4 projectioncameramatrix; uniform float currenttime; float time = currenttime/1000; uniform vec3 cameraposition; uniform vec3 player_pos; //Attributes in vec3 vertex_position; in vec2 vertex_texcoords0; in vec3 vertex_normal; in vec3 vertex_tangent; in vec3 vertex_binormal; //Outputs out vec4 ex_vertexposition; out vec2 ex_texcoords0; out vec3 ex_normal; out vec3 ex_tangent; out vec3 ex_binormal; void main() { //entity matrix mat4 entitymatrix = entity.matrix[gl_InstanceID]; mat4 entitymatrix_ = entitymatrix; entitymatrix_[0][3]=0.0; entitymatrix_[1][3]=0.0; entitymatrix_[2][3]=0.0; entitymatrix_[3][3]=1.0; //model position ex_vertexposition = entitymatrix_ * vec4(vertex_position,1.0); //Interactive vec3 direction = normalize(ex_vertexposition.xyz - player_pos); direction.y = -0.000; float radius = 2.0; float interact_power = 2.0; float dist = distance(player_pos,ex_vertexposition.xyz); float power = smoothstep(radius,0.0,dist*dist*0.3); direction = (vec4(direction,1.0) * entitymatrix_).xyz; ex_vertexposition.xyz += direction * power * 5.0 * interact_power * cos(5.0-ex_texcoords0.y)*cos(5.5-ex_texcoords0.x); gl_Position = projectioncameramatrix * ex_vertexposition; //normals mat3 nmat = mat3(entitymatrix_); ex_normal = normalize(nmat * vertex_normal); ex_tangent = normalize(nmat * vertex_tangent); ex_binormal = normalize(nmat * vertex_binormal); //texture coordinates ex_texcoords0 = vertex_texcoords0; }
  2. You should be able to just erase these lines without any problem. It doesn't look like you're establishing anything here that you need to use later:
  3. You got your process streamlined. Your levels seem to just pop up out of nowhere. I'd be interested in reading a tutorial.
  4. That ice rock looks pretty cool. What other shaders should I attempt?
  5. That's cool tessellation going to be automatic for all materials?
  6. A shot in the dark but one thing you could try is multiplying the vertex_position * entitymatrix rather than the vertex_normal * entitymatrix;
  7. Nice. I think with some tweaking here and there people can get the effect out of it that they want.
  8. 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.xy * amplitude); That's pretty much the gist of it. What this does is it warps the diffuse texture coordinates by the normals. But adding the normals to the texture coordinates pushes the effect to one side so I took it a step further by subtracting the ex_normal from that and the difference creates a nice centered refraction effect against the diffuse texture. vec2 n1 = normal.xy * amplitude; vec2 n2 = ex_normal.xy * amplitude; vec4 outcolor = texture(texture0,ex_texcoords0 + n1 - n2); In the weeper shader I added time to the normal texcoords and that makes an effect like water dripping down a wall. Here I didn't need that because this is ice. It's stuck in place. Once I got that established I added parallax to the diffuse texture. I used texture4 in this shader for my "outcolor" because I reserved texture0 for the little scratch marks on the surface of the ice. vec4 refractcol = texture(texture4, parallaxed_texcoords.xy + n1 - n2); After this I finished the color by mixing the outcolor and the refractcol by a "lighten" blend mode I found on Github. If you look at the normals and the outcolor in the shader you'll notice I didn't use the parallaxed texcoords because I wanted the surface to remain where its at and give the impression that there is something sort of encasing the "ice" i.e., the surface of the object - what the light bounces off of. The whole "ice" effect happens under some surface, right? I also z-sorted the object, which gets rid of the shaded sides (like ice doesn't really have a shadowed side does it?) and because of that I lost the specular so I added a blinn-phong to replace it. Also I added a cubemap to simulate reflection. I think this would work great as a frozen lake or an iceberg. Maybe even as ice cubes. It doesn't take the screen into consideration like the creek refraction does so you still technically have an opaque object. It's also parallax which notoriously has trouble with curves. I've added a few tricks so that the parallax can work on gentle slopes. You can adjust the texture sizes, the light, the cubemap fresnel, the parallax depth, the refraction amount, and the ice "contrast." If you put it on your own model you'll have to adjust the texture sizes and stuff but it's set up to work on a Leadwerks box brush so you can just slap it on one of those to quickly see it in action. The picture doesn't do it justice you have to move it around to see the effect. Anyway it's something fun. 27a_ice.zip
  9. Yeah it uses kernels to blur the image then subtracts the standard image from it which gives a grey, and the difference due to the blur sharpens it up. That's what high pass is in GIMP. I don't know how it would be used for lights. Looks like this:
  10. Yeah totally dude it's from muh blog.
  11. I did a high-pass filter: VERTEX: #version 400 uniform mat4 projectionmatrix; uniform mat4 drawmatrix; uniform vec2 offset; uniform vec2 position[4]; in vec3 vertex_position; void main(void) { gl_Position = projectionmatrix * (drawmatrix * vec4(position[gl_VertexID]+offset, 0.0, 1.0)); } FRAGMENT: //from https://learnopengl.com/Advanced-OpenGL/Framebuffers #version 400 //Variables float pass_mix = 0.5; float spread = 1000.0; float brightness = 1.3; //Uniforms uniform sampler2D texture1; uniform bool isbackbuffer; uniform vec2 buffersize; //Outputs out vec4 fragData0; float offset = 1.0 / spread; vec3 blendMultiply(vec3 base, vec3 blend) { return base*blend; } vec3 blendMultiply(vec3 base, vec3 blend, float opacity) { return (blendMultiply(base, blend) * opacity + base * (1.0 - opacity)); } void main(void) { vec2 coord = vec2(gl_FragCoord.xy/buffersize); if (isbackbuffer) coord.y = 1.0 - coord.y; vec4 outcol = texture(texture1,coord); vec2 offsets[9] = vec2[]( vec2(-offset, offset), // top-left vec2( 0.0f, offset), // top-center vec2( offset, offset), // top-right vec2(-offset, 0.0f), // center-left vec2( 0.0f, 0.0f), // center-center vec2( offset, 0.0f), // center-right vec2(-offset, -offset), // bottom-left vec2( 0.0f, -offset), // bottom-center vec2( offset, -offset) // bottom-right ); //Blur float kernel[9] = float[]( 1.0 / 16, 2.0 / 16, 1.0 / 16, 2.0 / 16, 4.0 / 16, 2.0 / 16, 1.0 / 16, 2.0 / 16, 1.0 / 16 ); vec3 sampleTex[9]; for(int i = 0; i < 9; i++) { sampleTex[i] = vec3(texture(texture1, coord + offsets[i])); } vec3 col = vec3(0.0); for(int i = 0; i < 9; i++) col += sampleTex[i] * kernel[i]; //High Pass vec3 high_pass = 0.5 - 8.0 * (col - outcol.xyz); //Output fragData0.xyz = blendMultiply(outcol.xyz,high_pass,0.5); //fragData0 = vec4(high_pass,1); //pure high pass }
  12. You can try changing the bottom of the shader like this. This works in the material editor for me. #if BFN_ENABLED==1 //Best-fit normals fragData1 = texture(texture15,normalize(vec3(normal.x,-normal.y,normal.z))); fragData1.a = fragData0.a; #else //Low-res normals fragData1 = vec4(normalize(normal)*0.5+0.5,fragData0.a); #endif int materialflags=1; if (ex_selectionstate>0.0) materialflags += 2; fragData1.a = materialflags/255.0; float specular = color_specular.r * 0.299 + color_specular.g * 0.587 + color_specular.b * 0.114; fragData2 = vec4(0.0,0.0,0.0,specular); vec3 dissolve_col = vec3(0,1,0); if (NoiseV<InvAlpha+0.03) fragData2 = vec4(dissolve_col,specular); }
  13. I'm snowed in I have limited power/internet. I'll get back to you on it but it looks like the specular affects it because he made the specular channel and the normals alpha channel the same. I tend to think Shadmar knows what he's doing and I'm not sure why he did it this way but I'm sure the fix will be pretty easy.
  14. Is it red in the Material Editor? If so it could be your normals alpha channel. Edit: I just saw the picture it looks like it is. The first thing I would do is check your fragData1 lines in the Fragment shader. They should look like: //Normals Output fragData1 = vec4(normalize(normal)*0.5+0.5,fragData0.a); fragData1.a = 1/255.0;
  15. Oh that one looks cooler anyway.
  16. This works fine for me. Is the shader compiling? Or do you mean you get some kind of lag?
  17. Awesome, dude. It's only going to get better from there. I love that you can put materials on terrain.
  18. Sounds great, man. Congrats. I still don't like the subscription thing though. That's my only gripe. Everything else A+.
  19. Awesome. Thanks, man. I'll see what I can do with this.
  20. Yeah that'd be great. plane reflections.zip
  21. I don't have anything clamped. I did try clamping stuff but nothing seemed to affect it.
  22. Just using the shader from above. That's why I'm wondering if I need to use a script like a Render function or something. It does look like that in game too. The one I was using has a similar problem it looks ok until I look down then I get this. I dont' know what it is but it looks like maybe it has to do with the buffer not fitting to the screen?
  23. All I get with that are these weird lines. I'm not sure what they are. Like the buffer or something? Even on the one I was using I was getting a similar thing. Do you know what it is ? What's happening here?
×
×
  • Create New...