Finally cubemap working
This commit is contained in:
1 parent
f413bbe265
commit
c475b1ecac
7 files changed
+186
-135
No files matched your search
@@ -4,6 +4,10 @@ varying vec3 dir;
|
||||
|
||||
void main(){
|
||||
gl_FragColor = textureCube(Env, normalize(dir));
|
||||
//if (dir.z < 0)
|
||||
//{
|
||||
// gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
|
||||
//}
|
||||
//gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
|
||||
|
||||
}
|
||||
@@ -10,5 +10,5 @@ void main(){
|
||||
vec4 realVertexPos = vec4(ModelRotateMatrix * vPosition.xyz + ModelTranslateVector, 1.0);
|
||||
gl_Position = ProjectionMatrix * realVertexPos;
|
||||
|
||||
dir = -vPosition;
|
||||
dir = vPosition;
|
||||
}
|
||||
@@ -4,13 +4,20 @@ uniform vec3 CamPos;
|
||||
uniform float WaterTimer;
|
||||
|
||||
|
||||
varying vec2 texCoord;
|
||||
varying vec3 vertexPos;
|
||||
varying vec3 camVec;
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 texCoord = gl_TexCoord[0].st;
|
||||
|
||||
vec3 camVec2 = normalize(camVec);
|
||||
|
||||
vec4 reflectColor = textureCube(Env, camVec2);
|
||||
|
||||
gl_FragColor = vec4(reflectColor.xyz, 1.0f);
|
||||
|
||||
/*
|
||||
mat3 rot;
|
||||
|
||||
rot[0] = vec3(0.0,0.0,1.0);
|
||||
@@ -29,9 +36,9 @@ void main()
|
||||
vec3 NVecReflect = normalize(rot * (NVec1 + NVec2) + vec3(0,8,0));
|
||||
vec3 NVecRefract = normalize(rot * (NVec1 + NVec2));
|
||||
|
||||
vec3 dir1 = reflect((camVec),NVecReflect);
|
||||
//vec3 dir2 = refract((camVec),NVecRefract,0.9);
|
||||
vec3 dir2 = reflect((camVec),NVecReflect);
|
||||
vec3 dir1 = reflect((camVec2),NVecReflect);
|
||||
//vec3 dir2 = refract((camVec2),NVecRefract,0.9);
|
||||
vec3 dir2 = reflect((camVec2),NVecReflect);
|
||||
dir2.y = - dir2.y;
|
||||
|
||||
vec4 reflectColor = textureCube(Env, dir1);
|
||||
@@ -39,7 +46,8 @@ void main()
|
||||
|
||||
vec4 texColor = reflectColor*0.2 + refractColor*0.8;
|
||||
|
||||
gl_FragColor = vec4(texColor.xyz, 1.0f);
|
||||
gl_FragColor = vec4(texColor.xyz, 1.0f);*/
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,13 +1,26 @@
|
||||
attribute vec3 vPosition;
|
||||
attribute vec2 vTexCoord;
|
||||
|
||||
uniform mat4 ProjectionMatrix;
|
||||
uniform mat3 ModelRotateMatrix;
|
||||
uniform vec3 ModelTranslateVector;
|
||||
uniform vec3 CamPos;
|
||||
|
||||
varying vec2 texCoord;
|
||||
varying vec3 vertexPos;
|
||||
varying vec3 camVec;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = ftransform();
|
||||
vec4 realVertexPos = vec4(ModelRotateMatrix * vPosition.xyz + ModelTranslateVector, 1.0);
|
||||
gl_Position = ProjectionMatrix * realVertexPos;
|
||||
|
||||
gl_TexCoord[0] = gl_MultiTexCoord0;
|
||||
texCoord = vTexCoord;
|
||||
|
||||
camVec = (gl_Vertex.xyz - CamPos);
|
||||
camVec = -(vPosition.xyz - CamPos);
|
||||
|
||||
//camVec = vec3(0, 1, 0);
|
||||
|
||||
//camVec.y = -camVec.y;
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user