Skip to content

Commit

Permalink
Merge pull request #1575 from zenustech/OptixBSDF
Browse files Browse the repository at this point in the history
add post process to texture 2d
  • Loading branch information
zhouhang95 authored Dec 5, 2023
2 parents 0ad136b + 0952b5f commit a682421
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion zeno/src/nodes/mtl/ShaderTexture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,14 @@ struct SmartTexture2D : ShaderNodeClone<SmartTexture2D>
if (has_input("coord")) {
coord = em->determineExpr(get_input("coord").get());
}
em->emitCode(zeno::format("{}(texture2D(zenotex[{}], vec2({}) * {}))", type, texId, coord, uvtiling));
auto postprocess = get_input2<std::string>("post_process");
if(postprocess == "raw"){
em->emitCode(zeno::format("{}(texture2D(zenotex[{}], vec2({}) * {}))", type, texId, coord, uvtiling));
}else if (postprocess == "srgb"){
em->emitCode(zeno::format("pow({}(texture2D(zenotex[{}], vec2({}) * {})),2.2f)", type, texId, coord, uvtiling));
}else if (postprocess == "normal_map"){
em->emitCode(zeno::format("{}(texture2D(zenotex[{}], vec2({}) * {})) * 2.0f - 1.0f", type, texId, coord, uvtiling));
}
}
};

Expand All @@ -195,6 +202,7 @@ ZENDEFNODE(SmartTexture2D, {
{"coord"},
{"vec2f", "uvtiling", "1,1"},
{"enum float vec2 vec3 vec4", "type", "vec3"},
{"enum raw srgb normal_map", "post_process", "raw"}
},
{
{"shader", "out"},
Expand Down
2 changes: 1 addition & 1 deletion zenovis/xinxinoptix/zxxglslvec.h
Original file line number Diff line number Diff line change
Expand Up @@ -1091,7 +1091,7 @@ __forceinline__ __device__ vec4 operator*(mat4 a, vec4 b)
//}

__forceinline__ __device__ vec3 normalmap(vec3 norm, float scale) {
norm = norm * 2 - 1;
//norm = norm * 2 - 1;
float x = norm.x * scale;
float y = norm.y * scale;
float z = 1 - sqrt(x * x + y * y);
Expand Down

0 comments on commit a682421

Please sign in to comment.