Skip to content

Commit 4a7266d

Browse files
committed
samples: float4→float3 for vtx_normal in cartoon & fireflies samples
It seems that Cg's glslv profile causes the w coordinate of the normal column to be random. Fixes panda3d#494 Fixes panda3d#495
1 parent 42405df commit 4a7266d

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

samples/cartoon-shader/normalGen.sha

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,21 @@
33
//Cg profile arbvp1 arbfp1
44

55
void vshader(float4 vtx_position : POSITION,
6-
float4 vtx_normal : NORMAL,
7-
out float4 l_position : POSITION,
8-
out float3 l_color : TEXCOORD0,
9-
uniform float4x4 mat_modelproj,
10-
uniform float4x4 itp_modelview)
6+
float3 vtx_normal : NORMAL,
7+
out float4 l_position : POSITION,
8+
out float3 l_color : TEXCOORD0,
9+
uniform float4x4 mat_modelproj,
10+
uniform float4x4 itp_modelview)
1111
{
12-
l_position=mul(mat_modelproj, vtx_position);
13-
l_color=(float3)mul(itp_modelview, vtx_normal);
12+
l_position = mul(mat_modelproj, vtx_position);
13+
l_color = (float3)mul(itp_modelview, float4(vtx_normal, 0));
1414
}
1515

1616
void fshader(float3 l_color: TEXCOORD0,
1717
out float4 o_color: COLOR)
1818
{
1919
l_color = normalize(l_color);
2020
l_color = l_color/2;
21-
o_color.rgb = l_color + float4(0.5, 0.5, 0.5, 0.5);
21+
o_color.rgb = l_color.rgb + float3(0.5, 0.5, 0.5);
2222
o_color.a = 1;
2323
}
24-
25-

samples/fireflies/model.sha

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
void vshader(float4 vtx_position : POSITION,
66
float2 vtx_texcoord0 : TEXCOORD0,
7-
float4 vtx_normal : NORMAL,
7+
float3 vtx_normal : NORMAL,
88
float4 vtx_color : COLOR,
99
out float4 l_position : POSITION,
1010
out float2 l_texcoord0 : TEXCOORD0,
@@ -16,7 +16,7 @@ void vshader(float4 vtx_position : POSITION,
1616
l_position=mul(mat_modelproj, vtx_position);
1717
l_texcoord0 = vtx_texcoord0;
1818
l_color = vtx_color;
19-
l_normal = (float3)mul(itp_modelview, vtx_normal);
19+
l_normal = (float3)mul(itp_modelview, float4(vtx_normal, 0));
2020
}
2121

2222
void fshader(float2 l_texcoord0: TEXCOORD0,

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy