Skip to content

Commit

Permalink
Reflections fixed (#630)
Browse files Browse the repository at this point in the history
  • Loading branch information
eprikazchikov authored Dec 11, 2023
1 parent eda6ca4 commit bdf7c6a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
7 changes: 4 additions & 3 deletions engine/src/pipelinetasks/reflections.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Reflections::Reflections() :
Material *material = Engine::loadResource<Material>(".embedded/IblReflections.shader");
if(material) {
m_combineMaterial = material->createInstance();
m_combineMaterial->setTexture("rgbMap", slrTexture);
m_combineMaterial->setTexture("slrMap", slrTexture);
m_combineMaterial->setTexture("environmentMap", m_environmentTexture);
}

Expand All @@ -61,12 +61,13 @@ void Reflections::exec(PipelineContext *context) {

if(m_slrMaterial) { // sslr step
buffer->setRenderTarget(m_slrTarget);

buffer->drawMesh(Matrix4(), PipelineContext::defaultPlane(), 0, CommandBuffer::UI, m_slrMaterial);
}

if(m_combineMaterial) { // combine step
buffer->setRenderTarget(m_combineTarget);
//buffer->clearRenderTarget();

buffer->drawMesh(Matrix4(), PipelineContext::defaultPlane(), 0, CommandBuffer::UI, m_combineMaterial);
}

Expand Down Expand Up @@ -95,7 +96,7 @@ void Reflections::setInput(int index, Texture *texture) {
if(m_slrMaterial) {
m_slrMaterial->setTexture("emissiveMap", texture);
}
//m_combineTarget->setColorAttachment(0, texture);
m_combineTarget->setColorAttachment(0, texture);
m_outputs.front().second = texture;
} break;
case 3: { // depthMap
Expand Down
14 changes: 7 additions & 7 deletions worldeditor/bin/engine/materials/IblReflections.shader
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<property name="depthMap" type="texture2D" binding="1" target="true"/>
<property name="normalsMap" type="texture2D" binding="2" target="true"/>
<property name="paramsMap" type="texture2D" binding="3" target="true"/>
<property name="rgbMap" type="texture2D" binding="4" target="true"/>
<property name="slrMap" type="texture2D" binding="4" target="true"/>
</properties>
<fragment>
<![CDATA[
Expand All @@ -14,7 +14,7 @@
layout(binding = UNIFORM + 1) uniform sampler2D depthMap;
layout(binding = UNIFORM + 2) uniform sampler2D normalsMap;
layout(binding = UNIFORM + 3) uniform sampler2D paramsMap;
layout(binding = UNIFORM + 4) uniform sampler2D rgbMap;
layout(binding = UNIFORM + 4) uniform sampler2D slrMap;

layout(location = 0) in vec4 _vertex;
layout(location = 1) in vec2 _uv0;
Expand All @@ -23,7 +23,7 @@ layout(location = 3) in vec3 _n;
layout(location = 4) in vec3 _t;
layout(location = 5) in vec3 _b;

layout(location = 0) out vec4 color;
layout(location = 0) out vec3 color;

#include "Functions.h"

Expand All @@ -48,13 +48,13 @@ void main(void) {

vec3 ibl = vec3(0.0);//textureLod(environmentMap, refl, rough * 10.0).xyz;

vec4 sslr = texture(rgbMap, _uv0);
color = vec4(mix(ibl, sslr.xyz, sslr.w), (1.0 - rough));
vec4 sslr = texture(slrMap, _uv0);
color = mix(ibl, sslr.xyz, sslr.w);
return;
}
color = vec4(0.0);
color = vec3(0.0);
}
]]>
</fragment>
<pass type="PostProcess" blendMode="Opaque" lightModel="Unlit" depthTest="false" depthWrite="false" twoSided="true"/>
<pass type="PostProcess" blendMode="Additive" lightModel="Unlit" depthTest="false" depthWrite="false" twoSided="true"/>
</shader>

0 comments on commit bdf7c6a

Please sign in to comment.