blobt
5 years ago
6 changed files with 101 additions and 6 deletions
-
BIN.vs/shader3/v14/.suo
-
6main.cpp
-
22res/shader/test.fs
-
15res/shader/test.vs
-
9shader3.vcxproj
-
55shader3.vcxproj.filters
@ -0,0 +1,22 @@ |
|||
uniform vec4 U_AmbientLightColor; |
|||
uniform vec4 U_AmbientMaterial; |
|||
uniform vec3 U_LightPos; |
|||
uniform vec4 U_DiffuseLightColor; |
|||
uniform vec4 U_DiffuseMaterial; |
|||
|
|||
|
|||
varying vec3 V_Normal; |
|||
|
|||
void main() |
|||
{ |
|||
//ambient |
|||
vec4 ambientColor = U_AmbientLightColor * U_AmbientMaterial; |
|||
|
|||
//diffuse |
|||
vec3 N = normalize(V_Normal); |
|||
vec3 L = normalize(U_LightPos); |
|||
float diffuseIntensity = max(0.0, dot(L,N)); |
|||
vec4 diffuseColor = U_DiffuseLightColor * U_DiffuseMaterial * diffuseIntensity; |
|||
|
|||
gl_FragColor = ambientColor + diffuseColor; |
|||
} |
@ -0,0 +1,15 @@ |
|||
attribute vec3 pos; |
|||
attribute vec2 texcoord; |
|||
attribute vec3 normal; |
|||
|
|||
uniform mat4 M; |
|||
uniform mat4 P; |
|||
uniform mat4 V; |
|||
uniform mat4 NM;//Normal Matrix 使用来修正法线的 |
|||
|
|||
varying vec3 V_Normal; |
|||
void main() |
|||
{ |
|||
V_Normal = mat3(NM)*normal; |
|||
gl_Position=P*V*M*vec4(pos,1.0); |
|||
} |
@ -1,3 +1,56 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|||
<ItemGroup> |
|||
<Filter Include="GPUProgram"> |
|||
<UniqueIdentifier>{e15d0e9c-35fc-45f8-90bd-b46a358d907b}</UniqueIdentifier> |
|||
</Filter> |
|||
<Filter Include="src"> |
|||
<UniqueIdentifier>{dbc65808-53cb-4088-a850-19079331f256}</UniqueIdentifier> |
|||
</Filter> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<ClCompile Include="FBO.cpp"> |
|||
<Filter>GPUProgram</Filter> |
|||
</ClCompile> |
|||
<ClCompile Include="FullScreenQuad.cpp"> |
|||
<Filter>GPUProgram</Filter> |
|||
</ClCompile> |
|||
<ClCompile Include="GPUProgram.cpp"> |
|||
<Filter>GPUProgram</Filter> |
|||
</ClCompile> |
|||
<ClCompile Include="ObjModel.cpp"> |
|||
<Filter>GPUProgram</Filter> |
|||
</ClCompile> |
|||
<ClCompile Include="utils.cpp"> |
|||
<Filter>GPUProgram</Filter> |
|||
</ClCompile> |
|||
<ClCompile Include="main.cpp"> |
|||
<Filter>src</Filter> |
|||
</ClCompile> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<ClInclude Include="FBO.h"> |
|||
<Filter>GPUProgram</Filter> |
|||
</ClInclude> |
|||
<ClInclude Include="FullScreenQuad.h"> |
|||
<Filter>GPUProgram</Filter> |
|||
</ClInclude> |
|||
<ClInclude Include="GPUProgram.h"> |
|||
<Filter>GPUProgram</Filter> |
|||
</ClInclude> |
|||
<ClInclude Include="ObjModel.h"> |
|||
<Filter>GPUProgram</Filter> |
|||
</ClInclude> |
|||
<ClInclude Include="utils.h"> |
|||
<Filter>GPUProgram</Filter> |
|||
</ClInclude> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<None Include="res\shader\test.fs"> |
|||
<Filter>src</Filter> |
|||
</None> |
|||
<None Include="res\shader\test.vs"> |
|||
<Filter>src</Filter> |
|||
</None> |
|||
</ItemGroup> |
|||
</Project> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue