From patchwork Wed Sep 4 17:51:38 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jesse Barker X-Patchwork-Id: 19761 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qe0-f72.google.com (mail-qe0-f72.google.com [209.85.128.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D1AE124869 for ; Wed, 4 Sep 2013 17:51:40 +0000 (UTC) Received: by mail-qe0-f72.google.com with SMTP id 6sf717073qea.7 for ; Wed, 04 Sep 2013 10:51:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:mime-version:to:from:subject :message-id:date:reply-to:sender:errors-to:precedence :x-original-sender:x-original-authentication-results:mailing-list :list-id:list-post:list-help:list-archive:list-unsubscribe :content-type; bh=laPsj8qWLfo7zecpVrMjei4r0sDnsL2icjuKaTGmkqc=; b=ms692NGEjQNVJOevmDsG3CJ+8bhtUICgaudtsdtS5XAWeAWBmtj21mONTqkiJFIZzB feWQg/VhEJEJR3rzxJ152kT3shpGUTCIDgM27aC5EiWb1i7f41aYBGfBlqGDef4cjLz2 csgV7T6Rdop20pPt1Z9wqnLXOAHlptUyIZH2Chxz0iovDrriYkwRXaKsRu2Hc47Z7wgL SiEWdPoPUFOouveEy60zni30TqJiPlyxrHs2PQFILvrTuMEHVUmeFERaeWbD6oHQbQvU 6hTCP1/B99mnnm+lNR8shSjsvR+aAGmGgTC1qh2UWtCYo/Irdzxz58//xk2oizEbCIgk Wk4g== X-Received: by 10.236.56.70 with SMTP id l46mr1575967yhc.2.1378317100677; Wed, 04 Sep 2013 10:51:40 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.38.101 with SMTP id f5ls217125qek.31.gmail; Wed, 04 Sep 2013 10:51:40 -0700 (PDT) X-Received: by 10.58.97.238 with SMTP id ed14mr949048veb.34.1378317100585; Wed, 04 Sep 2013 10:51:40 -0700 (PDT) Received: from mail-vb0-f44.google.com (mail-vb0-f44.google.com [209.85.212.44]) by mx.google.com with ESMTPS id ry8si6121116vcb.121.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 04 Sep 2013 10:51:40 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.212.44 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.44; Received: by mail-vb0-f44.google.com with SMTP id e13so401455vbg.17 for ; Wed, 04 Sep 2013 10:51:40 -0700 (PDT) X-Gm-Message-State: ALoCoQn1XGSw17yRXrsHXYQGElzA2Yahq6lOu+1TaUnERT3fb2fcYT6+MiqqaUnNnVt6AI4+x2CS X-Received: by 10.52.92.15 with SMTP id ci15mr311824vdb.34.1378317100500; Wed, 04 Sep 2013 10:51:40 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp233907vcz; Wed, 4 Sep 2013 10:51:39 -0700 (PDT) X-Received: by 10.180.109.65 with SMTP id hq1mr2998786wib.53.1378317099114; Wed, 04 Sep 2013 10:51:39 -0700 (PDT) Received: from indium.canonical.com (indium.canonical.com. [91.189.90.7]) by mx.google.com with ESMTPS id bb9si9525874wjb.139.1969.12.31.16.00.00 (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 04 Sep 2013 10:51:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.7 as permitted sender) client-ip=91.189.90.7; Received: from ackee.canonical.com ([91.189.89.26]) by indium.canonical.com with esmtp (Exim 4.71 #1 (Debian)) id 1VHHEw-00050F-J5 for ; Wed, 04 Sep 2013 17:51:38 +0000 Received: from ackee.canonical.com (localhost [127.0.0.1]) by ackee.canonical.com (Postfix) with ESMTP id 7E410E90FF for ; Wed, 4 Sep 2013 17:51:38 +0000 (UTC) MIME-Version: 1.0 X-Launchpad-Project: glmark2 X-Launchpad-Branch: ~glmark2-dev/glmark2/trunk X-Launchpad-Message-Rationale: Subscriber X-Launchpad-Branch-Revision-Number: 281 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~glmark2-dev/glmark2/trunk] Rev 281: SceneShading: Adds a new 'cel' (or 'toon') shading model. Message-Id: <20130904175138.7960.22165.launchpad@ackee.canonical.com> Date: Wed, 04 Sep 2013 17:51:38 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: list X-Generated-By: Launchpad (canonical.com); Revision="16753"; Instance="launchpad-lazr.conf" X-Launchpad-Hash: ca78ded7363fb05ac2a90d57ce7358e3bba9cc4b X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: noreply@launchpad.net X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.44 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Merge authors: Jesse Barker (jesse-barker) Related merge proposals: https://code.launchpad.net/~glmark2-dev/glmark2/cel-shading/+merge/180013 proposed by: Jesse Barker (jesse-barker) review: Approve - Alexandros Frantzis (afrantzis) ------------------------------------------------------------ revno: 281 [merge] committer: Jesse Barker branch nick: trunk timestamp: Wed 2013-09-04 10:07:59 -0700 message: SceneShading: Adds a new 'cel' (or 'toon') shading model. Merge of lp:~glmark2-dev/glmark2/cel-shading added: data/shaders/light-cel.frag modified: src/default-benchmarks.h src/scene-shading.cpp --- lp:glmark2 https://code.launchpad.net/~glmark2-dev/glmark2/trunk You are subscribed to branch lp:glmark2. To unsubscribe from this branch go to https://code.launchpad.net/~glmark2-dev/glmark2/trunk/+edit-subscription === added file 'data/shaders/light-cel.frag' --- data/shaders/light-cel.frag 1970-01-01 00:00:00 +0000 +++ data/shaders/light-cel.frag 2013-08-13 17:18:04 +0000 @@ -0,0 +1,60 @@ +varying vec3 vertex_normal; +varying vec4 vertex_position; + +void main(void) +{ + const vec4 OutlineColor = vec4(0.0, 0.0, 0.0, 1.0); + const vec2 OutlineThickness = vec2(0.1, 0.4); + const vec4 BaseColor = vec4(0.0, 0.3, 0.0, 1.0); + const vec4 LightColor = vec4(1.0, 1.0, 1.0, 1.0); + const vec4 LightSourcePosition = vec4(4.0, 3.0, 1.0, 1.0); + const vec4 DiffuseColor = vec4(0.0, 0.6, 0.0, 1.0); + const vec4 SpecularColor = vec4(1.0, 1.0, 1.0, 0.7); + const float DiffuseThreshold = 0.1; + const float SpecularThreshold = 0.5; + const float Shininess = 10.0; + + // Initialize the fragment color with an unlit value. + vec4 fragColor = BaseColor; + + // Set up factors for computing diffuse illumination + vec3 vertex_light = LightSourcePosition.xyz - vertex_position.xyz; + vec3 N = normalize(vertex_normal); + vec3 L = normalize(vertex_light); + float NdotL = dot(N, L); + float maxNdotL = max(NdotL, 0.0); + float attenuation = length(LightSourcePosition) / length(vertex_light); + + // See if we have a diffuse contribution... + // This will only be true if the interpolated normal and the light + // are pointing in the "same" direction, and the attenuation due to + // distance allows enough light for diffuse reflection. + if (attenuation * maxNdotL >= DiffuseThreshold) { + fragColor = LightColor * DiffuseColor; + } + + // See if this fragment is part of the silhouette + // If it is facing away from the viewer enough not to get any + // diffuse illumination contribution, then it is close enough + // to the silouhette to be painted with the outline color rather + // than the unlit color. + vec3 V = normalize(-vertex_position.xyz); + if (dot(V, N) < + mix(OutlineThickness.x, OutlineThickness.y, maxNdotL)) { + fragColor = LightColor * OutlineColor; + } + + // See if we have a specular contribution... + // If the interpolated normal direction and the light direction + // are facing the "same" direction, and the attenuated specular + // intensity is strong enough, then we have a contribution. + vec3 R = reflect(-L, N); + float specularIntensity = pow(max(0.0, dot(R, V)), Shininess); + if (NdotL > 0.0 && attenuation * specularIntensity > SpecularThreshold) { + fragColor = SpecularColor.a * LightColor * SpecularColor + + (1.0 - SpecularColor.a) * fragColor; + } + + // Emit the final color + gl_FragColor = vec4(fragColor.xyz, 1.0); +} === modified file 'src/default-benchmarks.h' --- src/default-benchmarks.h 2012-12-07 19:57:44 +0000 +++ src/default-benchmarks.h 2013-08-13 22:21:11 +0000 @@ -49,6 +49,7 @@ benchmarks.push_back("shading:shading=gouraud"); benchmarks.push_back("shading:shading=blinn-phong-inf"); benchmarks.push_back("shading:shading=phong"); + benchmarks.push_back("shading:shading=cel"); benchmarks.push_back("bump:bump-render=high-poly"); benchmarks.push_back("bump:bump-render=normals"); benchmarks.push_back("bump:bump-render=height"); === modified file 'src/scene-shading.cpp' --- src/scene-shading.cpp 2013-01-29 17:17:28 +0000 +++ src/scene-shading.cpp 2013-08-09 15:58:37 +0000 @@ -59,7 +59,7 @@ } options_["shading"] = Scene::Option("shading", "gouraud", "Which shading method to use", - "gouraud,blinn-phong-inf,phong"); + "gouraud,blinn-phong-inf,phong,cel"); options_["num-lights"] = Scene::Option("num-lights", "1", "The number of lights applied to the scene (phong only)"); options_["model"] = Scene::Option("model", "cat", "Which model to use", @@ -178,6 +178,12 @@ frg_source.add_const("MaterialDiffuse", materialDiffuse); vtx_source.append_file(vtx_shader_filename); } + else if (shading == "cel") { + vtx_shader_filename = GLMARK_DATA_PATH"/shaders/light-phong.vert"; + frg_shader_filename = GLMARK_DATA_PATH"/shaders/light-cel.frag"; + vtx_source.append_file(vtx_shader_filename); + frg_source.append_file(frg_shader_filename); + } if (!Scene::load_shaders_from_strings(program_, vtx_source.str(), frg_source.str()))