Jump to content

[Solved] Refraction with Framework


L B
 Share

Recommended Posts

Trying to use refraction with framework, I found myself stuck having to get the rendering buffers, which I can't access. Example:

 

(Reference tutorial: http://www.leadwerks.com/files/Tutorials/CPP/Transparency_And_Refraction.pdf)

 

using System;
using Leadwerks;
using Math = Leadwerks.Math;

namespace Evol
{
   static class Refraction
   {
       static void Main()
       {
           try
           {
               Engine.Initialize(800, 600);
               Framework.Initialize();
               FileSystem.Initialize(@"C:\Users\Lazlo\Desktop\Refraction");
               Filtering.Optimize();

               Explorer ex = new Explorer(Framework.Camera);
               ex.Camera.Position = new Vector3(0, 2, -2);                

               Mesh scene = Mesh.Load("abstract::scene.gmf");

               World.Current = Framework.Layers.Transparency.World;

               Mesh sphere = new Mesh.Sphere();
               sphere.Material = Material.Load("abstract::glass_refraction.mat");
               //sphere.Material.Textures[2] = Can't get the framework's light buffer?
               //sphere.Material.Textures[3] = Can't get the framework's graphic buffer?
               sphere.Position.Y = 2;

               World.Current = Framework.Layers.Main.World;

               float refractionStrength = 0.01f;

               while (!Window.HasRequestedClose)
               {
                   ex.Update();

                   if (Keyboard.KeyDown(Key.Up))
                   {
                       refractionStrength += 0.001f;
                   }

                   if (Keyboard.KeyDown(Key.Down))
                   {
                       refractionStrength -= 0.001f;
                   }

                   refractionStrength = Math.Max(refractionStrength, 0);
                   sphere.Material.Shader.Pass("refractionstrength", refractionStrength);

                   Timing.Update();
                   Framework.Update();
                   Framework.Render();
                   Graphics.Flip();
               }
           }
           catch (LeadwerksException e)
           {
               Debug.Alert(e);
           }

           try
           {
               Framework.Dispose();
               Engine.Dispose();
           }
           catch { }
       }
   }
}

Link to comment
Share on other sites

Trying to use refraction with framework, I found myself stuck having to get the rendering buffers, which I can't access.

I had the same problem, but because I'm using framewerk and not framework I was able to amend the framewerk adding my own additional functions for suporting refraction.

 

Guess you need to request Josh do likewise in the embedded framework!

Intel Core i5 2.66 GHz, Asus P7P55D, 8Gb DDR3 RAM, GTX460 1Gb DDR5, Windows 7 (x64), LE Editor, GMax, 3DWS, UU3D Pro, Texture Maker Pro, Shader Map Pro. Development language: C/C++

Link to comment
Share on other sites

Requested Josh, he said it is not possible at the moment, but that he would try to implement GetFrameworkGraphicsBuffer and GetFrameworkLightingBuffer eventually, which could be in some time.

 

What are your suggested alternatives? Building my own Framewerk, or what?

Link to comment
Share on other sites

I actually solved it with this material file:

texture0="abstract::glass.dds"
texture1="abstract::glassdot3.dds"
texture2="tag::rendercolor"
texture3="tag::renderdepth"

depthmask=0
zsort=1
shader="abstract::mesh_diffuse_bumpmap.vert","abstract::mesh_diffuse_bumpmap_refraction.frag"

Thanks to Lumooja for the firepit reference suggestion.

Link to comment
Share on other sites

Yeah, never judge someone who is marked by experience. He may not be benevolent to your current fashion, but in the end he will show you the right way.

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Link to comment
Share on other sites

yes... as shown in Josh's refraction example that he had provided in the tutorial for transparency and refraction... At the bottom of the tutorial, he even added a scripted model to use inside the Editor. Tutorials are our friends!

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

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...