[Bf-blender-cvs] [592b2bd5e48] soc-2018-npr: Fixed DPIX ortho view.
Nick Wu
noreply at git.blender.org
Thu Sep 6 03:51:01 CEST 2018
Commit: 592b2bd5e488d6da57253dc9928e329d9125d8a7
Author: Nick Wu
Date: Thu Sep 6 09:01:50 2018 +0800
Branches: soc-2018-npr
https://developer.blender.org/rB592b2bd5e488d6da57253dc9928e329d9125d8a7
Fixed DPIX ortho view.
===================================================================
M source/blender/draw/engines/lanpr/shaders/lanpr_dpix_project_clip_frag.glsl
===================================================================
diff --git a/source/blender/draw/engines/lanpr/shaders/lanpr_dpix_project_clip_frag.glsl b/source/blender/draw/engines/lanpr/shaders/lanpr_dpix_project_clip_frag.glsl
index d381cd1027a..1fbd4e6f0cc 100644
--- a/source/blender/draw/engines/lanpr/shaders/lanpr_dpix_project_clip_frag.glsl
+++ b/source/blender/draw/engines/lanpr/shaders/lanpr_dpix_project_clip_frag.glsl
@@ -345,7 +345,9 @@ bool testProfileEdge(ivec2 texcoord, vec3 world_position)
mat3 nm = mat3(transpose(inverse(ModelMatrix)));
vec3 face_normal_0 = mat3(nm) * texelFetch(face_normal0_tex, texcoord, 0).xyz;
vec3 face_normal_1 = mat3(nm) * texelFetch(face_normal1_tex, texcoord, 0).xyz;
- vec3 camera_to_line = world_position - view_pos;//modelview * vec4(world_position, 1.0);
+ vec3 camera_to_line = is_perspective == 1 ?
+ world_position - view_pos :
+ view_dir;//modelview * vec4(world_position, 1.0);
vec4 edge_mask = texelFetch(edge_mask_tex, texcoord, 0);
@@ -396,27 +398,30 @@ void main(){
return;
}
- // clip to the near plane
vec3 v0_clipped_near = v0_world_pos.xyz;
vec3 v1_clipped_near = v1_world_pos.xyz;
- bool v0_beyond_near = pointBeyondNear(v0_world_pos.xyz);
- bool v1_beyond_near = pointBeyondNear(v1_world_pos.xyz);
- if (!v0_beyond_near && !v1_beyond_near)
- {
- // segment entirely behind the camera
- gl_FragData[0] = vec4(0.0, 1.0, 0.0, 0.0);
- gl_FragData[1] = vec4(0.0, 0.0, 1.0, 0.0);
- gl_FragData[2] = vec4(0.0, 1.0, 0.0, 0.0);
- return;
- }
- else if (!v0_beyond_near)
- {
- v0_clipped_near = clipSegmentToNear(v0_world_pos.xyz, v1_clipped_near);
- }
- else if (!v1_beyond_near)
- {
- v1_clipped_near = clipSegmentToNear(v1_world_pos.xyz, v0_clipped_near);
+ if(is_perspective==1){
+ // clip to the near plane
+ bool v0_beyond_near = pointBeyondNear(v0_world_pos.xyz);
+ bool v1_beyond_near = pointBeyondNear(v1_world_pos.xyz);
+
+ if (!v0_beyond_near && !v1_beyond_near)
+ {
+ // segment entirely behind the camera
+ gl_FragData[0] = vec4(0.0, 1.0, 0.0, 0.0);
+ gl_FragData[1] = vec4(0.0, 0.0, 1.0, 0.0);
+ gl_FragData[2] = vec4(0.0, 1.0, 0.0, 0.0);
+ return;
+ }
+ else if (!v0_beyond_near)
+ {
+ v0_clipped_near = clipSegmentToNear(v0_world_pos.xyz, v1_clipped_near);
+ }
+ else if (!v1_beyond_near)
+ {
+ v1_clipped_near = clipSegmentToNear(v1_world_pos.xyz, v0_clipped_near);
+ }
}
// If this segment is a profile edge, test to see if it should be turned on.
@@ -438,9 +443,12 @@ void main(){
vec4 v1_pre_div = projection * ViewMatrix * vec4(v1_clipped_near, 1.0);
// perspective divide
- vec3 v0_clip_pos = v0_pre_div.xyz / v0_pre_div.w;
- vec3 v1_clip_pos = v1_pre_div.xyz / v1_pre_div.w;
-
+ vec3 v0_clip_pos = v0_pre_div.xyz;
+ vec3 v1_clip_pos = v1_pre_div.xyz;
+ if(is_perspective==1){
+ v0_clip_pos /= v0_pre_div.w;
+ v1_clip_pos /= v1_pre_div.w;
+ }
// clip to frustum
bool v0_on_screen = !pointOffScreen(v0_clip_pos);
bool v1_on_screen = !pointOffScreen(v1_clip_pos);
More information about the Bf-blender-cvs
mailing list