Fixed coordinate transformation for skybox and reflection objects
Matched HLSL and GLSL shaders Fixes #757
This commit is contained in:
parent
1d815e6ced
commit
4e600f5943
11 changed files with 5 additions and 5 deletions
|
|
@ -24,7 +24,7 @@ void main()
|
|||
vec3 cR = reflect (cI, normalize(inNormal));
|
||||
|
||||
cR = vec3(ubo.invModel * vec4(cR, 0.0));
|
||||
cR.y *= -1.0;
|
||||
cR.yz *= -1.0;
|
||||
|
||||
vec4 color = textureLod(samplerCubeMapArray, vec4(cR, ubo.cubeMapIndex), ubo.lodBias);
|
||||
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -16,5 +16,6 @@ layout (location = 0) out vec3 outUVW;
|
|||
void main()
|
||||
{
|
||||
outUVW = inPos;
|
||||
outUVW.yz *= -1.0f;
|
||||
gl_Position = ubo.projection * ubo.model * vec4(inPos.xyz, 1.0);
|
||||
}
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -25,11 +25,11 @@ struct VSOutput
|
|||
|
||||
float4 main(VSOutput input) : SV_TARGET
|
||||
{
|
||||
float3 cI = normalize (input.ViewVec);
|
||||
float3 cI = normalize (input.Pos);
|
||||
float3 cR = reflect (cI, normalize(input.Normal));
|
||||
|
||||
cR = mul(ubo.invModel, float4(cR, 0.0)).xyz;
|
||||
cR *= float3(-1.0, 1.0, -1.0);
|
||||
cR *= float3(1.0, -1.0, -1.0);
|
||||
|
||||
float4 color = textureCubeMapArray.SampleLevel(samplerCubeMapArray, float4(cR, ubo.cubeMapIndex), input.LodBias);
|
||||
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -21,7 +21,7 @@ VSOutput main([[vk::location(0)]] float3 Pos : POSITION0)
|
|||
{
|
||||
VSOutput output = (VSOutput)0;
|
||||
output.UVW = Pos;
|
||||
output.UVW.y *= -1.0;
|
||||
output.UVW.yz *= -1.0;
|
||||
output.Pos = mul(ubo.projection, mul(ubo.model, float4(Pos.xyz, 1.0)));
|
||||
return output;
|
||||
}
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -59,7 +59,6 @@ public:
|
|||
title = "Cube map textures";
|
||||
camera.type = Camera::CameraType::lookat;
|
||||
camera.setPosition(glm::vec3(0.0f, 0.0f, -4.0f));
|
||||
camera.setRotation(glm::vec3(-7.25f, -120.0f, 0.0f));
|
||||
camera.setRotationSpeed(0.25f);
|
||||
camera.setPerspective(60.0f, (float)width / (float)height, 0.1f, 256.0f);
|
||||
settings.overlay = true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue