Michael Betke Posted January 19, 2010 Share Posted January 19, 2010 Is it possible to have a refraction material without any coding? Just a texture and a .mat file? I would like to do a simple and cheap water or glass surface. Rivers in Crysis work this way and look very good. I hope it's possible with LE too. Doing a waterplane is not a good option because reflections drop my frames to much and I cant control the bump values of the water. Quote Pure3d Visualizations Germany - digital essences AAA 3D Model Shop specialized on nature and environments Link to comment Share on other sites More sharing options...
Gandi Posted January 19, 2010 Share Posted January 19, 2010 Klick Me Think that should help Quote Link to comment Share on other sites More sharing options...
Michael Betke Posted January 20, 2010 Author Share Posted January 20, 2010 Thanks, I know this tutorial. But this is what I meant by writing "without coding" Quote Pure3d Visualizations Germany - digital essences AAA 3D Model Shop specialized on nature and environments Link to comment Share on other sites More sharing options...
flachdrache Posted January 20, 2010 Share Posted January 20, 2010 iirc the tutorial is working from a glass "shader" as sample to explain ... You could stress the material editor with the wobbleDot3 and alpha value textures, it maybe gives good results but it would not "bend" the view behind the surface. That is youll need to capture and obscure the currentscreen with a normal. Hmmmm, try a [edit] texture insteed the wobbleDot3 e.g. use a posterise filter on a normalmap. [edit] removed a link to external DuDv map. Quote AMD 64 X2 Dual 5k - 4GB - XFX GForce9800GT - nv196.21 - WinXP Sp3 zBrush4R2 - Silo2Pro - Unwrap3DPro - Gile - MaPZone2.5 Xxploration FPS in progress ... Link to comment Share on other sites More sharing options...
Josh Posted January 21, 2010 Share Posted January 21, 2010 No, but it is possible to set it up in script so that you can always drag the object into the scene and have it work, once you write the initial script. 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...
Michael Betke Posted January 21, 2010 Author Share Posted January 21, 2010 Is there a sample of this script somewhere? Quote Pure3d Visualizations Germany - digital essences AAA 3D Model Shop specialized on nature and environments Link to comment Share on other sites More sharing options...
flachdrache Posted January 23, 2010 Share Posted January 23, 2010 mixed something up for an icelake kind of thing - however, i didnt get the alpha right "refraction2.frag" #define amplitude 0.125 uniform sampler2D texture0; uniform sampler2D texture1; uniform sampler2D texture2; uniform float AppTime; //-->uniform float apptime; varying vec3 T,B,N; varying vec4 projectSpace; varying vec2 texcoord; varying vec4 ModelVertex; void main(){ vec3 normal; vec4 bumpcolor; bumpcolor = texture2D(texture1,vec2(texcoord.x*4.0,texcoord.y*4.0 - 0.00015 * AppTime)); bumpcolor *= (bumpcolor+texture2D(texture1,vec2(texcoord.x*4.0,texcoord.y*4.0 - 0.00025 * AppTime)) )/2.0; normal = normalize(2.0*bumpcolor.xyz - 1.0); normal = T * normal.x + B * normal.y + N * normal.z; normal = cross(normal,N); vec4 color = texture2DProj(texture0, projectSpace + amplitude * vec4(normal.x,normal.y,normal.z,0.0) ); // * gl_Color; color *= texture2D(texture2,vec2(texcoord.x*4.0,texcoord.y*4.0 - 0.00015 * AppTime) ); gl_FragColor=color; gl_FragColor.a=color.a; } material file : texture0="abstract::glass_diffuse.dds" texture1="abstract::wobbleDot3.dds" texture2="abstract::glass_diffuse.dds" blend=0 depthmask=1 depthtest=1 overlay=0 zsort=0 cullface=1 castshadows=0 shader="abstract::refraction.vert","abstract::refraction2.frag" shadowshader="abstract::mesh_shadow.vert","" hth and OK to post it here [edit] PS: Iam aware of the fact that i expose the refraction.frag in a incorrect way. because of that i used to add 2x -> "refraction2.frag" Quote AMD 64 X2 Dual 5k - 4GB - XFX GForce9800GT - nv196.21 - WinXP Sp3 zBrush4R2 - Silo2Pro - Unwrap3DPro - Gile - MaPZone2.5 Xxploration FPS in progress ... Link to comment Share on other sites More sharing options...
Michael Betke Posted January 25, 2010 Author Share Posted January 25, 2010 Thanks mate. Will check it out. Quote Pure3d Visualizations Germany - digital essences AAA 3D Model Shop specialized on nature and environments Link to comment Share on other sites More sharing options...
Josh Posted January 30, 2010 Share Posted January 30, 2010 I added a section at the end of this article that shows how to get refraction in the editor. It's very easy: http://leadwerks.com/werkspace/index.php?/page/resources?record=10 For practical use, I would just load a copy of the mesh, parented to the model, instead of creating a sphere mesh. So instead of this: CreateSphere(8,model) You would just have this: LoadMesh("whatever.gmf",model) 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...
Michael Betke Posted January 30, 2010 Author Share Posted January 30, 2010 Awesome. Works very good except one thing: Placing the refraction sphere aboove a waterplane makes the water invisible if you look through the sphere. You see the water caustics and the ground. Looks quite funny. Is there a way with the script to animate (or use the waterplane textures) to get a flowing effect? Quote Pure3d Visualizations Germany - digital essences AAA 3D Model Shop specialized on nature and environments Link to comment Share on other sites More sharing options...
Josh Posted January 30, 2010 Share Posted January 30, 2010 Multiple layers of transparency aren't supported, because it would require a separate buffer and pass for each object. Now, water might be made in the future to work with refraction, because it is sort of a special case. We'll see. Is there a way with the script to animate (or use the waterplane textures) to get a flowing effect? Use a shader uniform to scroll the texture. Requires shader coding, but it is not a difficult problem. You could simply offset the texture coordinates by the apptime built-in uniform. Check the list of built-in uniforms in the wiki for the exact name. 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...
flachdrache Posted February 1, 2010 Share Posted February 1, 2010 How ended this up ? I aint getting depthbuffers right require("scripts/class") local class=CreateClass(...) function class:InitDialog(grid) self.super:InitDialog(grid) group1 = grid:AddGroup("Model") group1:AddProperty("model", PROPERTY_FILE, "GMF Files (*.gmf):gmf", "Model File", "Model Files") group1:Expand(1) end function class:CreateObject(model) local object=self.super:CreateObject(model) object.model = model --Use the invisible material so the model is not visible, but can still be picked object.model:Paint(LoadMaterial("abstract::invisible.mat"),1) function object:Render() if fw~=nil then --Switch to the transparency world SetWorld(fw.transparency.world) --Create a sphere mesh parented to the model and scale it object.mesh=CreateSphere(16, object.model) object.mesh:SetScalef(4,4,4) object.mesh:Hide() --Load the refraction material local mat=LoadMaterial("abstract::glass_refraction_easy.mat") --Get the material shader and set the refraction strength uniform local shader=GetMaterialShader(mat) SetShaderFloat(shader,"refractionstrength",0.05) if object.useModel ~= nil then object.useModel:Paint(mat) else --Apply the material to the mesh object.mesh:Paint(mat) object.mesh:Show() end --Switch back to the main world SetWorld(fw.main.world) end end function object:SetKey(key,value) if key=="model" then self.useModel = LoadMesh("abstract::"..value, self.model) if self.useModel ~= nil then self.useModel:SetPosition(self.model:GetPosition()) end else return self.super:SetKey(key,value) end return 1 end function object:Free(model) if object.useModel ~= nil then object.useModel:Free() end self.super:Free() --Notify("Inside free") end end Most likely a logic error , could one of you please take a look. thx Quote AMD 64 X2 Dual 5k - 4GB - XFX GForce9800GT - nv196.21 - WinXP Sp3 zBrush4R2 - Silo2Pro - Unwrap3DPro - Gile - MaPZone2.5 Xxploration FPS in progress ... 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.