I am working on making an online shop that sells diamond jewelry, and our main goal is to make those diamonds look very attractive to the eye. Unfortunately I don't know how to achieve reflections and refractions in WebGL.
My first try was to make a round diamond, and then render a skybox by palcing a camera inside a diamond stone in 3dsmax and vray. This gave me a pretty looking skybox (full of faceted distortions, just like a diamond) but it didn't really look interesting once applied to a refractive/reflective lambert material in Three.js.
So I started looking into Custom Shaders, and I stumble upon this link https://www.shadertoy.com/view/4sSGDc
Now my problem is that I can't find a way to make three.js compile the shader. Following other threads here, I found out how to setup some of the uniforms: (for example, Texture2D) but errors like this keep showing up:
THREE.WebGLShader: gl.getShaderInfoLog() ERROR: 0:163: 'textureCube' : no matching overloaded function found
ERROR: 0:163: 'assign' : cannot convert from 'const float' to 'highp 4-component vector of float'
ERROR: 0:168: 'textureCube' : no matching overloaded function found
ERROR: 0:168: 'r' : field selection requires structure, vector, or matrix on left hand side
ERROR: 0:169: 'textureCube' : no matching overloaded function found
ERROR: 0:169: 'g' : field selection requires structure, vector, or matrix on left hand side
ERROR: 0:170: 'textureCube' : no matching overloaded function found
ERROR: 0:170: 'b' : field selection requires structure, vector, or matrix on left hand side
ERROR: 0:185: 'textureCube' : no matching overloaded function found
ERROR: 0:185: 'assign' : cannot convert from 'const float' to 'highp 4-component vector of float'
ERROR: 0:196: 'fragCoord' : undeclared identifier
ERROR: 0:196: 'x' : field selection requires structure, vector, or matrix on left hand side
ERROR: 0:196: 'y' : field selection requires structure, vector, or matrix on left hand side
ERROR: 0:210: 'fragColor' : undeclared identifier
ERROR: 0:210: 'assign' : cannot convert from 'highp 4-component vector of float' to 'float'
Im not expecting to get someone to solve this for me, but I am asking for some lead into where to look first, or if there is some shortcut for converting this shader. This is a very important part of the project, so I will really appreciate any help! Thank you!