Browse Source

逐顶点渲染,环境光

master
blobt 4 years ago
parent
commit
d35db879f6
  1. 8
      Res/ambient_vs.fs
  2. 16
      Res/ambient_vs.vs
  3. 4
      renderFramework.vcxproj
  4. 10
      renderFramework.vcxproj.filters
  5. 8
      scene.cpp

8
Res/ambient_vs.fs

@ -0,0 +1,8 @@
#ifdef GL_ES
precision mediump float;
#endif
varying vec4 V_Color;
void main()
{
gl_FragColor=V_Color;
}

16
Res/ambient_vs.vs

@ -0,0 +1,16 @@
#ifdef GL_ES
precision mediump float;
#endif;
attribute vec4 position;
attribute vec4 texcoord;
attribute vec2 normal;
uniform mat4 ModelMatrix;
uniform mat4 ViewMatrix;
uniform mat4 ProjectionMatrix;
uniform vec4 U_AmbientMaterial;
uniform vec4 U_AmbientLight;
varying vec4 V_Color;
void main(){
V_Color=U_AmbientMaterial*U_AmbientLight;
gl_Position = ProjectionMatrix * ViewMatrix * ModelMatrix * position;
}

4
renderFramework.vcxproj

@ -149,11 +149,11 @@
<ClInclude Include="vertexbuffer.h" />
</ItemGroup>
<ItemGroup>
<None Include="Res\ambient_vs.fs" />
<None Include="Res\ambient_vs.vs" />
<None Include="Res\fullscreenquad.fs" />
<None Include="Res\fullscreenquad.vs" />
<None Include="Res\gray.fs" />
<None Include="Res\rgbcube.fs" />
<None Include="Res\rgbcube.vs" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">

10
renderFramework.vcxproj.filters

@ -62,19 +62,19 @@
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="Res\rgbcube.fs">
<None Include="Res\fullscreenquad.fs">
<Filter>源文件</Filter>
</None>
<None Include="Res\rgbcube.vs">
<None Include="Res\fullscreenquad.vs">
<Filter>源文件</Filter>
</None>
<None Include="Res\fullscreenquad.fs">
<None Include="Res\gray.fs">
<Filter>源文件</Filter>
</None>
<None Include="Res\fullscreenquad.vs">
<None Include="Res\ambient_vs.fs">
<Filter>源文件</Filter>
</None>
<None Include="Res\gray.fs">
<None Include="Res\ambient_vs.vs">
<Filter>源文件</Filter>
</None>
</ItemGroup>

8
scene.cpp

@ -12,13 +12,15 @@ FullScreenQuad *fsq;
void Init()
{
model.Init("Res/Cube.obj");
model.mShader->Init("Res/rgbcube.vs", "Res/rgbcube.fs");
model.Init("Res/Sphere.obj");
model.mShader->Init("Res/ambient_vs.vs", "Res/ambient_vs.fs");
model.SetPosition(0.0f, 0.0f, 0.0f);
model.SetAmbientMaterial(0.1f, 0.1f, 0.1f, 1.0f);
model.mShader->SetVec4("U_AmbientLight", 0.1f, 0.1f, 0.1f, 1.0f);
viewMatrix = glm::lookAt(cameraPos, glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, 1.0f, 0.0f));
fsq = new FullScreenQuad();
fsq->Init();
fsq->mShader->Init("Res/fullscreenquad.vs", "Res/gray.fs");
fsq->mShader->Init("Res/fullscreenquad.vs", "Res/fullscreenquad.fs");
}
void SetViewPortSize(float width, float height)

Loading…
Cancel
Save