Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //----------------------------------------------------------------------------------------------------
- // Shader template for [w]tech.
- // Copyright (c) [w]tech team.
- //----------------------------------------------------------------------------------------------------
- /** Define this when you want to make use of Tangents and Binormals (Needed for Normal-mapping)*/
- #define USE_TAN_BIN
- /** Define this when you want to modify attributes of the VertexShader (See CustomPreVS()-function) */
- //#define USE_CUSTOM_PREVS
- /** Define if you need access to the viewspace normals: Input.VS_Nrm */
- //#define USE_VIEWSPACE_NRM
- /** Define if you need access to the viewspace vertexposition: Input.VS_Pos */
- #define USE_VIEWSPACE_POS
- /** Un-Define if you know what you are doing and don't want the shader to use Instancing. The engine will most likly try to, though. */
- #define USE_INSTANCING
- #include <ShaderObject.fxh>
- class UserShaderObject : ShaderObject
- {
- // ----------- PIXEL SHADER -----------
- /** User defined scene-pixelshader (Outputs only one float4 for simplicity) */
- float4 UserScenePixelShader()
- {
- float3 Color = GetDiffuseLighting(); // get lighting
- /** bluring of lighting */
- float3 l=0;
- const int step = 16;
- const int ns=25*step/3;
- for(int y=-ns/2; y<ns/2; y+=step)
- {
- for(int x=-ns/2; x<ns/2; x+=step)
- {
- float2 Offset = (float2(x,y)/ViewportSize);
- Offset /= max(psInput.VS_Pos.z * 0.5, 0.1);
- Offset *= saturate(0.2+(abs(Tex(Tex2).rg*2-1)));
- Offset *= (1-Fresnel(vsNRM));
- l+=LightBuffer.Sample(samLinear, SCREEN_UV+Offset).rgb;
- }
- }
- l/= (ns/step)*(ns/step);
- /** use blured lighting */
- l = float3 (
- 0.9*l.b + 0.25*l.g, // convert blue and green light to red
- 0.7*l.b +0.2*l.g, // absorb green light
- 0.8*l.b + 0.8*l.g // absorb blue light
- );
- //l = GetDiffuseLighting();
- l.r += 0.1 * l.b; // Blau zu Rot
- l.g += 0.2 * l.b; // Blau zu Grün
- l.b -= 0.3 * l.b; // Blau abziehen
- l.r +=0.1 * l.g;
- l.b += 0.1 * l.g;
- l.g -= 0.2 * l.g;
- Color = float3(0.75,0.9,1) * pow(abs(Tex(Tex1).rgb),1); // some skin details
- Color += 0.25*Fresnel(vsNRM); // protect edges
- Color *= l; // HIER KANNST DU SSS TESTEN
- Color += 0.15*GetSpecularLighting(); // add specular
- return float4(Color, 1); // return result
- }
- /** User defined function for getting the Normals */
- float3 GetNormals()
- {
- float3 Normals = Tex(Tex2).rgb; // get normal map
- Normals= NrmMap(Normals); // convert normal map
- Normals += NrmMapD(TexUV(Tex3, UV*8).rgb,2);
- Normals/=2;
- return Normals; // return normals
- }
- /** User defined function for getting the specular power */
- float GetSpecularPower()
- {
- return 50;
- }
- // ----------- VERTEX SHADER -----------
- /** Runs before the VertexShader transforms the vertices */
- VertexShaderInput PreVertexShader(VertexShaderInput vsInput)
- {
- return vsInput;
- }
- /** Runs after the VertexShader has transformed the vertices */
- PixelShaderInput PostVertexShader(PixelShaderInput psInput)
- {
- return psInput;
- }
- };
- #include <MainShader.fx>
Add Comment
Please, Sign In to add comment