Merge branch 'master' of https://git.etud.insa-toulouse.fr/serviere/EnginPasTangible
This commit is contained in:
commit
14da88df99
4 changed files with 339 additions and 42 deletions
87
main.c
87
main.c
|
@ -7,6 +7,8 @@
|
||||||
#define STB_IMAGE_IMPLEMENTATION
|
#define STB_IMAGE_IMPLEMENTATION
|
||||||
#include "./Libraries/stb/stb_image.h"
|
#include "./Libraries/stb/stb_image.h"
|
||||||
#include "headers/shader.h"
|
#include "headers/shader.h"
|
||||||
|
|
||||||
|
#define SCENE "shaders/default.fs"
|
||||||
#define FULLSCREEN 0
|
#define FULLSCREEN 0
|
||||||
#define EXPERIMENTAL_FEATURES 0
|
#define EXPERIMENTAL_FEATURES 0
|
||||||
/* ## DEBUG MODE ##
|
/* ## DEBUG MODE ##
|
||||||
|
@ -44,6 +46,13 @@ float ez[3] = {0};
|
||||||
float ex[3] = {0};
|
float ex[3] = {0};
|
||||||
float ey[3] = {0};
|
float ey[3] = {0};
|
||||||
|
|
||||||
|
bool upar = false;
|
||||||
|
bool downar = false;
|
||||||
|
bool leftar = false;
|
||||||
|
bool rightar = false;
|
||||||
|
bool forwardar = false;
|
||||||
|
bool backwardar = false;
|
||||||
|
|
||||||
float fovValue=1.0;
|
float fovValue=1.0;
|
||||||
//281=3.13/2 * 180
|
//281=3.13/2 * 180
|
||||||
const int maxYmouse = 281;
|
const int maxYmouse = 281;
|
||||||
|
@ -73,8 +82,7 @@ static void key_callback(GLFWwindow* window, int key, int scancode, int action,
|
||||||
multiplicatorFov=1.;
|
multiplicatorFov=1.;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!action == GLFW_PRESS)
|
if (action == GLFW_PRESS) {
|
||||||
return;
|
|
||||||
if (key == GLFW_KEY_ESCAPE)
|
if (key == GLFW_KEY_ESCAPE)
|
||||||
{
|
{
|
||||||
//glfwSetWindowShouldClose(window, GLFW_TRUE);
|
//glfwSetWindowShouldClose(window, GLFW_TRUE);
|
||||||
|
@ -93,29 +101,40 @@ static void key_callback(GLFWwindow* window, int key, int scancode, int action,
|
||||||
}
|
}
|
||||||
if (key == GLFW_KEY_BACKSPACE)
|
if (key == GLFW_KEY_BACKSPACE)
|
||||||
glfwSetWindowShouldClose(window, GLFW_TRUE);
|
glfwSetWindowShouldClose(window, GLFW_TRUE);
|
||||||
if (key == GLFW_KEY_SPACE && stateControl != GLFW_PRESS)
|
if (key == GLFW_KEY_SPACE)
|
||||||
camPosY += speed;
|
upar = true;
|
||||||
if (key == GLFW_KEY_SPACE && stateControl == GLFW_PRESS)
|
if (key == GLFW_KEY_LEFT_CONTROL)
|
||||||
camPosY -= speed;
|
downar = true;
|
||||||
if (key == GLFW_KEY_UP || key == GLFW_KEY_W) {
|
if (key == GLFW_KEY_UP || key == GLFW_KEY_W) {
|
||||||
camPosX += speed*ez[0];
|
forwardar = true;
|
||||||
camPosY += speed*ez[1];
|
|
||||||
camPosZ += speed*ez[2];
|
|
||||||
}
|
}
|
||||||
if (key == GLFW_KEY_DOWN || key == GLFW_KEY_S ) {
|
if (key == GLFW_KEY_DOWN || key == GLFW_KEY_S ) {
|
||||||
camPosX -= speed*ez[0];
|
backwardar = true;
|
||||||
camPosY -= speed*ez[1];
|
|
||||||
camPosZ -= speed*ez[2];
|
|
||||||
}
|
}
|
||||||
if (key == GLFW_KEY_RIGHT || key == GLFW_KEY_D) {
|
if (key == GLFW_KEY_RIGHT || key == GLFW_KEY_D) {
|
||||||
camPosX += speed*ex[0];
|
rightar = true;
|
||||||
camPosY += speed*ex[1];
|
|
||||||
camPosZ += speed*ex[2];
|
|
||||||
}
|
}
|
||||||
if (key == GLFW_KEY_LEFT || key == GLFW_KEY_A ) {
|
if (key == GLFW_KEY_LEFT || key == GLFW_KEY_A ) {
|
||||||
camPosX -= speed*ex[0];
|
leftar = true;
|
||||||
camPosY -= speed*ex[1];
|
}
|
||||||
camPosZ -= speed*ex[2];
|
}
|
||||||
|
else if (action == GLFW_RELEASE) {
|
||||||
|
if (key == GLFW_KEY_SPACE)
|
||||||
|
upar = false;
|
||||||
|
if (key == GLFW_KEY_LEFT_CONTROL)
|
||||||
|
downar = false;
|
||||||
|
if (key == GLFW_KEY_UP || key == GLFW_KEY_W) {
|
||||||
|
forwardar = false;
|
||||||
|
}
|
||||||
|
if (key == GLFW_KEY_DOWN || key == GLFW_KEY_S ) {
|
||||||
|
backwardar = false;
|
||||||
|
}
|
||||||
|
if (key == GLFW_KEY_RIGHT || key == GLFW_KEY_D) {
|
||||||
|
rightar = false;
|
||||||
|
}
|
||||||
|
if (key == GLFW_KEY_LEFT || key == GLFW_KEY_A ) {
|
||||||
|
leftar = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,10 +143,11 @@ void scroll_callback(GLFWwindow* window, double xoffset, double yoffset)
|
||||||
int stateControl = glfwGetKey(window, GLFW_KEY_LEFT_CONTROL);
|
int stateControl = glfwGetKey(window, GLFW_KEY_LEFT_CONTROL);
|
||||||
|
|
||||||
// we only use yoffset as it is present on normal mice
|
// we only use yoffset as it is present on normal mice
|
||||||
if (DEBUG_MODE % 5 == 0)
|
if (DEBUG_MODE % 5 == 0) {
|
||||||
printf("scroll value : %f | precision : %f | ",yoffset, camPrecision);
|
printf("scroll value : %f | precision : %f | ",yoffset, camPrecision);
|
||||||
printf((stateControl == GLFW_PRESS) ? "ctrl -> speed" : "Zooming");
|
printf((stateControl == GLFW_PRESS) ? "ctrl -> speed" : "Zooming");
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
}
|
||||||
if (stateControl == GLFW_PRESS) {
|
if (stateControl == GLFW_PRESS) {
|
||||||
camPrecision += yoffset/2;
|
camPrecision += yoffset/2;
|
||||||
if (camPrecision <= 1)
|
if (camPrecision <= 1)
|
||||||
|
@ -202,7 +222,7 @@ int main (){
|
||||||
glBindVertexArray(VAO); // seeing as we only have a single VAO there's no need to unbind in the setupVertexArray function and then bind here, but we'll do so for clarity, organization, and avoiding possible bugs in future
|
glBindVertexArray(VAO); // seeing as we only have a single VAO there's no need to unbind in the setupVertexArray function and then bind here, but we'll do so for clarity, organization, and avoiding possible bugs in future
|
||||||
|
|
||||||
GLuint quad_shader = glCreateProgram();
|
GLuint quad_shader = glCreateProgram();
|
||||||
int compilerInfo=buildShaders(quad_shader, "shaders/generic.vs", "shaders/quad.fs");
|
int compilerInfo=buildShaders(quad_shader, "shaders/generic.vs", SCENE);
|
||||||
if(compilerInfo>0){
|
if(compilerInfo>0){
|
||||||
return compilerInfo;
|
return compilerInfo;
|
||||||
}
|
}
|
||||||
|
@ -256,6 +276,31 @@ int main (){
|
||||||
ey[2] = ex[0] * ez[1] - ex[1] * ez[0];
|
ey[2] = ex[0] * ez[1] - ex[1] * ez[0];
|
||||||
//crossProduct(ex,ez);
|
//crossProduct(ex,ez);
|
||||||
|
|
||||||
|
if (upar)
|
||||||
|
camPosY += speed;
|
||||||
|
if (downar)
|
||||||
|
camPosY -= speed;
|
||||||
|
if (forwardar) {
|
||||||
|
camPosX += speed*ez[0];
|
||||||
|
camPosY += speed*ez[1];
|
||||||
|
camPosZ += speed*ez[2];
|
||||||
|
}
|
||||||
|
if (backwardar) {
|
||||||
|
camPosX -= speed*ez[0];
|
||||||
|
camPosY -= speed*ez[1];
|
||||||
|
camPosZ -= speed*ez[2];
|
||||||
|
}
|
||||||
|
if (rightar) {
|
||||||
|
camPosX += speed*ex[0];
|
||||||
|
camPosY += speed*ex[1];
|
||||||
|
camPosZ += speed*ex[2];
|
||||||
|
}
|
||||||
|
if (leftar) {
|
||||||
|
camPosX -= speed*ex[0];
|
||||||
|
camPosY -= speed*ex[1];
|
||||||
|
camPosZ -= speed*ex[2];
|
||||||
|
}
|
||||||
|
|
||||||
currentTime = glfwGetTime();
|
currentTime = glfwGetTime();
|
||||||
deltaTime = currentTime - lastFrame;
|
deltaTime = currentTime - lastFrame;
|
||||||
lastFrame = currentTime;
|
lastFrame = currentTime;
|
||||||
|
@ -277,7 +322,7 @@ int main (){
|
||||||
glUniform3f(glGetUniformLocation(quad_shader, "iEy"), ey[0],ey[1],ey[2]);
|
glUniform3f(glGetUniformLocation(quad_shader, "iEy"), ey[0],ey[1],ey[2]);
|
||||||
glUniform3f(glGetUniformLocation(quad_shader, "iEz"), ez[0],ez[1],ez[2]);
|
glUniform3f(glGetUniformLocation(quad_shader, "iEz"), ez[0],ez[1],ez[2]);
|
||||||
glUniform3f(glGetUniformLocation(quad_shader, "iCamPos"), camPosX,camPosY,camPosZ);
|
glUniform3f(glGetUniformLocation(quad_shader, "iCamPos"), camPosX,camPosY,camPosZ);
|
||||||
glUniform1f(glGetUniformLocation(quad_shader, "iFovValue"), fovValue*multiplicatorFov);
|
glUniform1f(glGetUniformLocation(quad_shader, "iFovValue"), fovValue*fovValue*multiplicatorFov);
|
||||||
// glBindVertexArray(0); // no need to unbind it every time
|
// glBindVertexArray(0); // no need to unbind it every time
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
120
shaders/default.fs
Normal file
120
shaders/default.fs
Normal file
|
@ -0,0 +1,120 @@
|
||||||
|
#version 330 core
|
||||||
|
|
||||||
|
in vec2 FragCoord;
|
||||||
|
in float Time;
|
||||||
|
in vec3 Ex;
|
||||||
|
in vec3 Ey;
|
||||||
|
in vec3 Ez;
|
||||||
|
in vec3 CamPos;
|
||||||
|
in float fovValue;
|
||||||
|
in float FacteurLargeur;
|
||||||
|
|
||||||
|
out vec4 FragColor;
|
||||||
|
//uniform sampler2D generalTexture;
|
||||||
|
|
||||||
|
vec3 rotate(vec3 pos, vec3 angles){
|
||||||
|
float ca=cos(angles.x);
|
||||||
|
float sa=sin(angles.x);
|
||||||
|
float cb=cos(angles.y);
|
||||||
|
float sb=sin(angles.y);
|
||||||
|
float cc=cos(angles.z);
|
||||||
|
float sc=sin(angles.z);
|
||||||
|
return vec3(cb*cc*pos.x+(sa*sb*cc-ca*sc)*pos.y+(ca*sb*cc+sa*sc)*pos.z,
|
||||||
|
cb*sc*pos.x+(sa*sb*sc+ca*cc)*pos.y+(ca*sb*sc-sa*cc)*pos.z,
|
||||||
|
-sb*pos.x+sa*cb*pos.y+ca*cb*pos.z);
|
||||||
|
}
|
||||||
|
|
||||||
|
vec3 infinity(vec3 pos,vec3 box){
|
||||||
|
return mod(pos+.5*box,box)-.5*box;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
vec3 repeter(vec3 p, float size, vec3 repet)
|
||||||
|
{
|
||||||
|
return p-size*clamp(round(p/size),-repet,repet);
|
||||||
|
}
|
||||||
|
|
||||||
|
float SDF_Box_Frame( vec3 p, vec3 b, float e )
|
||||||
|
{
|
||||||
|
p = abs(p )-b;
|
||||||
|
vec3 q = abs(p+e)-e;
|
||||||
|
return min(min(
|
||||||
|
length(max(vec3(p.x,q.y,q.z),0.0))+min(max(p.x,max(q.y,q.z)),0.0),
|
||||||
|
length(max(vec3(q.x,p.y,q.z),0.0))+min(max(q.x,max(p.y,q.z)),0.0)),
|
||||||
|
length(max(vec3(q.x,q.y,p.z),0.0))+min(max(q.x,max(q.y,p.z)),0.0));
|
||||||
|
}
|
||||||
|
|
||||||
|
float Inflate( float b, float r )
|
||||||
|
{
|
||||||
|
return b - r;
|
||||||
|
}
|
||||||
|
|
||||||
|
float SDF_Sphere(vec3 p,float r){
|
||||||
|
return length(p)-r;
|
||||||
|
}
|
||||||
|
|
||||||
|
float SDF_Global(vec3 p){
|
||||||
|
return SDF_Sphere(p,.5);
|
||||||
|
//return max(SDF_Sphere(p,.5),-SDF_Box_Frame(rotate(p,vec3(0.,.2*Time,0.)),vec3(1.,1.,1.),.3));//min(SDF_Box_Frame(p,vec3(.5,.5,.5),0.1),SDF_Circle(mod(p+vec3(.5),vec3(1.,1.,1.))-vec3(.5),.15));
|
||||||
|
}
|
||||||
|
|
||||||
|
vec4 Get_Impact(vec3 origin,vec3 dir){//must have length(dir)==1
|
||||||
|
vec3 pos=origin;
|
||||||
|
float dist;
|
||||||
|
for(int i=0;i<30;i++){
|
||||||
|
dist=SDF_Global(pos);
|
||||||
|
pos+=dist*dir;
|
||||||
|
if(dist<=.01) return vec4(pos,1.);
|
||||||
|
if(dist>=20.0) return vec4(pos,-1.);
|
||||||
|
}
|
||||||
|
return vec4(pos,-1.);
|
||||||
|
}
|
||||||
|
|
||||||
|
vec3 grad(vec3 p){
|
||||||
|
vec2 epsilon = vec2(.01,0.);
|
||||||
|
return normalize(vec3(SDF_Global(p+epsilon.xyy)-SDF_Global(p-epsilon.xyy),
|
||||||
|
SDF_Global(p+epsilon.yxy)-SDF_Global(p-epsilon.yxy),
|
||||||
|
SDF_Global(p+epsilon.yyx)-SDF_Global(p-epsilon.yyx)));
|
||||||
|
}
|
||||||
|
|
||||||
|
vec3 Get_Color(vec3 origin,vec3 dir){
|
||||||
|
vec4 impact = Get_Impact(origin,dir);
|
||||||
|
if(impact.w<0.) return (impact.y+1.)*.05*vec3(.5,.7,1.);
|
||||||
|
vec3 normale=grad(impact.xyz);
|
||||||
|
vec3 sunPos=vec3(3.,3.5,.5);//vec3(3.*sin(Time*1.5),3.*cos(Time*3.),3.*cos(Time*1.5));
|
||||||
|
return vec3(clamp(0.,1.,dot(sunPos-impact.xyz,normale)));//normale;
|
||||||
|
}
|
||||||
|
|
||||||
|
float Mandel(vec2 co){
|
||||||
|
vec2 coo = co.xy;
|
||||||
|
float limf=100.0;
|
||||||
|
float cf=0.0;
|
||||||
|
int c;
|
||||||
|
for(c=0;c<30;c++){
|
||||||
|
coo=vec2(pow(coo.x,2.0)-pow(coo.y,2.0)+co.x,2.*coo.x*coo.y+co.y);
|
||||||
|
if(length(coo)>=2.0){
|
||||||
|
return cf/limf;
|
||||||
|
}
|
||||||
|
cf+=1.0;
|
||||||
|
}
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void main(){
|
||||||
|
vec3 lookingAt = vec3(0.);
|
||||||
|
vec3 posCam = CamPos;//vec3(-3.*sin(Time*.15),.6*cos(Time*.15),3.*cos(Time*.15));
|
||||||
|
//vec3 posCam = vec3(-3.*sin(MousePos.x/400)*(1-abs(atan(MousePos.y/500))),2*atan(MousePos.y/300),3.*cos(MousePos.x/400)*(1-abs(atan(MousePos.y/500))));
|
||||||
|
//float pan=-MousePos.x/180.;
|
||||||
|
//float tilt=-MousePos.y/180.;
|
||||||
|
//tilt=max(min(tilt,3.14*.45),-3.14*.45);
|
||||||
|
|
||||||
|
//vec3 ez = vec3(cos(tilt)*sin(pan),sin(tilt),cos(tilt)*cos(pan));//normalize(lookingAt-posCam);////base orthonormée
|
||||||
|
//vec3 ex = normalize(cross(ez,vec3(0.,1.,0.)));
|
||||||
|
//vec3 ey = cross(ex,ez);
|
||||||
|
|
||||||
|
vec3 dir = normalize(FragCoord.x * normalize(Ex) + FragCoord.y * normalize(Ey) + fovValue * Ez);
|
||||||
|
|
||||||
|
|
||||||
|
//float c=Mandel(FragCoord*1.5);
|
||||||
|
FragColor=vec4(Get_Color(posCam,dir),1.);//c,c,c,1.);
|
||||||
|
}
|
121
shaders/immeublesparisiens.fs
Normal file
121
shaders/immeublesparisiens.fs
Normal file
|
@ -0,0 +1,121 @@
|
||||||
|
#version 330 core
|
||||||
|
|
||||||
|
in vec2 FragCoord;
|
||||||
|
in float Time;
|
||||||
|
in vec3 Ex;
|
||||||
|
in vec3 Ey;
|
||||||
|
in vec3 Ez;
|
||||||
|
in vec3 CamPos;
|
||||||
|
in float fovValue;
|
||||||
|
in float FacteurLargeur;
|
||||||
|
|
||||||
|
out vec4 FragColor;
|
||||||
|
//uniform sampler2D generalTexture;
|
||||||
|
|
||||||
|
vec3 rotate(vec3 pos, vec3 angles){
|
||||||
|
float ca=cos(angles.x);
|
||||||
|
float sa=sin(angles.x);
|
||||||
|
float cb=cos(angles.y);
|
||||||
|
float sb=sin(angles.y);
|
||||||
|
float cc=cos(angles.z);
|
||||||
|
float sc=sin(angles.z);
|
||||||
|
return vec3(cb*cc*pos.x+(sa*sb*cc-ca*sc)*pos.y+(ca*sb*cc+sa*sc)*pos.z,
|
||||||
|
cb*sc*pos.x+(sa*sb*sc+ca*cc)*pos.y+(ca*sb*sc-sa*cc)*pos.z,
|
||||||
|
-sb*pos.x+sa*cb*pos.y+ca*cb*pos.z);
|
||||||
|
}
|
||||||
|
|
||||||
|
vec3 infinity(vec3 pos,vec3 box){
|
||||||
|
return mod(pos+.5*box,box)-.5*box;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
vec3 repeter(vec3 p, vec3 size, vec3 repet)
|
||||||
|
{
|
||||||
|
return p-size*clamp(vec3(round(p.x/size.x),round(p.y/size.y),round(p.z/size.z)),-repet,repet);
|
||||||
|
}
|
||||||
|
|
||||||
|
float SDF_Box_Frame( vec3 p, vec3 b, float e )
|
||||||
|
{
|
||||||
|
p = abs(p )-b;
|
||||||
|
vec3 q = abs(p+e)-e;
|
||||||
|
return min(min(
|
||||||
|
length(max(vec3(p.x,q.y,q.z),0.0))+min(max(p.x,max(q.y,q.z)),0.0),
|
||||||
|
length(max(vec3(q.x,p.y,q.z),0.0))+min(max(q.x,max(p.y,q.z)),0.0)),
|
||||||
|
length(max(vec3(q.x,q.y,p.z),0.0))+min(max(q.x,max(q.y,p.z)),0.0));
|
||||||
|
}
|
||||||
|
|
||||||
|
float Inflate( float b, float r )
|
||||||
|
{
|
||||||
|
return b - r;
|
||||||
|
}
|
||||||
|
|
||||||
|
float SDF_Sphere(vec3 p,float r){
|
||||||
|
return length(p)-r;
|
||||||
|
}
|
||||||
|
|
||||||
|
float SDF_Global(vec3 p){
|
||||||
|
//return SDF_Box_Frame(rotate(p,vec3(0.,.2*Time,0.)),vec3(.5,.5,.5),.1);
|
||||||
|
//return max(SDF_Sphere(p,.5),-SDF_Box_Frame(rotate(p,vec3(0.,.2*Time,0.)),vec3(1.,1.,1.),.3));//min(SDF_Box_Frame(p,vec3(.5,.5,.5),0.1),SDF_Circle(mod(p+vec3(.5),vec3(1.,1.,1.))-vec3(.5),.15));
|
||||||
|
return min(SDF_Box_Frame(repeter(p, vec3(4.,2.,10.), vec3(2., 25., 5.)), vec3(1.,1.,1.),.1),p.y); //infinity(p, vec(0.3, 0.2, 0.5))
|
||||||
|
}
|
||||||
|
|
||||||
|
vec4 Get_Impact(vec3 origin,vec3 dir){//must have length(dir)==1
|
||||||
|
vec3 pos=origin;
|
||||||
|
float dist;
|
||||||
|
for(int i=0;i<30;i++){
|
||||||
|
dist=SDF_Global(pos);
|
||||||
|
pos+=dist*dir;
|
||||||
|
if(dist<=.01) return vec4(pos,1.);
|
||||||
|
if(dist>=20.0) return vec4(pos,-1.);
|
||||||
|
}
|
||||||
|
return vec4(pos,-1.);
|
||||||
|
}
|
||||||
|
|
||||||
|
vec3 grad(vec3 p){
|
||||||
|
vec2 epsilon = vec2(.01,0.);
|
||||||
|
return normalize(vec3(SDF_Global(p+epsilon.xyy)-SDF_Global(p-epsilon.xyy),
|
||||||
|
SDF_Global(p+epsilon.yxy)-SDF_Global(p-epsilon.yxy),
|
||||||
|
SDF_Global(p+epsilon.yyx)-SDF_Global(p-epsilon.yyx)));
|
||||||
|
}
|
||||||
|
|
||||||
|
vec3 Get_Color(vec3 origin,vec3 dir){
|
||||||
|
vec4 impact = Get_Impact(origin,dir);
|
||||||
|
if(impact.w<0.) return (impact.y+1.)*.05*vec3(.5,.7,1.);
|
||||||
|
vec3 normale=grad(impact.xyz);
|
||||||
|
vec3 sunPos=vec3(3.,3.5,.5);//vec3(3.*sin(Time*1.5),3.*cos(Time*3.),3.*cos(Time*1.5));
|
||||||
|
return vec3(clamp(0.,1.,dot(sunPos-impact.xyz,normale)));//normale;
|
||||||
|
}
|
||||||
|
|
||||||
|
float Mandel(vec2 co){
|
||||||
|
vec2 coo = co.xy;
|
||||||
|
float limf=100.0;
|
||||||
|
float cf=0.0;
|
||||||
|
int c;
|
||||||
|
for(c=0;c<30;c++){
|
||||||
|
coo=vec2(pow(coo.x,2.0)-pow(coo.y,2.0)+co.x,2.*coo.x*coo.y+co.y);
|
||||||
|
if(length(coo)>=2.0){
|
||||||
|
return cf/limf;
|
||||||
|
}
|
||||||
|
cf+=1.0;
|
||||||
|
}
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void main(){
|
||||||
|
vec3 lookingAt = vec3(0.);
|
||||||
|
vec3 posCam = CamPos;//vec3(-3.*sin(Time*.15),.6*cos(Time*.15),3.*cos(Time*.15));
|
||||||
|
//vec3 posCam = vec3(-3.*sin(MousePos.x/400)*(1-abs(atan(MousePos.y/500))),2*atan(MousePos.y/300),3.*cos(MousePos.x/400)*(1-abs(atan(MousePos.y/500))));
|
||||||
|
//float pan=-MousePos.x/180.;
|
||||||
|
//float tilt=-MousePos.y/180.;
|
||||||
|
//tilt=max(min(tilt,3.14*.45),-3.14*.45);
|
||||||
|
|
||||||
|
//vec3 ez = vec3(cos(tilt)*sin(pan),sin(tilt),cos(tilt)*cos(pan));//normalize(lookingAt-posCam);////base orthonormée
|
||||||
|
//vec3 ex = normalize(cross(ez,vec3(0.,1.,0.)));
|
||||||
|
//vec3 ey = cross(ex,ez);
|
||||||
|
|
||||||
|
vec3 dir = normalize(FragCoord.x * normalize(Ex) + FragCoord.y * normalize(Ey) + fovValue * Ez);
|
||||||
|
|
||||||
|
|
||||||
|
//float c=Mandel(FragCoord*1.5);
|
||||||
|
FragColor=vec4(Get_Color(posCam,dir),1.);//c,c,c,1.);
|
||||||
|
}
|
|
@ -28,6 +28,12 @@ vec3 infinity(vec3 pos,vec3 box){
|
||||||
return mod(pos+.5*box,box)-.5*box;
|
return mod(pos+.5*box,box)-.5*box;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
vec3 repeter(vec3 p, float size, vec3 repet)
|
||||||
|
{
|
||||||
|
return p-size*clamp(round(p/size),-repet,repet);
|
||||||
|
}
|
||||||
|
|
||||||
float SDF_Box_Frame( vec3 p, vec3 b, float e )
|
float SDF_Box_Frame( vec3 p, vec3 b, float e )
|
||||||
{
|
{
|
||||||
p = abs(p )-b;
|
p = abs(p )-b;
|
||||||
|
@ -38,6 +44,11 @@ float SDF_Box_Frame( vec3 p, vec3 b, float e )
|
||||||
length(max(vec3(q.x,q.y,p.z),0.0))+min(max(q.x,max(q.y,p.z)),0.0));
|
length(max(vec3(q.x,q.y,p.z),0.0))+min(max(q.x,max(q.y,p.z)),0.0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float Inflate( float b, float r )
|
||||||
|
{
|
||||||
|
return b - r;
|
||||||
|
}
|
||||||
|
|
||||||
float SDF_Sphere(vec3 p,float r){
|
float SDF_Sphere(vec3 p,float r){
|
||||||
return length(p)-r;
|
return length(p)-r;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue