Josh Posted November 21, 2016 Share Posted November 21, 2016 An update on the beta branch adds the ability to create refraction effects. It's still pretty rough, but it works. This allows glass, heat haze, and other effects. The attached zip contains a map, material, and new shader for handling refraction effects. At this time, water must be enabled for any refraction effects to work. I think it also works if one or more post-processing effects are enabled. texture10 must be declared in the shader, where the screen color texture will automatically be uploaded. (I know this is weird, but this will get better.) I didn't put a lot of effort into the refraction shader because I figure you guys will go crazy making all kinds of things with it (especially Shadmar and Igor). So you can play with this now if you want to. The basic routine is there, and I just need to sort out the refracted tex coordinate. This update only effects the editor, only on Windows. refraction.zip 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
macklebee Posted November 21, 2016 Share Posted November 21, 2016 Need to have colored shadows or be able to have something other than just dark shadows. Ruins the effect without it. The only other option is to not have shadows at all then it leaves you with a floating object that doesn't seem part of the scene. 1 Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
Josh Posted November 21, 2016 Author Share Posted November 21, 2016 If every other pixel is removed from the shadow it creates a semi-transparent shadow. For clear glass I would not use any shadow. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
psychoanima Posted November 21, 2016 Share Posted November 21, 2016 Need to have colored shadows or be able to have something other than just dark shadows. Ruins the effect without it. The only other option is to not have shadows at all then it leaves you with a floating object that doesn't seem part of the scene. You mean something like caustic effect? Quote Link to comment Share on other sites More sharing options...
shadmar Posted November 21, 2016 Share Posted November 21, 2016 You can also use probes to make static refractions at almost no cost. Quote HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB Link to comment Share on other sites More sharing options...
macklebee Posted November 21, 2016 Share Posted November 21, 2016 If every other pixel is removed from the shadow it creates a semi-transparent shadow. For clear glass I would not use any shadow. You mean something like caustic effect? I asked specifically about adding colored shadows for colored glass much like I showed in the video from 2 years ago. A black shadow for colored glass looks almost as bad as having no shadow. And no, I mean colored shadows - something we had in LE2 over 6 years ago. And no - not the purelight global illumination - but colored shadows. Granted i know I am asking too much since we cannot even get simple projected textures for lights that LE2 had for its entirety. Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
Josh Posted November 21, 2016 Author Share Posted November 21, 2016 Funny you should mention that. In the editor on Windows in the beta, try adding a material with a texture in the first slot to a spotlight and watch what happens. I don't plan to implement colored shadows. It's too obscure of a feature and won't get noticed or used. I've got the refraction working with textureProj, just need to figure out how to use the normal to perturb the refraction vector correctly. This provides perfect accuracy but ignores the surface normal: #version 400 #define BFN_ENABLED 1 //Uniforms uniform sampler2D texture0;//diffuse map uniform sampler2D texture1;//normal map uniform sampler2D texture10;//screen color uniform vec4 materialcolorspecular; uniform vec4 lighting_ambient; uniform samplerCube texture15; uniform int decalmode; uniform float materialroughness; uniform sampler2DMS texture9; uniform vec2 buffersize; uniform bool isbackbuffer; uniform vec2 camerarange; uniform float camerazoom; //Inputs in vec2 ex_texcoords0; in vec4 ex_color; in float ex_selectionstate; in vec3 ex_VertexCameraPosition; in vec3 ex_normal; in vec3 ex_tangent; in vec3 ex_binormal; in float clipdistance0; out vec4 fragData0; out vec4 fragData1; out vec4 fragData2; out vec4 fragData3; void main(void) { //Clip plane discard if (clipdistance0>0.0) discard; vec4 outcolor = ex_color; vec4 color_specular = materialcolorspecular; //Normal map vec3 normal = ex_normal; normal = texture(texture1,ex_texcoords0).xyz * 2.0 - 1.0; float ao = normal.z; normal = ex_tangent*normal.x + ex_binormal*normal.y + ex_normal*normal.z; normal=normalize(normal); //--------------------------------------------------------------- //Refraction //--------------------------------------------------------------- vec4 refractionvector = vec4( gl_FragCoord.x/buffersize.x, gl_FragCoord.y/buffersize.y, gl_FragCoord.z, 1.0 ); if (isbackbuffer) refractionvector.y = 1.0f - refractionvector.y; vec2 texcoord = gl_FragCoord.xy / buffersize; if (isbackbuffer) texcoord.y = 1.0f - texcoord.y; vec4 screencolor = textureProj(texture10,refractionvector); outcolor = screencolor * 0.75; //--------------------------------------------------------------- // //--------------------------------------------------------------- fragData0 = outcolor; #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 float specular = color_specular.r * 0.299 + color_specular.g * 0.587 + color_specular.b * 0.114; int materialflags=1; if (ex_selectionstate>0.0) materialflags += 2; if (decalmode==1) materialflags += 4;//brush if (decalmode==2) materialflags += 8;//model if (decalmode==4) materialflags += 16;//terrain if (materialroughness>=0.5) { materialflags += 32; if (materialroughness>=0.75) materialflags += 64; } else { if (materialroughness>=0.25) materialflags += 64; } fragData1.a = materialflags/255.0; fragData2 = vec4(0.0,0.0,0.0,specular); } 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
macklebee Posted November 21, 2016 Share Posted November 21, 2016 Funny you should mention that. In the editor on Windows in the beta, try adding a material with a texture in the first slot to a spotlight and watch what happens. I must be doing something wrong because i see no difference after updating my project. I don't plan to implement colored shadows. It's too obscure of a feature and won't get noticed or used. Its hard to use something that doesn't get implemented. I have had a decent glass shader for a couple of years but no reason to use it when it looks weird with black or no shadows. But I will take what i can get if textures on lights work! Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
Josh Posted November 21, 2016 Author Share Posted November 21, 2016 It only works in the editor at this point. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Josh Posted November 22, 2016 Author Share Posted November 22, 2016 http://www.leadwerks.com/werkspace/page/viewitem?fileid=804131869 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.